mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Support descriptions in flow menu steps (#12108)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
f493280f0a
commit
df96199433
@ -189,6 +189,18 @@ export const showConfigFlowDialog = (
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderMenuDescription(hass, step) {
|
||||||
|
const description = hass.localize(
|
||||||
|
`component.${step.handler}.config.step.${step.step_id}.description`,
|
||||||
|
step.description_placeholders
|
||||||
|
);
|
||||||
|
return description
|
||||||
|
? html`
|
||||||
|
<ha-markdown allowsvg breaks .content=${description}></ha-markdown>
|
||||||
|
`
|
||||||
|
: "";
|
||||||
|
},
|
||||||
|
|
||||||
renderMenuOption(hass, step, option) {
|
renderMenuOption(hass, step, option) {
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`component.${step.handler}.config.step.${step.step_id}.menu_options.${option}`,
|
`component.${step.handler}.config.step.${step.step_id}.menu_options.${option}`,
|
||||||
|
@ -83,6 +83,11 @@ export interface FlowConfig {
|
|||||||
|
|
||||||
renderMenuHeader(hass: HomeAssistant, step: DataEntryFlowStepMenu): string;
|
renderMenuHeader(hass: HomeAssistant, step: DataEntryFlowStepMenu): string;
|
||||||
|
|
||||||
|
renderMenuDescription(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
step: DataEntryFlowStepMenu
|
||||||
|
): TemplateResult | "";
|
||||||
|
|
||||||
renderMenuOption(
|
renderMenuOption(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
step: DataEntryFlowStepMenu,
|
step: DataEntryFlowStepMenu,
|
||||||
|
@ -142,6 +142,22 @@ export const showOptionsFlowDialog = (
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderMenuDescription(hass, step) {
|
||||||
|
const description = hass.localize(
|
||||||
|
`component.${step.handler}.option.step.${step.step_id}.description`,
|
||||||
|
step.description_placeholders
|
||||||
|
);
|
||||||
|
return description
|
||||||
|
? html`
|
||||||
|
<ha-markdown
|
||||||
|
allowsvg
|
||||||
|
breaks
|
||||||
|
.content=${description}
|
||||||
|
></ha-markdown>
|
||||||
|
`
|
||||||
|
: "";
|
||||||
|
},
|
||||||
|
|
||||||
renderMenuOption(hass, step, option) {
|
renderMenuOption(hass, step, option) {
|
||||||
return hass.localize(
|
return hass.localize(
|
||||||
`component.${step.handler}.options.step.${step.step_id}.menu_options.${option}`,
|
`component.${step.handler}.options.step.${step.step_id}.menu_options.${option}`,
|
||||||
|
@ -35,8 +35,14 @@ class StepFlowMenu extends LitElement {
|
|||||||
translations = this.step.menu_options;
|
translations = this.step.menu_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const description = this.flowConfig.renderMenuDescription(
|
||||||
|
this.hass,
|
||||||
|
this.step
|
||||||
|
);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<h2>${this.flowConfig.renderMenuHeader(this.hass, this.step)}</h2>
|
<h2>${this.flowConfig.renderMenuHeader(this.hass, this.step)}</h2>
|
||||||
|
${description ? html`<div class="content">${description}</div>` : ""}
|
||||||
<div class="options">
|
<div class="options">
|
||||||
${options.map(
|
${options.map(
|
||||||
(option) => html`
|
(option) => html`
|
||||||
@ -69,6 +75,16 @@ class StepFlowMenu extends LitElement {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
.content {
|
||||||
|
padding-bottom: 16px;
|
||||||
|
border-bottom: 1px solid var(--divider-color);
|
||||||
|
}
|
||||||
|
.content + .options {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
mwc-list-item {
|
||||||
|
--mdc-list-side-padding: 24px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user