From 9cbd49b86769e8418d98b1f7e6c82be6e817aa55 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Wed, 6 Mar 2024 05:45:16 +0100 Subject: [PATCH] Add description to sections demo (#19991) * Add description to sections demo * Update wording --- demo/src/configs/sections/description.ts | 16 ++++++++ demo/src/configs/sections/index.ts | 2 + demo/src/configs/types.ts | 4 ++ demo/src/custom-cards/ha-demo-card.ts | 51 +++++++++++++++++------- src/translations/en.json | 4 ++ 5 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 demo/src/configs/sections/description.ts diff --git a/demo/src/configs/sections/description.ts b/demo/src/configs/sections/description.ts new file mode 100644 index 000000000000..b5762739acaf --- /dev/null +++ b/demo/src/configs/sections/description.ts @@ -0,0 +1,16 @@ +import { html } from "lit"; +import { DemoConfig } from "../types"; + +export const demoLovelaceDescription: DemoConfig["description"] = ( + localize +) => html` +

+ ${localize("ui.panel.page-demo.config.sections.description", { + blog_post: html`${localize("ui.panel.page-demo.config.sections.description_blog_post")} + `, + })} +

+`; diff --git a/demo/src/configs/sections/index.ts b/demo/src/configs/sections/index.ts index 39bc7419b80a..993feece9701 100644 --- a/demo/src/configs/sections/index.ts +++ b/demo/src/configs/sections/index.ts @@ -1,4 +1,5 @@ import { DemoConfig } from "../types"; +import { demoLovelaceDescription } from "./description"; import { demoEntitiesSections } from "./entities"; import { demoLovelaceSections } from "./lovelace"; @@ -6,6 +7,7 @@ export const demoSections: DemoConfig = { authorName: "Home Assistant", authorUrl: "https://github.com/home-assistant/frontend/", name: "Home Demo", + description: demoLovelaceDescription, lovelace: demoLovelaceSections, entities: demoEntitiesSections, theme: () => ({}), diff --git a/demo/src/configs/types.ts b/demo/src/configs/types.ts index abd677852788..ee2959ab460a 100644 --- a/demo/src/configs/types.ts +++ b/demo/src/configs/types.ts @@ -1,3 +1,4 @@ +import { TemplateResult } from "lit"; import { LocalizeFunc } from "../../../src/common/translations/localize"; import { LovelaceConfig } from "../../../src/data/lovelace/config/types"; import { Entity } from "../../../src/fake_data/entity"; @@ -7,6 +8,9 @@ export interface DemoConfig { name: string; authorName: string; authorUrl: string; + description?: + | string + | ((localize: LocalizeFunc) => string | TemplateResult<1>); lovelace: (localize: LocalizeFunc) => LovelaceConfig; entities: (localize: LocalizeFunc) => Entity[]; theme: () => Record | null; diff --git a/demo/src/custom-cards/ha-demo-card.ts b/demo/src/custom-cards/ha-demo-card.ts index ca969d85896d..3bc9837a1a7c 100644 --- a/demo/src/custom-cards/ha-demo-card.ts +++ b/demo/src/custom-cards/ha-demo-card.ts @@ -39,32 +39,51 @@ export class HADemoCard extends LitElement implements LovelaceCard {
${this._switching - ? html`` + ? html` + + ` : until( selectedDemoConfig.then( (conf) => html` ${conf.name} - - ${this.hass.localize( - "ui.panel.page-demo.cards.demo.demo_by", - { name: conf.authorName } - )} - + ${this.hass.localize( + "ui.panel.page-demo.cards.demo.demo_by", + { + name: html` + + ${conf.authorName} + + `, + } + )} ` ), "" )}
+ ${this.hass.localize("ui.panel.page-demo.cards.demo.next_demo")}
-