Fix cast receiver background (#11825)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Paulus Schoutsen 2022-02-24 02:52:12 -08:00 committed by GitHub
parent 892f774792
commit cd740ed135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property, query } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event"; import { fireEvent } from "../../../../src/common/dom/fire_event";
import { LovelaceConfig } from "../../../../src/data/lovelace"; import { LovelaceConfig } from "../../../../src/data/lovelace";
import { Lovelace } from "../../../../src/panels/lovelace/types"; import { Lovelace } from "../../../../src/panels/lovelace/types";
@ -20,6 +20,8 @@ class HcLovelace extends LitElement {
@property() public urlPath: string | null = null; @property() public urlPath: string | null = null;
@query("hui-view") private _huiView?: HTMLElement;
protected render(): TemplateResult { protected render(): TemplateResult {
const index = this._viewIndex; const index = this._viewIndex;
if (index === undefined) { if (index === undefined) {
@ -78,12 +80,12 @@ class HcLovelace extends LitElement {
this.lovelaceConfig.background; this.lovelaceConfig.background;
if (configBackground) { if (configBackground) {
(this.shadowRoot!.querySelector( this._huiView!.style.setProperty(
"hui-view"
) as HTMLElement)!.style.setProperty(
"--lovelace-background", "--lovelace-background",
configBackground configBackground
); );
} else {
this._huiView!.style.removeProperty("--lovelace-background");
} }
} }
} }
@ -116,6 +118,9 @@ class HcLovelace extends LitElement {
:host > * { :host > * {
flex: 1; flex: 1;
} }
hui-view {
background: var(--lovelace-background, var(--primary-background-color));
}
`; `;
} }
} }