Align entity errors (#9904)

This commit is contained in:
Bram Kragten 2021-08-30 10:38:33 +02:00 committed by GitHub
parent 7c952d92bf
commit 6e38f5accf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 9 deletions

View File

@ -192,6 +192,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
padding: 0 16px 4px; padding: 0 16px 4px;
flex-wrap: wrap; flex-wrap: wrap;
box-sizing: border-box; box-sizing: border-box;
align-items: center;
align-content: center; align-content: center;
} }
.entities.no-header { .entities.no-header {
@ -224,9 +225,31 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
.name { .name {
min-height: var(--paper-font-body1_-_line-height, 20px); min-height: var(--paper-font-body1_-_line-height, 20px);
} }
.warning {
cursor: default;
position: relative;
padding: 8px;
width: calc(var(--glance-column-width, 20%) - 4px);
margin: 0 2px;
}
.warning::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0.12;
pointer-events: none;
content: "";
border-radius: 4px;
background-color: var(--warning-color);
}
state-badge { state-badge {
margin: 8px 0; margin: 8px 0;
} }
hui-warning-element {
padding: 8px;
}
`; `;
} }
@ -234,11 +257,24 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
const stateObj = this.hass!.states[entityConf.entity]; const stateObj = this.hass!.states[entityConf.entity];
if (!stateObj) { if (!stateObj) {
return html` return html`<div class="entity warning">
<hui-warning-element ${this._config!.show_name
.label=${createEntityNotFoundWarning(this.hass!, entityConf.entity)} ? html`
></hui-warning-element> <div class="name">
`; ${createEntityNotFoundWarning(this.hass!, entityConf.entity)}
</div>
`
: ""}
${this._config!.show_icon
? html` <hui-warning-element
.label=${createEntityNotFoundWarning(
this.hass!,
entityConf.entity
)}
></hui-warning-element>`
: ""}
<div>${this._config!.show_state ? entityConf.entity : ""}</div>
</div>`;
} }
return html` return html`

View File

@ -337,6 +337,9 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
ha-icon-button.state-on { ha-icon-button.state-on {
color: var(--ha-picture-icon-button-on-color, white); color: var(--ha-picture-icon-button-on-color, white);
} }
hui-warning-element {
padding: 0 8px;
}
.state { .state {
display: block; display: block;
font-size: 12px; font-size: 12px;

View File

@ -1,19 +1,22 @@
import { mdiAlertOutline } from "@mdi/js";
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 } from "lit/decorators";
import "../../../components/ha-icon"; import "../../../components/ha-svg-icon";
@customElement("hui-warning-element") @customElement("hui-warning-element")
export class HuiWarningElement extends LitElement { export class HuiWarningElement extends LitElement {
@property() public label?: string; @property() public label?: string;
protected render(): TemplateResult { protected render(): TemplateResult {
return html` <ha-icon icon="hass:alert" .title=${this.label}></ha-icon> `; return html`
<ha-svg-icon .path=${mdiAlertOutline} .title=${this.label}></ha-svg-icon>
`;
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {
return css` return css`
ha-icon { ha-svg-icon {
color: #fce588; color: var(--warning-color);
} }
`; `;
} }