From 5bcba95c25b88361505d21e40fd7e612b6a4195e Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Tue, 3 Sep 2019 14:35:37 -0500 Subject: [PATCH] handle unavailable lights (#3549) * handle unavailable lights * unavailable overlay * extract unavailable overlay --- src/panels/lovelace/cards/hui-light-card.ts | 8 +++ .../lovelace/components/hui-unavailable.ts | 55 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/panels/lovelace/components/hui-unavailable.ts diff --git a/src/panels/lovelace/cards/hui-light-card.ts b/src/panels/lovelace/cards/hui-light-card.ts index 9618e4a3bf..a27c7709d8 100644 --- a/src/panels/lovelace/cards/hui-light-card.ts +++ b/src/panels/lovelace/cards/hui-light-card.ts @@ -15,6 +15,7 @@ import applyThemesOnElement from "../../../common/dom/apply_themes_on_element"; import "../../../components/ha-card"; import "../../../components/ha-icon"; import "../components/hui-warning"; +import "../components/hui-unavailable"; import { fireEvent } from "../../../common/dom/fire_event"; import { styleMap } from "lit-html/directives/style-map"; @@ -94,6 +95,13 @@ export class HuiLightCard extends LitElement implements LovelaceCard { return html` ${this.renderStyle()} + ${stateObj.state === "unavailable" + ? html` + + ` + : ""} +
${this.text}
+ + `; + } + + static get styles(): CSSResult { + return css` + .disabled-overlay { + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: var(--state-icon-unavailable-color); + opacity: 0.5; + z-index: 50; + } + + .disabled-overlay div { + position: absolute; + top: 50%; + left: 50%; + font-size: 50px; + color: var(--primary-text-color); + transform: translate(-50%, -50%); + -ms-transform: translate(-50%, -50%); + } + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "hui-unavailable": HuiUnavailable; + } +}