diff --git a/demo/src/configs/sections/description.ts b/demo/src/configs/sections/description.ts new file mode 100644 index 0000000000..b5762739ac --- /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 39bc7419b8..993feece97 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 abd6778527..ee2959ab46 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 ca969d8589..3bc9837a1a 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")}
-
- ${this.hass.localize("ui.panel.page-demo.cards.demo.introduction")} +
+

+ ${this.hass.localize("ui.panel.page-demo.cards.demo.introduction")} +

+ ${until( + selectedDemoConfig.then((conf) => { + if (typeof conf.description === "function") { + return conf.description(this.hass.localize); + } + if (conf.description) { + return html`

${conf.description}

`; + } + return nothing; + }), + nothing + )}