Iconcolor from Parameter?


Is there a way to take the color from a parameter in an “if statement” for an icon?

The ‘=props.fgcolor ’ didn’t work, and I’m sure it’s just a matter of syntax:

uid: Shuffle_Test
tags: []
- description: rgba or HEX
label: Foreground Color
name: fgcolor
required: false
type: TEXT
parameterGroups: []
timestamp: Aug 4, 2022, 8:17:05 PM
component: f7-card
config: {}
- component: oh-button
action: command
actionCommand: ‘=(items[props.shuffle].state !== “ON”) ? “ON” : “OFF”’
actionItem: =props.shuffle
iconColor: “=items[props.shuffle].state === ‘OFF’ ? themeOptions.dark === ‘dark’ ? ‘white’ : ‘black’ : ‘=props.fgcolor’”
iconF7: shuffle
iconSize: 25

You have an extra = before the props.fgcolor. Just as you don’t need it for the 'white' or 'black' results, you don’t need if for the props call either.

iconColor: "=(items[props.shuffle].state === 'OFF') ? ((themeOptions.dark === 'dark') ? 'white' : 'black') : props.fgcolor"

*The parentheses are not required but, in my opinion, help with readability.
**It’s probably just related to how you pasted the code into the post, but be careful - you have “smart” quotes around all the values, not run-of-the-mill, regular quotes.

Hello @JustinG,

again many thanks for your help.
I’m sure you also know how a similar problem can be solved with the oh-chart.

I would also like to take the colors from the parameters here, but the props.graphColor1 doesn’t work with or without =:

- component: oh-chart
        - props.graphColor1
        - rgba(255,100,0,1)
        - green
    period: W

it would be awesome if i could add a color picker to the parameters. Is this possible?

It’s likely that this is not possible. See the discussion here for some details:

Ah ok. That’s a pity

There’s an initiative to bring expressions to chart widgets but it’s stale - I offered to extend the support of expressions to chart widgets so there’s no ambiguity which widgets accept expressions and which don’t:

As for the “that’s a pity” remark (and the “it’s a shame” I’ve read several times already wrt. the stuff I made for this community) I would have many things to say but I’ll restrain myself.