1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Add customizable dismiss label to ha-alert component (#51337)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Petar Petrov
2026-04-01 16:20:05 +02:00
committed by GitHub
parent e36a2e1c70
commit 3b8f219800
3 changed files with 10 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import {
import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import type { LocalizeFunc } from "../common/translations/localize";
import { fireEvent } from "../common/dom/fire_event";
import "./ha-icon-button";
import "./ha-svg-icon";
@@ -38,6 +39,8 @@ class HaAlert extends LitElement {
@property({ type: Boolean }) public dismissable = false;
@property({ attribute: false }) public localize?: LocalizeFunc;
@property({ type: Boolean }) public narrow = false;
public render() {
@@ -65,7 +68,7 @@ class HaAlert extends LitElement {
${this.dismissable
? html`<ha-icon-button
@click=${this._dismissClicked}
label="Dismiss alert"
.label=${this.localize!("ui.common.dismiss_alert")}
.path=${mdiClose}
></ha-icon-button>`
: nothing}

View File

@@ -143,7 +143,11 @@ export class HuiEnergyCompareCard
);
return html`
<ha-alert dismissable @alert-dismissed-clicked=${this._stopCompare}>
<ha-alert
dismissable
.localize=${this.hass.localize}
@alert-dismissed-clicked=${this._stopCompare}
>
${this.hass.localize(
"ui.panel.lovelace.cards.energy.energy_compare.info",
{

View File

@@ -443,6 +443,7 @@
"update": "Update",
"hide": "Hide",
"close": "Close",
"dismiss_alert": "Dismiss alert",
"clear": "Clear",
"leave": "Leave",
"stay": "Stay",