Fix flow form padding end (#25328)

* Fix flow form padding end

* Use more end padding if docs are present
This commit is contained in:
Wendelin 2025-05-06 13:52:00 +02:00 committed by GitHub
parent 852278e8aa
commit 00d708fbd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 61 additions and 23 deletions

View File

@ -1,4 +1,3 @@
import "@material/mwc-button";
import { mdiClose, mdiHelpCircle } from "@mdi/js";
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import type { CSSResultGroup, PropertyValues } from "lit";
@ -177,6 +176,17 @@ class DataEntryFlowDialog extends LitElement {
return nothing;
}
const showDocumentationLink =
([
"form",
"menu",
"external",
"progress",
"data_entry_flow_progressed",
].includes(this._step?.type as any) &&
this._params.manifest?.is_built_in) ||
!!this._params.manifest?.documentation;
return html`
<ha-dialog
open
@ -191,7 +201,7 @@ class DataEntryFlowDialog extends LitElement {
<step-flow-loading
.flowConfig=${this._params.flowConfig}
.hass=${this.hass}
.loadingReason=${this._loading}
.loadingReason=${this._loading!}
.handler=${this._handler}
.step=${this._step}
></step-flow-loading>
@ -199,26 +209,18 @@ class DataEntryFlowDialog extends LitElement {
: this._step === undefined
? // When we are going to next step, we render 1 round of empty
// to reset the element.
""
nothing
: html`
<div class="dialog-actions">
${([
"form",
"menu",
"external",
"progress",
"data_entry_flow_progressed",
].includes(this._step?.type as any) &&
this._params.manifest?.is_built_in) ||
this._params.manifest?.documentation
${showDocumentationLink
? html`
<a
href=${this._params.manifest.is_built_in
href=${this._params.manifest!.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this._params.manifest.domain}`
`/integrations/${this._params.manifest!.domain}`
)
: this._params?.manifest?.documentation}
: this._params.manifest!.documentation}
target="_blank"
rel="noreferrer noopener"
>
@ -229,7 +231,7 @@ class DataEntryFlowDialog extends LitElement {
</ha-icon-button
></a>
`
: ""}
: nothing}
<ha-icon-button
.label=${this.hass.localize("ui.common.close")}
.path=${mdiClose}
@ -242,6 +244,7 @@ class DataEntryFlowDialog extends LitElement {
.flowConfig=${this._params.flowConfig}
.step=${this._step}
.hass=${this.hass}
.increasePaddingEnd=${showDocumentationLink}
></step-flow-form>
`
: this._step.type === "external"
@ -250,6 +253,7 @@ class DataEntryFlowDialog extends LitElement {
.flowConfig=${this._params.flowConfig}
.step=${this._step}
.hass=${this.hass}
.increasePaddingEnd=${showDocumentationLink}
></step-flow-external>
`
: this._step.type === "abort"
@ -261,6 +265,7 @@ class DataEntryFlowDialog extends LitElement {
.handler=${this._step.handler}
.domain=${this._params.domain ??
this._step.handler}
.increasePaddingEnd=${showDocumentationLink}
></step-flow-abort>
`
: this._step.type === "progress"
@ -270,6 +275,7 @@ class DataEntryFlowDialog extends LitElement {
.step=${this._step}
.hass=${this.hass}
.progress=${this._progress}
.increasePaddingEnd=${showDocumentationLink}
></step-flow-progress>
`
: this._step.type === "menu"
@ -278,6 +284,7 @@ class DataEntryFlowDialog extends LitElement {
.flowConfig=${this._params.flowConfig}
.step=${this._step}
.hass=${this.hass}
.increasePaddingEnd=${showDocumentationLink}
></step-flow-menu>
`
: html`
@ -286,7 +293,8 @@ class DataEntryFlowDialog extends LitElement {
.step=${this._step}
.hass=${this.hass}
.navigateToResult=${this._params
.navigateToResult}
.navigateToResult ?? false}
.increasePaddingEnd=${showDocumentationLink}
></step-flow-create-entry>
`}
`}

View File

@ -22,6 +22,9 @@ class StepFlowAbort extends LitElement {
@property({ attribute: false }) public handler!: string;
@property({ type: Boolean, attribute: "increase-padding-end" })
public increasePaddingEnd = false;
protected firstUpdated(changed: PropertyValues) {
super.firstUpdated(changed);
if (this.step.reason === "missing_credentials") {
@ -34,7 +37,7 @@ class StepFlowAbort extends LitElement {
return nothing;
}
return html`
<h2>
<h2 class=${this.increasePaddingEnd ? "end-space" : ""}>
${this.params.flowConfig.renderAbortHeader
? this.params.flowConfig.renderAbortHeader(this.hass, this.step)
: this.hass.localize(`component.${this.domain}.title`)}

View File

@ -36,6 +36,9 @@ class StepFlowCreateEntry extends LitElement {
@property({ attribute: false }) public step!: DataEntryFlowStepCreateEntry;
@property({ type: Boolean, attribute: "increase-padding-end" })
public increasePaddingEnd = false;
public navigateToResult = false;
@state() private _deviceUpdate: Record<
@ -113,7 +116,7 @@ class StepFlowCreateEntry extends LitElement {
this.step.result?.entry_id
);
return html`
<h2>
<h2 class=${this.increasePaddingEnd ? "end-space" : ""}>
${devices.length
? localize("ui.panel.config.integrations.config_flow.assign_area", {
number: devices.length,

View File

@ -15,11 +15,16 @@ class StepFlowExternal extends LitElement {
@property({ attribute: false }) public step!: DataEntryFlowStepExternal;
@property({ type: Boolean, attribute: "increase-padding-end" })
public increasePaddingEnd = false;
protected render(): TemplateResult {
const localize = this.hass.localize;
return html`
<h2>${this.flowConfig.renderExternalStepHeader(this.hass, this.step)}</h2>
<h2 class=${this.increasePaddingEnd ? "end-space" : ""}>
${this.flowConfig.renderExternalStepHeader(this.hass, this.step)}
</h2>
<div class="content">
${this.flowConfig.renderExternalStepDescription(this.hass, this.step)}
<div class="open-button">
@ -51,6 +56,9 @@ class StepFlowExternal extends LitElement {
.open-button a {
text-decoration: none;
}
h2.end-space {
padding-inline-end: 72px;
}
`,
];
}

View File

@ -27,6 +27,9 @@ class StepFlowForm extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ type: Boolean, attribute: "increase-padding-end" })
public increasePaddingEnd = false;
@state() private _loading = false;
@state() private _stepData?: Record<string, any>;
@ -43,7 +46,9 @@ class StepFlowForm extends LitElement {
const stepData = this._stepDataProcessed;
return html`
<h2>${this.flowConfig.renderShowFormStepHeader(this.hass, this.step)}</h2>
<h2 class=${this.increasePaddingEnd ? "end-space" : ""}>
${this.flowConfig.renderShowFormStepHeader(this.hass, this.step)}
</h2>
<div class="content" @click=${this._clickHandler}>
${this.flowConfig.renderShowFormStepDescription(this.hass, this.step)}
${this._errorMsg

View File

@ -17,6 +17,9 @@ class StepFlowMenu extends LitElement {
@property({ attribute: false }) public step!: DataEntryFlowStepMenu;
@property({ type: Boolean, attribute: "increase-padding-end" })
public increasePaddingEnd = false;
protected render(): TemplateResult {
let options: string[];
let translations: Record<string, string>;
@ -42,7 +45,9 @@ class StepFlowMenu extends LitElement {
);
return html`
<h2>${this.flowConfig.renderMenuHeader(this.hass, this.step)}</h2>
<h2 class=${this.increasePaddingEnd ? "end-space" : ""}>
${this.flowConfig.renderMenuHeader(this.hass, this.step)}
</h2>
${description ? html`<div class="content">${description}</div>` : ""}
<div class="options">
${options.map(

View File

@ -24,9 +24,12 @@ class StepFlowProgress extends LitElement {
@property({ type: Number })
public progress?: number;
@property({ type: Boolean, attribute: "increase-padding-end" })
public increasePaddingEnd = false;
protected render(): TemplateResult {
return html`
<h2>
<h2 class=${this.increasePaddingEnd ? "end-space" : ""}>
${this.flowConfig.renderShowFormProgressHeader(this.hass, this.step)}
</h2>
<div class="content">

View File

@ -22,6 +22,9 @@ export const configFlowContentStyles = css`
text-transform: var(--mdc-typography-headline6-text-transform, inherit);
box-sizing: border-box;
}
h2.end-space {
padding-inline-end: 72px;
}
.content,
.preview {