Thank you very much. I can see the image now.
But I did not understand the script completely. I have to use a binding with a markdown-component instead script ? Where exactly do I have to put the binding? If I try:
optionList = []
for option in locals:
optionList.append({
"value": option,
"label": option,
"style": {"color": "red"}
})
self.getChild("root").getChild("FlexContainer_top").getChild("DD_languageTag").props.options = optionList
It dosen´t accept the style property. which is unfortunate.
you replied to the wrong person i think
yes on the bottom of the topic there is someone who linked his post where he goes into more depth using my markdown if you are unfamiliar with it
Anyways if its for some static flags, you can just add the styles in stylesheet.css for every flag.
give your dropdownOptionsStyle a class example "cssFlags"
.psc-cssFlags[data-label="de"] {
color: #FF0000
}
for none static things you'll need the markdown to add these styles
# for extra styling of the dropdown content
dropdownOptionStyle = {
"background-color" : "transparent",
"line-height" : "50px",
"padding-left" : "10px",
"fontStyle" : "italic",
"color" : "green",
}
# define the variable here to "save" complete HTML string
markDownStyle= ""
#Get locals
locals = package.getAvailableLocales()
# import all needed images from the Image Management (pictures have to be uploaded FIRST !)
imgUrlUK = '/system/images/contryIcons/united-kingdom.png'
imgUrlDE = '/system/images/contryIcons/german.png'
# create an optionlist with all locals
optionList = []
# for each option 1.build the option and 2. add style
for option in locals:
# cast java.Locale to string
option = str(option)
optionList.append({
"value": option,
"label": option,
})
# choose imageUrl depending on option
imgUrl = ""
if option == "de":
imgUrl = imgUrlDE
elif option == "en":
imgUrl = imgUrlUK
markDownStyle = markDownStyle + """.iaDropdownCommon_options [data-label=""" + option + """
]:before { content: url(""" + imgUrl + """);}"""
# build the styling with the accumulated markDownStyle
markDowncode = """<style>
""" + markDownStyle + """
</style>"""
# format the string nicer, to make sure the HTML is valid
markDowncode = markDowncode.replace("\n", " ").replace("\t", "")
# set the properties
self.getChild("root").getChild("FlexContainer_top").getChild("DD_languageTag").props.options = optionList
self.getChild("root").getChild("FlexContainer_top").getChild("DD_languageTag").props.dropdownOptionStyle = dropdownOptionStyle
self.getChild("root").getChild("FlexContainer_top").getChild("Markdown").props.source = markDowncode
Thank you very much for your help.
Edit: forgot to add image: