thomasloven / lovelace-card-mod

🔹 Add CSS styles to (almost) any lovelace card
MIT License
1.06k stars 169 forks source link

Color in rgb-format is not applied #239

Closed seanomat closed 6 months ago

seanomat commented 1 year ago

My Home Assistant version: 2022.12

My lovelace configuration method (GUI or yaml): yaml

What I am doing: apply state-depending color to icon. Since the recent changes to state-colors in HA 2022.12, state-colors need to be defined as rgb-values, hex or names are no longer allowed. When I try to apply a color in rgb-notation to an icon, the icon turns black. The default should be blue, but it turns black, so I guess the style is applied, but the color-format can not be interpreted. When I change the css-definition of the color to hex-notation, the color is apllied as expected. This would mean I have to define every color twice in different notations.

What I expected to happen: the color to be applied

What happened instead: color not being applied, turns black instead

Minimal steps to reproduce:

# The least amount of code possible to reproduce my error
THEME:
  accent-color-01: 255,193,7
#  accent-color-01: "#ff0000"

CARD:
      style: |
        :host {
          --paper-item-icon-color: var(--accent-color-01);
        }  

# End of code

Error messages from the browser console: No errors, just not applied


By putting an X in the boxes ([]) below, I indicate that I:

ildar170975 commented 1 year ago

state-colors need to be defined as rgb-values, hex or names are no longer allowed.

Wrong, you may define your OWN variables as you like. Although HA dev decided to define new vars as "255,255,255" - you should not repeat same not wise decision and you may keep defining your OWN vars as you wish. "OWN" - means your unique vars with different names.

seanomat commented 1 year ago

I am using my own vars but that doesn't change anything about what format the value of this variable has to have to be applied. When I define the color in HEX it will not be applied to the new states, and if I define it in RGB it will not be applied to the card-mod-styles.

ildar170975 commented 1 year ago

When I define the color in HEX it will not be applied to the new states, and if I define it in RGB it will not be applied to the card-mod-styles.

This is a point - the new shiny Way is for internal use, not for dirty external custom plugins. Solution: use "---rgb" values for the newly added vars. And these vars will be used for conventional cards. For customizing cards by card-mod - do NOT use vars, dig into DOM to use CSS properties.

thomasloven commented 6 months ago

255,193,7 is not a valid CSS color. rgb(255,193,7) is bild