Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card_light Rework color background #1209

Merged
merged 10 commits into from
Mar 24, 2023

Conversation

basbruss
Copy link
Collaborator

@basbruss basbruss commented Mar 10, 2023

Make background colors more inline with examples found on behance

Example with ulm_card_light_force_background_color: true
image

Old behavior:
image

  • adds variable ulm_card_light_color to set manually the color when a light/switch is on

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the contribution guidelines
    • This PR is for a custom-card or documentation change and therefore directed to the main branch.
    • This PR is for a official card or any other directly to the integration related change and therefore directed to the release branch.

@basbruss
Copy link
Collaborator Author

@benbur98 Inspired by the force background feature of the card_fan I have also implemented the same logic to the card_light 🚀

@benbur98
Copy link
Contributor

Nice work!

I like the white text, it's way more readable than the coloured text previously - I'll check some of the other cards because we might have some inconsistency between cards after this which wouldn't look too good...

For the background, I'm not sure if I prefer the new bold colour in light mode or the old pastel colour personally.
Could make it a variable but aware that the card might get overly complex...

Custom color choice is great too.

@basbruss
Copy link
Collaborator Author

By looking at Behance the bold color background for any active state is definitely the way to go:
image
@schumijo want to you think on the design changes?

benbur98
benbur98 previously approved these changes Mar 10, 2023
Copy link
Contributor

@benbur98 benbur98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested - Card works well :)

@benbur98
Copy link
Contributor

For the Button Colours, what is anyone's opinion on the preferred choice:

Option 1 - Change Icon Only
Option 2 - Set Button Background to White and Icon to the Bard Background Color - this is most similar to the Behance image above
Option 3 - Do Nothing...

image

@basbruss
Copy link
Collaborator Author

@benbur98 Oh damn didn't test that feature haha.
Maybe give it the same values as the icon grid? Same is done with the oscillating button from the card_fan

@benbur98
Copy link
Contributor

image

Good idea, this is with it matched to the icon grid.

Code I added to each button in the list is:

              styles:
                card:
                  - background-color: >
                      [[[
                        if (!hass.themes.darkMode) {
                          var color_set = variables.mui_card_light_enable_color ? entity.attributes.rgb_color : variables.mui_card_light_color;
                          var color = 'rgba(var(--color-' + color_set + '),0.2)'
                          if (variables.mui_card_light_enable_color) {
                            return 'rgba(250, 250, 250,0.8)';
                          }
                          if (entity.state != "on") {
                            return 'rgba(var(--color-theme),0.05)';
                          }
                          return color
                        }
                        return 'rgba(var(--color-theme),0.05)';
                      ]]]
                icon:
                  - color: >
                      [[[
                        if (!hass.themes.darkMode) {
                          var color_set = variables.mui_card_light_enable_color ? entity.attributes.rgb_color : variables.mui_card_light_color;
                          var color = 'rgba(var(--color-' + color_set + '),1)';
                          if (variables.mui_card_light_enable_color) {
                            color = 'rgba(' + color_set + ',1)';
                          }
                          if (entity.state != "on") {
                            return 'rgba(var(--color-theme),0.2)';
                          }
                          return color;
                        }
                        return 'rgba(var(--color-theme),0.9)';
                      ]]]

Can add it myself another day if you want, but I'm not currently on a machine with git.

@benbur98
Copy link
Contributor

Sorry there was a bug in that code when not using the Collapse option, also some unnecessary parts.

Please change for:

                card:
                  - background-color: >
                      [[[
                        if (!hass.themes.darkMode && variables.mui_card_light_force_background_color) {
                          if (variables.mui_card_light_enable_color && entity.state != "off") {
                            return 'rgba(250, 250, 250,0.8)';
                          }
                        }
                        return 'rgba(var(--color-theme),0.05)';
                      ]]]
                icon:
                  - color: >
                      [[[
                        if (!hass.themes.darkMode && variables.mui_card_light_force_background_color) {
                          if (entity.state != "off") {
                            var color_set = variables.mui_card_light_enable_color ? entity.attributes.rgb_color : variables.mui_card_light_color;
                            var color = 'rgba(var(--color-' + color_set + '),1)';
                            if (variables.mui_card_light_enable_color) {
                              color = 'rgba(' + color_set + ',1)';
                            }
                            return color;
                          }
                        }
                        return 'rgba(var(--color-theme),0.9)';
                      ]]]

@basbruss basbruss merged commit 8db2baf into UI-Lovelace-Minimalist:release Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants