Is there a way to take the color from a parameter in an “if statement” for an icon?
=props.fgcolor ’ didn’t work, and I’m sure it’s just a matter of syntax:
- description: rgba or HEX
label: Foreground Color
timestamp: Aug 4, 2022, 8:17:05 PM
- component: oh-button
actionCommand: ‘=(items[props.shuffle].state !== “ON”) ? “ON” : “OFF”’
iconColor: “=items[props.shuffle].state === ‘OFF’ ? themeOptions.dark === ‘dark’ ? ‘white’ : ‘black’ : ‘ =props.fgcolor’”
You have an extra
= before the
props.fgcolor. Just as you don’t need it for the
'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.
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
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:
The chart components are slightly different than the other components since they are wrappers for eCharts and not f7 components. As I understand it, in the chart widgets, not all of the property values are passed through the expression parser. So there are some places, apparently period is one of them, where you cannot yet use expressions. You will likely have to submit a feature request on the webUI github page to get that resolved.
I’m not sure I fully understand what you’re asking here.…
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.