Add support for panels to cast (#3796)

* Add panel support to cast

* Set background
This commit is contained in:
Bram Kragten 2019-09-23 23:03:45 +02:00 committed by Paulus Schoutsen
parent a1b9a092d0
commit 2fe4a02b6b

View File

@ -9,6 +9,7 @@ import {
} from "lit-element"; } from "lit-element";
import { LovelaceConfig } from "../../../../src/data/lovelace"; import { LovelaceConfig } from "../../../../src/data/lovelace";
import "../../../../src/panels/lovelace/views/hui-view"; import "../../../../src/panels/lovelace/views/hui-view";
import "../../../../src/panels/lovelace/views/hui-panel-view";
import { HomeAssistant } from "../../../../src/types"; import { HomeAssistant } from "../../../../src/types";
import { Lovelace } from "../../../../src/panels/lovelace/types"; import { Lovelace } from "../../../../src/panels/lovelace/types";
import "./hc-launch-screen"; import "./hc-launch-screen";
@ -40,7 +41,14 @@ class HcLovelace extends LitElement {
saveConfig: async () => undefined, saveConfig: async () => undefined,
setEditMode: () => undefined, setEditMode: () => undefined,
}; };
return html` return this.lovelaceConfig.views[index].panel
? html`
<hui-panel-view
.hass=${this.hass}
.config=${this.lovelaceConfig.views[index]}
></hui-panel-view>
`
: html`
<hui-view <hui-view
.hass=${this.hass} .hass=${this.hass}
.lovelace=${lovelace} .lovelace=${lovelace}
@ -62,7 +70,9 @@ class HcLovelace extends LitElement {
this.lovelaceConfig.background; this.lovelaceConfig.background;
if (configBackground) { if (configBackground) {
this.shadowRoot!.querySelector("hui-view")!.style.setProperty( (this.shadowRoot!.querySelector(
"hui-view, hui-panel-view"
) as HTMLElement)!.style.setProperty(
"--lovelace-background", "--lovelace-background",
configBackground configBackground
); );
@ -94,7 +104,7 @@ class HcLovelace extends LitElement {
box-sizing: border-box; box-sizing: border-box;
background: var(--primary-background-color); background: var(--primary-background-color);
} }
hui-view { :host > * {
flex: 1; flex: 1;
} }
`; `;