mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +00:00
Make sure lovelace theme background is set on it's container (#20683)
This commit is contained in:
parent
627e06663b
commit
f611f23f6f
@ -886,9 +886,9 @@ class HUIRoot extends LitElement {
|
|||||||
const configBackground = viewConfig.background || this.config.background;
|
const configBackground = viewConfig.background || this.config.background;
|
||||||
|
|
||||||
if (configBackground) {
|
if (configBackground) {
|
||||||
this.style.setProperty("--lovelace-background", configBackground);
|
root.style.setProperty("--lovelace-background", configBackground);
|
||||||
} else {
|
} else {
|
||||||
this.style.removeProperty("--lovelace-background");
|
root.style.removeProperty("--lovelace-background");
|
||||||
}
|
}
|
||||||
|
|
||||||
root.appendChild(view);
|
root.appendChild(view);
|
||||||
|
@ -143,6 +143,11 @@ export class HUIView extends ReactiveElement {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public connectedCallback(): void {
|
||||||
|
super.connectedCallback();
|
||||||
|
this._applyTheme();
|
||||||
|
}
|
||||||
|
|
||||||
public willUpdate(changedProperties: PropertyValues): void {
|
public willUpdate(changedProperties: PropertyValues): void {
|
||||||
super.willUpdate(changedProperties);
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
@ -212,7 +217,7 @@ export class HUIView extends ReactiveElement {
|
|||||||
this.hass.themes !== oldHass.themes ||
|
this.hass.themes !== oldHass.themes ||
|
||||||
this.hass.selectedTheme !== oldHass.selectedTheme
|
this.hass.selectedTheme !== oldHass.selectedTheme
|
||||||
) {
|
) {
|
||||||
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
|
this._applyTheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changedProperties.has("narrow")) {
|
if (changedProperties.has("narrow")) {
|
||||||
@ -238,6 +243,28 @@ export class HUIView extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _applyTheme() {
|
||||||
|
applyThemesOnElement(this, this.hass.themes, this._viewConfigTheme);
|
||||||
|
if (this._viewConfigTheme) {
|
||||||
|
// Set lovelace background color to root element, so it will be placed under the header too
|
||||||
|
const computedStyles = getComputedStyle(this);
|
||||||
|
let lovelaceBackground = computedStyles.getPropertyValue(
|
||||||
|
"--lovelace-background"
|
||||||
|
);
|
||||||
|
if (!lovelaceBackground) {
|
||||||
|
lovelaceBackground = computedStyles.getPropertyValue(
|
||||||
|
"--primary-background-color"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (lovelaceBackground) {
|
||||||
|
this.parentElement?.style.setProperty(
|
||||||
|
"--lovelace-background",
|
||||||
|
lovelaceBackground
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async _initializeConfig() {
|
private async _initializeConfig() {
|
||||||
let viewConfig = this.lovelace.config.views[this.index];
|
let viewConfig = this.lovelace.config.views[this.index];
|
||||||
let isStrategy = false;
|
let isStrategy = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user