diff --git a/src/panels/lovelace/common/create-row-element.js b/src/panels/lovelace/common/create-row-element.js index e2b02e9712..c269ff86c5 100644 --- a/src/panels/lovelace/common/create-row-element.js +++ b/src/panels/lovelace/common/create-row-element.js @@ -16,9 +16,10 @@ import "../entity-rows/hui-toggle-entity-row.js"; import "../special-rows/hui-call-service-row.js"; import "../special-rows/hui-divider-row"; -import "../special-rows/hui-section-row.js"; +import "../special-rows/hui-section-row"; import "../special-rows/hui-weblink-row"; + import createErrorCardConfig from "./create-error-card-config.js"; const CUSTOM_TYPE_PREFIX = "custom:"; diff --git a/src/panels/lovelace/special-rows/hui-section-row.js b/src/panels/lovelace/special-rows/hui-section-row.js deleted file mode 100644 index 97f1690fad..0000000000 --- a/src/panels/lovelace/special-rows/hui-section-row.js +++ /dev/null @@ -1,53 +0,0 @@ -import { html } from "@polymer/polymer/lib/utils/html-tag.js"; -import { PolymerElement } from "@polymer/polymer/polymer-element.js"; - -import "../../../components/ha-icon.js"; - -class HuiSectionRow extends PolymerElement { - static get template() { - return html` - ${this.styleTemplate} -
- - `; - } - - static get styleTemplate() { - return html` - - `; - } - - static get properties() { - return { - _config: Object, - }; - } - - setConfig(config) { - if (!config) { - throw new Error("Error in card configuration."); - } - this._config = config; - } -} -customElements.define("hui-section-row", HuiSectionRow); diff --git a/src/panels/lovelace/special-rows/hui-section-row.ts b/src/panels/lovelace/special-rows/hui-section-row.ts new file mode 100644 index 0000000000..f590c4d96d --- /dev/null +++ b/src/panels/lovelace/special-rows/hui-section-row.ts @@ -0,0 +1,70 @@ +import { html, LitElement } from "@polymer/lit-element"; +import { EntityRow, SectionConfig } from "../entity-rows/types"; +import { HomeAssistant } from "../../../types"; + +import "../../../components/ha-icon.js"; +import { TemplateResult } from "lit-html"; + +class HuiSectionRow extends LitElement implements EntityRow { + public hass?: HomeAssistant; + private _config?: SectionConfig; + + static get properties() { + return { + _config: {}, + }; + } + + public setConfig(config: SectionConfig): void { + if (!config) { + throw new Error("Error in card configuration."); + } + + this._config = config; + } + + protected render(): TemplateResult { + if (!this._config) { + return html``; + } + + return html` + ${this.renderStyle()} +
+ ${ + this._config.label + ? html`
${this._config.label}
` + : html`` + } + `; + } + + private renderStyle(): TemplateResult { + return html` + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-section-row": HuiSectionRow; + } +} + +customElements.define("hui-section-row", HuiSectionRow);