"children": [
{
"forEach": "choice in [$Colors]",
"elmType": "div",
"style": {
"box-sizing": "border-box",
"padding": "4px 8px 5px 8px",
"overflow": "hidden",
"text-overflow": "ellipsis",
"display": "flex",
"border-radius": "16px",
"height": "24px",
"align-items": "center",
"white-space": "nowrap",
"margin": "4px 4px 4px 4px",
"background-color": "=if([$choice]=='Autumn Orange','#c93712', if([$choice]=='Battleship Grey','#3b3b42',if([$choice]=='Black','#282828',if([$choice]=='Bright Purple','#3e2249',if([$choice]=='Burgundy','#933a50',if([$choice]=='Brilliant Blue','#1482bd',if([$choice]=='Carolina Blue','#6e99db',if([$choice]=='Celadon Blue','#3479aa',if([$choice]=='Cool Grey','#999999',if([$choice]=='Dark Green','#2c3d39',if([$choice]=='Engine Red','#ad1730',if([$choice]=='Gusty Grey','#9c9899',if([$choice]=='Jewel Green','#0e8261',if([$choice]=='Lime','#91de5c',if([$choice]=='Magenta','#932063',if([$choice]=='Maroon','#5b2032',if([$choice]=='Navy','#1d2331',if([$choice]=='Neon Orange','#fe4c2c',if([$choice]=='Neon Yellow','#d9ff45',if([$choice]=='Pink Raspberry','#fc355e',if([$choice]=='Red','#c30a2b',if([$choice]=='Royal','#323d73',if([$choice]=='Steel Grey','#414642',if([$choice]=='Stone','#dacbae',if([$choice]=='Teal Green','#017d79',if([$choice]=='True Navy','#292b46',if([$choice]=='True Royal','#1c3578',if([$choice]=='White','#f2f2f2',if([$choice]=='Yellow','#f4ce2d',''))",
"color": "#6e6e6e",
"font-weight": "bold"
},
"txtContent": "[$choice]"
I am developing a list that will act as a catalog for clothing. The code posted for the gallery view of this list. The snipped posted basically populates choice pills with the associated shirt colors as the background colors.
Is there any way I can reference the "background-color" of the current "for each" loop in the "color" element? For example, "color": "$choice.attribute.background-color"
Ideally, if I'm able to reference elements within elements as stated above, I would like to convert all the hex values to rgba and throw in a formula for the luminance values to figure out optimal font colors for each pill.