diff --git a/src/components/ha-selector/ha-selector-location.ts b/src/components/ha-selector/ha-selector-location.ts index 26831a793d..a7e030122e 100644 --- a/src/components/ha-selector/ha-selector-location.ts +++ b/src/components/ha-selector/ha-selector-location.ts @@ -6,7 +6,6 @@ import type { LocationSelector, LocationSelectorValue, } from "../../data/selector"; -import "../../panels/lovelace/components/hui-theme-select-editor"; import type { HomeAssistant } from "../../types"; import type { MarkerLocation } from "../map/ha-locations-editor"; import "../map/ha-locations-editor"; diff --git a/src/components/ha-selector/ha-selector-theme.ts b/src/components/ha-selector/ha-selector-theme.ts index d25539908f..f90362b552 100644 --- a/src/components/ha-selector/ha-selector-theme.ts +++ b/src/components/ha-selector/ha-selector-theme.ts @@ -1,4 +1,4 @@ -import "../../panels/lovelace/components/hui-theme-select-editor"; +import "../ha-theme-picker"; import { html, LitElement } from "lit"; import { customElement, property } from "lit/decorators"; import type { HomeAssistant } from "../../types"; @@ -18,11 +18,11 @@ export class HaThemeSelector extends LitElement { protected render() { return html` - + > `; } } diff --git a/src/panels/lovelace/components/hui-theme-select-editor.ts b/src/components/ha-theme-picker.ts similarity index 68% rename from src/panels/lovelace/components/hui-theme-select-editor.ts rename to src/components/ha-theme-picker.ts index 659b5af4e9..093865d3a7 100644 --- a/src/panels/lovelace/components/hui-theme-select-editor.ts +++ b/src/components/ha-theme-picker.ts @@ -2,13 +2,13 @@ import "@material/mwc-button"; import "@material/mwc-list/mwc-list-item"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; -import { fireEvent } from "../../../common/dom/fire_event"; -import { stopPropagation } from "../../../common/dom/stop_propagation"; -import "../../../components/ha-select"; -import { HomeAssistant } from "../../../types"; +import { fireEvent } from "../common/dom/fire_event"; +import { stopPropagation } from "../common/dom/stop_propagation"; +import "./ha-select"; +import { HomeAssistant } from "../types"; -@customElement("hui-theme-select-editor") -export class HuiThemeSelectEditor extends LitElement { +@customElement("ha-theme-picker") +export class HaThemePicker extends LitElement { @property() public value?: string; @property() public label?: string; @@ -19,11 +19,7 @@ export class HuiThemeSelectEditor extends LitElement { return html` ${this.hass!.localize( - "ui.panel.lovelace.editor.card.generic.no_theme" + "ui.components.theme_picker.no_theme" )} ${Object.keys(this.hass!.themes.themes) @@ -64,6 +60,6 @@ export class HuiThemeSelectEditor extends LitElement { declare global { interface HTMLElementTagNameMap { - "hui-theme-select-editor": HuiThemeSelectEditor; + "ha-theme-picker": HaThemePicker; } } diff --git a/src/panels/lovelace/editor/config-elements/config-elements-style.ts b/src/panels/lovelace/editor/config-elements/config-elements-style.ts index 2931974935..2f068a1f91 100644 --- a/src/panels/lovelace/editor/config-elements/config-elements-style.ts +++ b/src/panels/lovelace/editor/config-elements/config-elements-style.ts @@ -23,7 +23,6 @@ export const configElementStyle = css` .suffix { margin: 0 8px; } - hui-theme-select-editor, hui-action-editor, ha-select, ha-textfield, diff --git a/src/panels/lovelace/editor/config-elements/hui-alarm-panel-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-alarm-panel-card-editor.ts index ae8f79bd27..96f98fbbc2 100644 --- a/src/panels/lovelace/editor/config-elements/hui-alarm-panel-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-alarm-panel-card-editor.ts @@ -99,6 +99,14 @@ export class HuiAlarmPanelCardEditor return this.hass!.localize(`ui.panel.lovelace.editor.card.generic.name`); } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return this.hass!.localize( `ui.panel.lovelace.editor.card.alarm-panel.${ schema.name === "states" ? "available_states" : schema.name diff --git a/src/panels/lovelace/editor/config-elements/hui-area-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-area-card-editor.ts index 447c1ccd2e..ed4114bda5 100644 --- a/src/panels/lovelace/editor/config-elements/hui-area-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-area-card-editor.ts @@ -69,6 +69,12 @@ export class HuiAreaCardEditor private _computeLabelCallback = (schema: HaFormSchema) => { switch (schema.name) { + case "theme": + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; case "area": return this.hass!.localize("ui.panel.lovelace.editor.card.area.name"); case "navigation_path": diff --git a/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts index 2445a1e045..90bc7e51d3 100644 --- a/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-button-card-editor.ts @@ -200,6 +200,14 @@ export class HuiButtonCardEditor )}`; } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return this.hass!.localize( `ui.panel.lovelace.editor.card.generic.${schema.name}` ); diff --git a/src/panels/lovelace/editor/config-elements/hui-calendar-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-calendar-card-editor.ts index 30c81af52c..b1e6baa3e5 100644 --- a/src/panels/lovelace/editor/config-elements/hui-calendar-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-calendar-card-editor.ts @@ -121,6 +121,14 @@ export class HuiCalendarCardEditor return this.hass!.localize("ui.panel.lovelace.editor.card.generic.title"); } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return this.hass!.localize( `ui.panel.lovelace.editor.card.calendar.${schema.name}` ); diff --git a/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts index b0c418718e..536eede67c 100644 --- a/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-entities-card-editor.ts @@ -31,7 +31,7 @@ import "../../../../components/ha-icon"; import "../../../../components/ha-switch"; import type { HomeAssistant } from "../../../../types"; import type { EntitiesCardConfig } from "../../cards/types"; -import "../../components/hui-theme-select-editor"; +import "../../../../components/ha-theme-picker"; import { TIMESTAMP_RENDERING_FORMATS } from "../../components/types"; import type { LovelaceRowConfig } from "../../entity-rows/types"; import { headerFooterConfigStructs } from "../../header-footer/structs"; @@ -265,12 +265,17 @@ export class HuiEntitiesCardEditor .configValue=${"title"} @input=${this._valueChanged} > - + >
- this.hass!.localize( - `ui.panel.lovelace.editor.card.glance.${schema.name}` - ) || - this.hass!.localize(`ui.panel.lovelace.editor.card.generic.${schema.name}`); + private _computeLabelCallback = (schema: HaFormSchema) => { + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return ( + this.hass!.localize( + `ui.panel.lovelace.editor.card.glance.${schema.name}` + ) || + this.hass!.localize( + `ui.panel.lovelace.editor.card.generic.${schema.name}` + ) + ); + }; } declare global { diff --git a/src/panels/lovelace/editor/config-elements/hui-humidifier-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-humidifier-card-editor.ts index 7f472d39a1..b5e83f7c81 100644 --- a/src/panels/lovelace/editor/config-elements/hui-humidifier-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-humidifier-card-editor.ts @@ -75,6 +75,14 @@ export class HuiHumidifierCardEditor ); } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return this.hass!.localize( `ui.panel.lovelace.editor.card.generic.${schema.name}` ); diff --git a/src/panels/lovelace/editor/config-elements/hui-light-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-light-card-editor.ts index 8995c7a6ff..42e47ef81a 100644 --- a/src/panels/lovelace/editor/config-elements/hui-light-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-light-card-editor.ts @@ -179,6 +179,14 @@ export class HuiLightCardEditor ); } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return this.hass!.localize( `ui.panel.lovelace.editor.card.generic.${schema.name}` ); diff --git a/src/panels/lovelace/editor/config-elements/hui-logbook-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-logbook-card-editor.ts index 427535e412..f789c09bbe 100644 --- a/src/panels/lovelace/editor/config-elements/hui-logbook-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-logbook-card-editor.ts @@ -96,11 +96,24 @@ export class HuiLogbookCardEditor fireEvent(this, "config-changed", { config: ev.detail.value }); } - private _computeLabelCallback = (schema: HaFormSchema) => - this.hass!.localize( - `ui.panel.lovelace.editor.card.generic.${schema.name}` - ) || - this.hass!.localize(`ui.panel.lovelace.editor.card.logbook.${schema.name}`); + private _computeLabelCallback = (schema: HaFormSchema) => { + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + + return ( + this.hass!.localize( + `ui.panel.lovelace.editor.card.generic.${schema.name}` + ) || + this.hass!.localize( + `ui.panel.lovelace.editor.card.logbook.${schema.name}` + ) + ); + }; } declare global { diff --git a/src/panels/lovelace/editor/config-elements/hui-markdown-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-markdown-card-editor.ts index fe1b3360c4..54dc74bcd7 100644 --- a/src/panels/lovelace/editor/config-elements/hui-markdown-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-markdown-card-editor.ts @@ -58,13 +58,23 @@ export class HuiMarkdownCardEditor fireEvent(this, "config-changed", { config: ev.detail.value }); } - private _computeLabelCallback = (schema: HaFormSchema) => - this.hass!.localize( - `ui.panel.lovelace.editor.card.generic.${schema.name}` - ) || - this.hass!.localize( - `ui.panel.lovelace.editor.card.markdown.${schema.name}` + private _computeLabelCallback = (schema: HaFormSchema) => { + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return ( + this.hass!.localize( + `ui.panel.lovelace.editor.card.generic.${schema.name}` + ) || + this.hass!.localize( + `ui.panel.lovelace.editor.card.markdown.${schema.name}` + ) ); + }; } declare global { diff --git a/src/panels/lovelace/editor/config-elements/hui-media-control-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-media-control-card-editor.ts index 012dac5a35..9732c5b7a4 100644 --- a/src/panels/lovelace/editor/config-elements/hui-media-control-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-media-control-card-editor.ts @@ -5,7 +5,7 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/entity/ha-entity-picker"; import { HomeAssistant } from "../../../../types"; import { MediaControlCardConfig } from "../../cards/types"; -import "../../components/hui-theme-select-editor"; +import "../../../../components/ha-theme-picker"; import { LovelaceCardEditor } from "../../types"; import { baseLovelaceCardConfig } from "../structs/base-card-struct"; import { EditorTarget, EntitiesEditorEvent } from "../types"; @@ -62,12 +62,17 @@ export class HuiMediaControlCardEditor @change=${this._valueChanged} allow-custom-entity > - + >
`; } diff --git a/src/panels/lovelace/editor/config-elements/hui-picture-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-picture-card-editor.ts index a5e156c42d..8174a049e2 100644 --- a/src/panels/lovelace/editor/config-elements/hui-picture-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-picture-card-editor.ts @@ -6,7 +6,7 @@ import { ActionConfig } from "../../../../data/lovelace"; import { HomeAssistant } from "../../../../types"; import { PictureCardConfig } from "../../cards/types"; import "../../components/hui-action-editor"; -import "../../components/hui-theme-select-editor"; +import "../../../../components/ha-theme-picker"; import { LovelaceCardEditor } from "../../types"; import { actionConfigStruct } from "../structs/action-struct"; import { baseLovelaceCardConfig } from "../structs/base-card-struct"; @@ -72,12 +72,17 @@ export class HuiPictureCardEditor .configValue=${"image"} @input=${this._valueChanged} > - + > - + > `; } diff --git a/src/panels/lovelace/editor/config-elements/hui-thermostat-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-thermostat-card-editor.ts index ed4ab2a61b..78d6dc3a97 100644 --- a/src/panels/lovelace/editor/config-elements/hui-thermostat-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-thermostat-card-editor.ts @@ -71,6 +71,14 @@ export class HuiThermostatCardEditor ); } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return this.hass!.localize( `ui.panel.lovelace.editor.card.generic.${schema.name}` ); diff --git a/src/panels/lovelace/editor/config-elements/hui-weather-forecast-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-weather-forecast-card-editor.ts index cd6c2ab227..70a310b5da 100644 --- a/src/panels/lovelace/editor/config-elements/hui-weather-forecast-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-weather-forecast-card-editor.ts @@ -184,6 +184,14 @@ export class HuiWeatherForecastCardEditor )})`; } + if (schema.name === "theme") { + return `${this.hass!.localize( + "ui.panel.lovelace.editor.card.generic.theme" + )} (${this.hass!.localize( + "ui.panel.lovelace.editor.card.config.optional" + )})`; + } + return ( this.hass!.localize( `ui.panel.lovelace.editor.card.generic.${schema.name}` diff --git a/src/translations/en.json b/src/translations/en.json index 3ef90c50bd..4075052bd6 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -401,6 +401,10 @@ "add_device_id": "Choose device", "add_entity_id": "Choose entity" }, + "theme-picker": { + "theme": "Theme", + "no_theme": "No theme" + }, "user-picker": { "no_user": "No user", "add_user": "Add user", @@ -3458,7 +3462,6 @@ "tap_action": "Tap Action", "title": "Title", "theme": "Theme", - "no_theme": "No theme", "unit": "Unit", "url": "URL", "state": "State",