diff --git a/src/panels/lovelace/editor/config-elements/hui-view-editor.ts b/src/panels/lovelace/editor/config-elements/hui-view-editor.ts new file mode 100644 index 0000000000..872c776663 --- /dev/null +++ b/src/panels/lovelace/editor/config-elements/hui-view-editor.ts @@ -0,0 +1,128 @@ +import { html, LitElement, PropertyDeclarations } from "@polymer/lit-element"; +import { TemplateResult } from "lit-html"; +import "@polymer/paper-input/paper-input"; + +import { EditorTarget } from "../types"; +import { hassLocalizeLitMixin } from "../../../../mixins/lit-localize-mixin"; +import { HomeAssistant } from "../../../../types"; +import { fireEvent } from "../../../../common/dom/fire_event"; +import { configElementStyle } from "./config-elements-style"; + +import "../../components/hui-theme-select-editor"; +import { LovelaceViewConfig } from "../../../../data/lovelace"; + +declare global { + interface HASSDomEvents { + "view-config-changed": { + config: LovelaceViewConfig; + }; + } +} + +export class HuiViewEditor extends hassLocalizeLitMixin(LitElement) { + static get properties(): PropertyDeclarations { + return { hass: {}, _config: {} }; + } + + get _id(): string { + if (!this._config) { + return ""; + } + return this._config.id || ""; + } + + get _title(): string { + if (!this._config) { + return ""; + } + return this._config.title || ""; + } + + get _icon(): string { + if (!this._config) { + return ""; + } + return this._config.icon || ""; + } + + get _theme(): string { + if (!this._config) { + return ""; + } + return this._config.theme || "Backend-selected"; + } + + public hass?: HomeAssistant; + private _config?: LovelaceViewConfig; + + set config(config: LovelaceViewConfig) { + this._config = config; + } + + protected render(): TemplateResult { + if (!this.hass) { + return html``; + } + + return html` + ${configElementStyle} +