mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
Fix background theme in Lovelace view
This commit is contained in:
parent
0364c5e493
commit
d8ddbefcf6
@ -104,6 +104,36 @@ export class HUIView extends ReactiveElement {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
this._applyBackgroundTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _applyBackgroundTheme() {
|
||||||
|
if (this._viewConfigTheme) {
|
||||||
|
const theme = this.hass.themes.themes[this._viewConfigTheme];
|
||||||
|
if (theme["lovelace-background"]) {
|
||||||
|
this.parentElement?.style.setProperty(
|
||||||
|
"--lovelace-background",
|
||||||
|
theme["lovelace-background"]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.parentElement?.style.removeProperty("--lovelace-background");
|
||||||
|
}
|
||||||
|
if (theme["primary-background-color"]) {
|
||||||
|
this.parentElement?.style.setProperty(
|
||||||
|
"--primary-background-color",
|
||||||
|
theme["primary-background-color"]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.parentElement?.style.removeProperty("--primary-background-color");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.parentElement?.style.removeProperty("--lovelace-background");
|
||||||
|
this.parentElement?.style.removeProperty("--primary-background-color");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public willUpdate(changedProperties: PropertyValues): void {
|
public willUpdate(changedProperties: PropertyValues): void {
|
||||||
super.willUpdate(changedProperties);
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
@ -166,6 +196,7 @@ export class HUIView extends ReactiveElement {
|
|||||||
this.hass.selectedTheme !== oldHass.selectedTheme
|
this.hass.selectedTheme !== oldHass.selectedTheme
|
||||||
) {
|
) {
|
||||||
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
|
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
|
||||||
|
this._applyBackgroundTheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changedProperties.has("narrow")) {
|
if (changedProperties.has("narrow")) {
|
||||||
@ -225,6 +256,8 @@ export class HUIView extends ReactiveElement {
|
|||||||
applyThemesOnElement(this, this.hass.themes, viewConfig.theme);
|
applyThemesOnElement(this, this.hass.themes, viewConfig.theme);
|
||||||
this._viewConfigTheme = viewConfig.theme;
|
this._viewConfigTheme = viewConfig.theme;
|
||||||
|
|
||||||
|
this._applyBackgroundTheme();
|
||||||
|
|
||||||
if (addLayoutElement) {
|
if (addLayoutElement) {
|
||||||
while (this.lastChild) {
|
while (this.lastChild) {
|
||||||
this.removeChild(this.lastChild);
|
this.removeChild(this.lastChild);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user