diff --git a/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts
index 225de47da4..701936440f 100644
--- a/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts
+++ b/src/panels/lovelace/editor/config-elements/hui-tile-card-editor.ts
@@ -1,5 +1,6 @@
+import { mdiGestureTap, mdiPalette } from "@mdi/js";
import { HassEntity } from "home-assistant-js-websocket";
-import { html, LitElement, TemplateResult } from "lit";
+import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { assert, assign, object, optional, string } from "superstruct";
@@ -8,6 +9,7 @@ import { fireEvent } from "../../../../common/dom/fire_event";
import { computeDomain } from "../../../../common/entity/compute_domain";
import { domainIcon } from "../../../../common/entity/domain_icon";
import { capitalizeFirstLetter } from "../../../../common/string/capitalize-first-letter";
+import { LocalizeFunc } from "../../../../common/translations/localize";
import "../../../../components/ha-form/ha-form";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
@@ -42,63 +44,89 @@ export class HuiTileCardEditor
this._config = config;
}
- private _schema = memoizeOne(
- (entity: string, icon?: string, entityState?: HassEntity) =>
+ private _mainSchema = [{ name: "entity", selector: { entity: {} } }] as const;
+
+ private _appearanceSchema = memoizeOne(
+ (
+ localize: LocalizeFunc,
+ entity: string,
+ icon?: string,
+ entityState?: HassEntity
+ ) =>
[
- { name: "entity", selector: { entity: {} } },
- { name: "name", selector: { text: {} } },
{
- name: "icon",
- selector: {
- icon: {
- placeholder: icon || entityState?.attributes.icon,
- fallbackPath:
- !icon && !entityState?.attributes.icon && entityState
- ? domainIcon(computeDomain(entity), entityState)
- : undefined,
- },
- },
- },
- {
- name: "color",
- selector: {
- select: {
- options: [
- {
- label: "Default (based on state)",
- value: "default",
+ name: "",
+ type: "grid",
+ schema: [
+ { name: "name", selector: { text: {} } },
+ {
+ name: "icon",
+ selector: {
+ icon: {
+ placeholder: icon || entityState?.attributes.icon,
+ fallbackPath:
+ !icon && !entityState?.attributes.icon && entityState
+ ? domainIcon(computeDomain(entity), entityState)
+ : undefined,
},
- ...Array.from(THEME_COLORS).map((color) => ({
- label: capitalizeFirstLetter(color),
- value: color,
- })),
- ],
+ },
},
- },
- },
- {
- name: "tap_action",
- selector: {
- "ui-action": {},
- },
- },
- {
- name: "icon_tap_action",
- selector: {
- "ui-action": {},
- },
+ {
+ name: "color",
+ selector: {
+ select: {
+ options: [
+ {
+ label: localize(
+ `ui.panel.lovelace.editor.card.tile.default_color`
+ ),
+ value: "default",
+ },
+ ...Array.from(THEME_COLORS).map((color) => ({
+ label: capitalizeFirstLetter(color),
+ value: color,
+ })),
+ ],
+ },
+ },
+ },
+ ] as const,
},
] as const
);
+ private _actionsSchema = [
+ {
+ name: "tap_action",
+ selector: {
+ "ui-action": {},
+ },
+ },
+ {
+ name: "icon_tap_action",
+ selector: {
+ "ui-action": {},
+ },
+ },
+ ] as const;
+
protected render(): TemplateResult {
if (!this.hass || !this._config) {
return html``;
}
- const entity = this.hass.states[this._config.entity ?? ""];
+ const entity = this.hass.states[this._config.entity ?? ""] as
+ | HassEntity
+ | undefined;
- const schema = this._schema(this._config.entity, this._config.icon, entity);
+ const mainSchema = this._mainSchema;
+ const appareanceSchema = this._appearanceSchema(
+ this.hass.localize,
+ this._config.entity,
+ this._config.icon,
+ entity
+ );
+ const actionsSchema = this._actionsSchema;
const data = {
color: "default",
@@ -106,13 +134,55 @@ export class HuiTileCardEditor
};
return html`
-