I am trying to generate custom:button-card elements "on the fly" with JavaScript. It works well with single variables:
variables:
iconColor: "[[[ return '#d0d000'; ]]]"
...
styles:
icon:
color: "[[[ return variables.iconColor; ]]]"
And it works well with arrays:
variables:
objectTemplates: |
[[[
return ['FLEXIBOX-OBJECT', 'OBJECT-TYPE-BUTTON'];
]]]
...
custom_fields:
OBJECT:
card:
- type: custom:button-card
template: "[[[ return variables.objectTemplates; ]]]"
But I haven't managed to work out if it's possible to return a dictionary/map (whatever the terminology is) from a variable - conceptually I'm trying to achieve this:
variables:
myMap: |
[[[
return {
'border-radius': '16px',
'padding': '16px',
'overflow': 'hidden'
};
]]]
...
styles:
card: "[[[ return variables.myMap; ]]]" <-- this doesn't work!
I have tried to find documentation about this, but it seems this is a somewhat unusual use case for button-card variables... I'm not even sure maps are natively supported data structures in JavaScript. Anyone managed to achieve something like this?