mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-24 21:37:21 +00:00
Use ha-alert in lovelace alerts/warnings (#9880)
This commit is contained in:
parent
32777b4259
commit
20744e90a0
@ -1,6 +1,7 @@
|
||||
import { dump } from "js-yaml";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, state } from "lit/decorators";
|
||||
import "../../../components/ha-alert";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { LovelaceCard } from "../types";
|
||||
import { ErrorCardConfig } from "./types";
|
||||
@ -34,25 +35,17 @@ export class HuiErrorCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
}
|
||||
|
||||
return html`
|
||||
${this._config.error}${dumped ? html`<pre>${dumped}</pre>` : ""}
|
||||
`;
|
||||
return html`<ha-alert alert-type="error" .title=${this._config.error}>
|
||||
${dumped ? html`<pre>${dumped}</pre>` : ""}
|
||||
</ha-alert>`;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
:host {
|
||||
display: block;
|
||||
background-color: var(--error-color);
|
||||
color: var(--color-on-error, white);
|
||||
padding: 8px;
|
||||
font-weight: 500;
|
||||
user-select: text;
|
||||
cursor: default;
|
||||
}
|
||||
pre {
|
||||
font-family: var(--code-font-family, monospace);
|
||||
text-overflow: ellipsis;
|
||||
user-select: text;
|
||||
overflow: hidden;
|
||||
}
|
||||
`;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { STATE_NOT_RUNNING } from "home-assistant-js-websocket";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import "../../../components/ha-alert";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
|
||||
export const createEntityNotFoundWarning = (
|
||||
@ -18,19 +19,7 @@ export const createEntityNotFoundWarning = (
|
||||
@customElement("hui-warning")
|
||||
export class HuiWarning extends LitElement {
|
||||
protected render(): TemplateResult {
|
||||
return html` <slot></slot> `;
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
:host {
|
||||
display: block;
|
||||
color: black;
|
||||
background-color: #fce588;
|
||||
padding: 8px;
|
||||
word-break: break-word;
|
||||
}
|
||||
`;
|
||||
return html`<ha-alert alert-type="warning"><slot></slot></ha-alert> `;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user