Skip to content

Variable colours (cards, backgrounds, sidebar, ...)#361

Merged
balloob merged 33 commits into
home-assistant:masterfrom
allardhs:master
Aug 1, 2017
Merged

Variable colours (cards, backgrounds, sidebar, ...)#361
balloob merged 33 commits into
home-assistant:masterfrom
allardhs:master

Conversation

@allardhs
Copy link
Copy Markdown
Contributor

First contribution, apologies for any mistakes.
As discussed in the "Share your Themes thread": https://community.home-assistant.io/t/share-your-themes/22018/9?u=ahs.

Goal is to allow more flexibility with theming (allowing e.g. "night mode") by replacing some hardcoded values by variable colours (which can be defined in custom themes):

  • replaced the white background colour in the state cards (ha-card.html) by the variable background colour
  • replaced the light grey overall background colour by the variable paper-grey-200 colour

Note that the default paper-grey-200 is not exactly the same as the current colour (#E5E5E5) but is the closest match of the defined colours in ha-style.html. It will however lead to a slight recolouring of the default background.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @ahofelt,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Comment thread src/components/ha-card.html Outdated
transition: all 0.30s ease-out;

background-color: white;
background-color: var(--primary-background-color);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets keep default values:
background-color: var(--primary-background-color, white);

Comment thread src/layouts/partial-cards.html Outdated

app-header-layout {
background-color: #E5E5E5;
background-color: var(--paper-grey-200);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Create a separate variable.
If you want a green background here you wouldn't want to override paper-grey-200 to green,

@allardhs
Copy link
Copy Markdown
Contributor Author

You're right @andrey-git changed it now as you suggested. Added a --secondary-background-color definition now in ha-style.html and referenced that one instead of --paper-grey-200. Also added the default colours for both.

@bramkragten
Copy link
Copy Markdown
Member

If you want a proper dark theme you would need a few more adjustments, I don't have a fork right now so maybe you want to add this?

in ha-sidebar:
add to : host
background: var(--paper-listbox-background-color,var(--primary-background-color));

in home-assistant-main add:
color: var(--primary-text-color)

in ha-panel-dev-service change:
.attributes tr:nth-child(even) {
background-color:#eee
}
to:
.attributes tr:nth-child(even) {
background-color: var(--paper-listbox-background-color,#eee) (or a new one?)
}

ha-state-icon:
color: var(--paper-item-icon_-_color, #44739e)
I believe there is another one for active/on, that would need to be changed as well.

The svg in state-history-chart-timeline might need some... for example:
fill="var(--paper-dialog-background-color,var(--primary-background-color))" for the main rect... and
fill="var(--primary-text-color)" for the times underneath...

I think that would bring us pretty close. A few more thing to do in specific components probably.

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Jul 27, 2017

ha-media_player-card

.controls {
...
background-color: var(--same as ha-card);
}
ha-state-label-badge could use some updates, but maybe okay to stay white...

@allardhs
Copy link
Copy Markdown
Contributor Author

@bramkragten : Ok, going through them now -- but unsure on your home-assistant-main point. There's not a lot of styling in there.. https://github.com/home-assistant/home-assistant-polymer/blob/master/src/layouts/home-assistant-main.html

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Jul 27, 2017

Thats for all the text that does not have explicit styling, it now just takes the browser default which is black, we would need to set a text color at some high point, normally you would use the body. But figgered home-assistant-main was high enough and there the custom styles are set aswell... So I would suggest adding a style block? @andrey-git suggestions?

@allardhs
Copy link
Copy Markdown
Contributor Author

As to ha-state-icon, the active state is actually in state-badge.html (currently: #44739E) and the inactive is somewhere in bower_components/paper-dialog/paper-dialog.html (isn't that outside our reach?).
The --paper-item-icon_-_color you suggest is not defined, I think, so it will resort to #44739E which causes the change not to do anything.

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Jul 27, 2017

That would mean we could just define --paper-item-icon_-_color in our styles config, let me try that.

State badge is found here:
https://github.com/home-assistant/home-assistant-polymer/blob/a1057681f1a33cffc79708085c1646d786712a87/src/components/entity/state-badge.html

ha-state-icon {
transition:color .3s ease-in-out;
color: var(--paper-item-icon_-_color, #44739e);
}

ha-state-icon[data-domain=binary_sensor][data-state=on],ha-state-icon[data-domain=light][data-state=on],ha-state-icon[data-domain=sun][data-state=above_horizon],ha-state-icon[data-domain=switch][data-state=on] {
color: var(--paper-item-icon_-_active_color, #fdd835)
}

@allardhs
Copy link
Copy Markdown
Contributor Author

State badge is found here:

Yes, that's where it is defined as #44739E

I added some more changes as you suggested. As to the changes in home-assistant-main, state-history-chart-timeline, and ha-state-icon/state-badge, I'm afraid that's beyond me for now..

@bramkragten
Copy link
Copy Markdown
Member

The charts are a different story indeed, Google charts makes them, I believe you can set options with colors, but I'm not familiair with it. Also not the biggest problem right now.

I'll look at the points left. Have to setup a development environment for the frontend...

@bramkragten
Copy link
Copy Markdown
Member

For the state cards, I would prefer a different variable; paper-card-background-color.
So I can give them a different color then the background.

Thanks for your work btw. I have my def env setup, tomorrow I'll get on to this.

@allardhs allardhs changed the title Variable cards and background colours Variable colours (cards, backgrounds, sidebar, ...) Jul 28, 2017
@balloob
Copy link
Copy Markdown
Member

balloob commented Jul 29, 2017

@ahofelt it looks like you're editing this via the GitHub online editor. Please test this locally.

@balloob
Copy link
Copy Markdown
Member

balloob commented Jul 29, 2017

@bramkragten the problem is that CSS variables does not have functions that SASS has like lighten or darken.

@allardhs
Copy link
Copy Markdown
Contributor Author

@ahofelt it looks like you're editing this via the GitHub online editor. Please test this locally.

@balloob yes that's correct. I'm just a beginner and have my difficulties in understanding it all. But I do test it all locally before mirroring the changes manually in the GitHub online editor. Not the most efficient way but it works for me for now. Triple-checked everything for consistency. All working perfectly well locally. And most of the recent changes have been suggested by @bramkragten and I merely copy (and test) them. Apologies for my ignorance.

@balloob
Copy link
Copy Markdown
Member

balloob commented Aug 1, 2017

Alright, tested it locally and didn't see anything of the default theme be off, so all ok 👍 🐬 congratualtions on getting your first PR merged! 🎉

@balloob balloob merged commit 4af688a into home-assistant:master Aug 1, 2017
@allardhs
Copy link
Copy Markdown
Contributor Author

allardhs commented Aug 1, 2017

Wonderful news. Thanks all, @balloob and especially @bramkragten. Now, let's get theming!

@bramkragten bramkragten mentioned this pull request Feb 12, 2020
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants