diff --git a/src/panels/lovelace/editor/badge-editor/hui-badge-picker.ts b/src/panels/lovelace/editor/badge-editor/hui-badge-picker.ts index 97a5887101..b11118d6c1 100644 --- a/src/panels/lovelace/editor/badge-editor/hui-badge-picker.ts +++ b/src/panels/lovelace/editor/badge-editor/hui-badge-picker.ts @@ -12,6 +12,7 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import { stringCompare } from "../../../../common/string/compare"; import "../../../../components/ha-spinner"; import "../../../../components/search-input"; +import { haStyleScrollbar } from "../../../../resources/styles"; import { isUnavailableState } from "../../../../data/entity/entity"; import type { LovelaceBadgeConfig } from "../../../../data/lovelace/config/badge"; import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; @@ -139,6 +140,7 @@ export class HuiBadgePicker extends LitElement { >
- + @@ -104,7 +114,6 @@ export class HuiCreateDialogBadge slot="nav" .active=${this._currTab === "badge"} panel="badge" - dialogInitialFocus > ${this.hass!.localize( "ui.panel.lovelace.editor.badge_picker.by_badge" @@ -124,6 +133,7 @@ export class HuiCreateDialogBadge this._currTab === "badge" ? html` - + + ${this.hass!.localize("ui.common.cancel")} ${this._selectedEntities.length ? html` - + ${this.hass!.localize("ui.common.continue")} ` : ""} -
- + + `; } @@ -164,36 +178,19 @@ export class HuiCreateDialogBadge return [ haStyleDialog, css` - @media all and (max-width: 450px), all and (max-height: 500px) { - /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - --mdc-dialog-max-height: 100%; - height: 100%; - } - } - - @media all and (min-width: 850px) { - ha-dialog { - --mdc-dialog-min-width: 845px; - } - } - - ha-dialog { - --mdc-dialog-max-width: 845px; - --dialog-content-padding: 2px 24px 20px 24px; + ha-wa-dialog { + --dialog-content-padding: 0; --dialog-z-index: 6; } - ha-dialog.table { + ha-wa-dialog.table { --dialog-content-padding: 0; } - @media (min-width: 1200px) { - ha-dialog { - --mdc-dialog-max-width: calc(100vw - 32px); - --mdc-dialog-min-width: 1000px; - } + ha-wa-dialog::part(body) { + overflow: hidden; } + ha-tab-group-tab { flex: 1; } @@ -203,14 +200,24 @@ export class HuiCreateDialogBadge } hui-badge-picker { --badge-picker-search-shape: 0; - --badge-picker-search-margin: -2px -24px 0; + --badge-picker-search-margin: 0; + display: flex; + flex-direction: column; + min-height: 0; } + + hui-badge-picker, + hui-entity-picker-table { + height: calc(100vh - 198px); + } + hui-entity-picker-table { display: block; - height: calc(100vh - 198px); --mdc-shape-small: 0; } + @media all and (max-width: 450px), all and (max-height: 500px) { + hui-badge-picker, hui-entity-picker-table { height: calc(100vh - 158px); } diff --git a/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts b/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts index 75338c5516..d108f310d7 100644 --- a/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts +++ b/src/panels/lovelace/editor/badge-editor/hui-dialog-edit-badge.ts @@ -6,8 +6,8 @@ import { customElement, property, query, state } from "lit/decorators"; import type { HASSDomEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event"; import { computeRTLDirection } from "../../../../common/util/compute_rtl"; -import "../../../../components/ha-dialog"; -import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-icon-button"; import "../../../../components/ha-spinner"; import "../../../../components/ha-button"; @@ -61,6 +61,8 @@ export class HuiDialogEditBadge @state() private _params?: EditBadgeDialogParams; + @state() private _open = false; + @state() private _badgeConfig?: LovelaceBadgeConfig; @state() private _containerConfig!: LovelaceViewConfig; @@ -86,6 +88,7 @@ export class HuiDialogEditBadge this._params = params; this._GUImode = true; this._guiModeAvailable = true; + this._open = true; const containerConfig = findLovelaceContainer( params.lovelaceConfig, @@ -113,20 +116,25 @@ export class HuiDialogEditBadge } public closeDialog(): boolean { - this._isEscapeEnabled = true; - window.removeEventListener("dialog-closed", this._enableEscapeKeyClose); - window.removeEventListener("hass-more-info", this._disableEscapeKeyClose); if (this._dirty) { this._confirmCancel(); return false; } + this._open = false; + return true; + } + + private _dialogClosed(): void { + this._open = false; + this._isEscapeEnabled = true; + window.removeEventListener("dialog-closed", this._enableEscapeKeyClose); + window.removeEventListener("hass-more-info", this._disableEscapeKeyClose); this._params = undefined; this._badgeConfig = undefined; this._error = undefined; this._documentationURL = undefined; this._dirty = false; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected updated(changedProps: PropertyValues): void { @@ -197,48 +205,46 @@ export class HuiDialogEditBadge } return html` - - - - ${heading} - ${this._documentationURL !== undefined - ? html` - - - - ` - : nothing} - + + ${heading} + ${this._documentationURL !== undefined + ? html` + + + + ` + : nothing}
@@ -258,44 +264,45 @@ export class HuiDialogEditBadge : ``}
- ${this._badgeConfig !== undefined - ? html` - - ${this.hass!.localize( - !this._badgeEditorEl || this._GUImode - ? "ui.panel.lovelace.editor.edit_badge.show_code_editor" - : "ui.panel.lovelace.editor.edit_badge.show_visual_editor" - )} - - ` - : nothing} - - ${this.hass!.localize("ui.common.cancel")} - - ${this._badgeConfig !== undefined && this._dirty - ? html` - - ${this.hass!.localize("ui.common.save")} - - ` - : nothing} -
+ + ${this._badgeConfig !== undefined + ? html` + + ${this.hass!.localize( + !this._badgeEditorEl || this._GUImode + ? "ui.panel.lovelace.editor.edit_badge.show_code_editor" + : "ui.panel.lovelace.editor.edit_badge.show_visual_editor" + )} + + ` + : nothing} + + ${this.hass!.localize("ui.common.cancel")} + + ${this._badgeConfig !== undefined && this._dirty + ? html` + + ${this.hass!.localize("ui.common.save")} + + ` + : nothing} + + `; } @@ -407,26 +414,18 @@ export class HuiDialogEditBadge --code-mirror-max-height: calc(100vh - 176px); } - ha-dialog { - --mdc-dialog-max-width: 100px; + ha-wa-dialog { --dialog-z-index: 6; - --mdc-dialog-max-width: 90vw; - --dialog-content-padding: 24px 12px; + --dialog-content-padding: var(--ha-space-2); } .content { - width: calc(90vw - 48px); - max-width: 1000px; + width: 100%; + max-width: 100%; } @media all and (max-width: 450px), all and (max-height: 500px) { /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - height: 100%; - --mdc-dialog-max-height: 100%; - --dialog-surface-top: 0px; - --mdc-dialog-max-width: 100vw; - } .content { width: 100%; max-width: 100%; @@ -479,6 +478,8 @@ export class HuiDialogEditBadge background: var(--primary-background-color); padding: 10px; border-radius: var(--ha-border-radius-sm); + position: sticky; + top: 0; display: flex; flex-direction: column; justify-content: center; @@ -495,12 +496,7 @@ export class HuiDialogEditBadge margin-inline-end: auto; margin-inline-start: initial; } - .header { - display: flex; - align-items: center; - justify-content: space-between; - } - ha-dialog-header a { + ha-wa-dialog a[slot="headerActionItems"] { color: inherit; text-decoration: none; } diff --git a/src/panels/lovelace/editor/badge-editor/hui-dialog-suggest-badge.ts b/src/panels/lovelace/editor/badge-editor/hui-dialog-suggest-badge.ts index 163e99b03b..5318474ba0 100644 --- a/src/panels/lovelace/editor/badge-editor/hui-dialog-suggest-badge.ts +++ b/src/panels/lovelace/editor/badge-editor/hui-dialog-suggest-badge.ts @@ -5,6 +5,8 @@ import { customElement, property, query, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-yaml-editor"; import "../../../../components/ha-button"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; import type { LovelaceBadgeConfig } from "../../../../data/lovelace/config/badge"; @@ -24,6 +26,8 @@ export class HuiDialogSuggestBadge extends LitElement { @state() private _params?: SuggestBadgeDialogParams; + @state() private _open = false; + @state() private _badgeConfig?: LovelaceBadgeConfig[]; @state() private _saving = false; @@ -33,6 +37,7 @@ export class HuiDialogSuggestBadge extends LitElement { public showDialog(params: SuggestBadgeDialogParams): void { this._params = params; this._badgeConfig = params.badgeConfig; + this._open = true; if (!Object.isFrozen(this._badgeConfig)) { this._badgeConfig = deepFreeze(this._badgeConfig); } @@ -42,6 +47,11 @@ export class HuiDialogSuggestBadge extends LitElement { } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { + this._open = false; this._params = undefined; this._badgeConfig = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); @@ -71,13 +81,13 @@ export class HuiDialogSuggestBadge extends LitElement { return nothing; } return html` -
${this._renderPreview()} @@ -92,30 +102,32 @@ export class HuiDialogSuggestBadge extends LitElement { ` : nothing}
- - ${this._params.yaml - ? this.hass!.localize("ui.common.close") - : this.hass!.localize("ui.common.cancel")} - - ${!this._params.yaml - ? html` - - ${this.hass!.localize( - "ui.panel.lovelace.editor.suggest_badge.add" - )} - - ` - : nothing} -
+ + + ${this._params.yaml + ? this.hass!.localize("ui.common.close") + : this.hass!.localize("ui.common.cancel")} + + ${!this._params.yaml + ? html` + + ${this.hass!.localize( + "ui.panel.lovelace.editor.suggest_badge.add" + )} + + ` + : nothing} + + `; } @@ -123,20 +135,7 @@ export class HuiDialogSuggestBadge extends LitElement { return [ haStyleDialog, css` - @media all and (max-width: 450px), all and (max-height: 500px) { - /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - max-height: 100%; - height: 100%; - } - } - @media all and (min-width: 850px) { - ha-dialog { - width: 845px; - } - } - ha-dialog { - max-width: 845px; + ha-wa-dialog { --dialog-z-index: 6; } .hidden { diff --git a/src/panels/lovelace/editor/card-editor/hui-card-picker.ts b/src/panels/lovelace/editor/card-editor/hui-card-picker.ts index ffcacfdc0c..2ac7a15311 100644 --- a/src/panels/lovelace/editor/card-editor/hui-card-picker.ts +++ b/src/panels/lovelace/editor/card-editor/hui-card-picker.ts @@ -11,6 +11,7 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import { stringCompare } from "../../../../common/string/compare"; import "../../../../components/ha-spinner"; import "../../../../components/search-input"; +import { haStyleScrollbar } from "../../../../resources/styles"; import { isUnavailableState } from "../../../../data/entity/entity"; import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; @@ -142,7 +143,7 @@ export class HuiCardPicker extends LitElement { "ui.panel.lovelace.editor.edit_card.search_cards" )} > -
+
${this._filter ? html`
${this._filterCards(this._cards, this._filter).map( @@ -460,40 +461,56 @@ export class HuiCardPicker extends LitElement { static get styles(): CSSResultGroup { return [ + haStyleScrollbar, css` + :host { + display: flex; + flex-direction: column; + min-height: 0; + } + + #content { + flex: 1; + min-height: 0; + overflow: auto; + } + search-input { display: block; + width: 100%; --mdc-shape-small: var(--card-picker-search-shape); margin: var(--card-picker-search-margin); position: sticky; top: 0; z-index: 10; background-color: var( - --ha-dialog-surface-background, - var(--mdc-theme-surface, #fff) + --ha-dialog-surface-background, + var(--mdc-theme-surface, #fff) ); } .cards-container-header { font-size: var(--ha-font-size-l); font-weight: var(--ha-font-weight-medium); - padding: 12px 8px; + padding: var(--ha-space-3) var(--ha-space-2); margin: 0; grid-column: 1 / -1; position: sticky; - top: 56px; + top: 0; z-index: 1; - background: linear-gradient(90deg, var( - --ha-dialog-surface-background, - var(--mdc-theme-surface, #fff) - ) 0%, #ffffff00 80%); + background: linear-gradient( + 90deg, + var(--ha-dialog-surface-background, var(--mdc-theme-surface, #fff)) + 0%, + #ffffff00 80% + ); } .cards-container { display: grid; - grid-gap: 8px 8px; + gap: var(--ha-space-2); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); - margin-top: 20px; + padding: var(--ha-space-3); } .card { @@ -501,12 +518,16 @@ export class HuiCardPicker extends LitElement { max-width: 500px; display: flex; flex-direction: column; - border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg)); + border-radius: var( + --ha-card-border-radius, + var(--ha-border-radius-lg) + ); background: var(--primary-background-color, #fafafa); cursor: pointer; position: relative; overflow: hidden; - border: var(--ha-card-border-width, 1px) solid var(--ha-card-border-color, var(--divider-color)); + border: var(--ha-card-border-width, 1px) solid + var(--ha-card-border-color, var(--divider-color)); } .card-header { @@ -516,14 +537,14 @@ export class HuiCardPicker extends LitElement { font-weight: var(--ha-font-weight-bold); letter-spacing: -0.012em; line-height: var(--ha-line-height-condensed); - padding: 12px 16px; + padding: var(--ha-space-3) var(--ha-space-4); display: block; text-align: center; } .preview { pointer-events: none; - margin: 20px; + margin: var(--ha-space-5); flex-grow: 1; display: flex; align-items: center; @@ -550,7 +571,10 @@ export class HuiCardPicker extends LitElement { height: 100%; z-index: 1; box-sizing: border-box; - border-radius: var(--ha-card-border-radius, var(--ha-border-radius-lg)); + border-radius: var( + --ha-card-border-radius, + var(--ha-border-radius-lg) + ); } .manual { @@ -560,16 +584,16 @@ export class HuiCardPicker extends LitElement { .icon { position: absolute; - top: 8px; - right: 8px - inset-inline-start: 8px; - inset-inline-end: 8px; + top: var(--ha-space-2); + right: var(--ha-space-2); + inset-inline-start: var(--ha-space-2); + inset-inline-end: var(--ha-space-2); border-radius: var(--ha-border-radius-circle); - --mdc-icon-size: 16px; - line-height: 16px; + --mdc-icon-size: var(--ha-space-4); + line-height: var(--ha-space-4); box-sizing: border-box; color: var(--text-primary-color); - padding: 4px; + padding: var(--ha-space-1); } .icon.custom { background: var(--warning-color); diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts index 3b0bc9760c..dc20ff97db 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts @@ -4,13 +4,13 @@ import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { cache } from "lit/directives/cache"; import { classMap } from "lit/directives/class-map"; -import { ifDefined } from "lit/directives/if-defined"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog"; import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-tab-group"; import "../../../../components/ha-tab-group-tab"; +import "../../../../components/ha-wa-dialog"; import type { LovelaceSectionConfig } from "../../../../data/lovelace/config/section"; import { isStrategySection } from "../../../../data/lovelace/config/section"; import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view"; @@ -51,6 +51,8 @@ export class HuiCreateDialogCard @state() private _params?: CreateCardDialogParams; + @state() private _open = false; + @state() private _containerConfig!: | LovelaceViewConfig | LovelaceSectionConfig; @@ -78,14 +80,20 @@ export class HuiCreateDialogCard } this._containerConfig = containerConfig; + this._open = true; } public closeDialog(): boolean { + this._open = false; + return true; + } + + private _dialogClosed(): void { + this._open = false; this._params = undefined; this._currTab = "card"; this._selectedEntities = []; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected render() { @@ -101,18 +109,19 @@ export class HuiCreateDialogCard : this.hass!.localize("ui.panel.lovelace.editor.edit_card.pick_card"); return html` - - + @@ -123,7 +132,7 @@ export class HuiCreateDialogCard slot="nav" .active=${this._currTab === "card"} panel="card" - dialogInitialFocus=${ifDefined(this._narrow ? "" : undefined)} + ?autofocus=${this._narrow} > ${this.hass!.localize( "ui.panel.lovelace.editor.cardpicker.by_card" @@ -143,7 +152,7 @@ export class HuiCreateDialogCard this._currTab === "card" ? html` - + + ${this.hass!.localize("ui.common.cancel")} ${this._selectedEntities.length ? html` - + ${this.hass!.localize("ui.common.continue")} ` : ""} -
- + + `; } @@ -184,34 +197,19 @@ export class HuiCreateDialogCard return [ haStyleDialog, css` - @media all and (min-width: 850px) { - ha-dialog { - --mdc-dialog-min-width: 845px; - --mdc-dialog-min-height: calc( - 100vh - var(--ha-space-18) - var(--safe-area-inset-y) - ); - --mdc-dialog-max-height: calc( - 100vh - var(--ha-space-18) - var(--safe-area-inset-y) - ); - } - } - - ha-dialog { - --mdc-dialog-max-width: 845px; - --dialog-content-padding: 0 24px 20px 24px; + ha-wa-dialog { + --dialog-content-padding: 0; --dialog-z-index: 6; } - ha-dialog.table { + ha-wa-dialog.table { --dialog-content-padding: 0; } - @media (min-width: 1200px) { - ha-dialog { - --mdc-dialog-max-width: calc(100vw - 32px); - --mdc-dialog-min-width: 1000px; - } + ha-wa-dialog::part(body) { + overflow: hidden; } + ha-tab-group-tab { flex: 1; } @@ -221,14 +219,24 @@ export class HuiCreateDialogCard } hui-card-picker { --card-picker-search-shape: 0; - --card-picker-search-margin: 0 -24px 0; + --card-picker-search-margin: 0; + display: flex; + flex-direction: column; + min-height: 0; } + + hui-card-picker, + hui-entity-picker-table { + height: calc(100vh - 198px); + } + hui-entity-picker-table { display: block; - height: calc(100vh - 198px); --mdc-shape-small: 0; } + @media all and (max-width: 450px), all and (max-height: 500px) { + hui-card-picker, hui-entity-picker-table { height: calc(100vh - 158px); } diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts index 9c2ddc1777..2c53d91144 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts @@ -8,6 +8,8 @@ import { haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; import "../../cards/hui-card"; import "../../../../components/ha-button"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import type { DeleteCardDialogParams } from "./show-delete-card-dialog"; @customElement("hui-dialog-delete-card") @@ -16,17 +18,25 @@ export class HuiDialogDeleteCard extends LitElement { @state() private _params?: DeleteCardDialogParams; + @state() private _open = false; + @state() private _cardConfig?: LovelaceCardConfig; public async showDialog(params: DeleteCardDialogParams): Promise { this._params = params; this._cardConfig = params.cardConfig; + this._open = true; if (!Object.isFrozen(this._cardConfig)) { this._cardConfig = deepFreeze(this._cardConfig); } } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { + this._open = false; this._params = undefined; this._cardConfig = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); @@ -38,10 +48,13 @@ export class HuiDialogDeleteCard extends LitElement { } return html` -
${this._cardConfig @@ -56,18 +69,24 @@ export class HuiDialogDeleteCard extends LitElement { ` : ""}
- - ${this.hass!.localize("ui.common.cancel")} - - - ${this.hass!.localize("ui.common.delete")} - -
+ + + ${this.hass!.localize("ui.common.cancel")} + + + ${this.hass!.localize("ui.common.delete")} + + + `; } diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts index 18cab231db..6edf402b26 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts @@ -9,8 +9,8 @@ import { fireEvent } from "../../../../common/dom/fire_event"; import { computeRTLDirection } from "../../../../common/util/compute_rtl"; import "../../../../components/ha-spinner"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog"; -import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-icon-button"; import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; import type { LovelaceSectionConfig } from "../../../../data/lovelace/config/section"; @@ -60,6 +60,8 @@ export class HuiDialogEditCard @state() private _params?: EditCardDialogParams; + @state() private _open = false; + @state() private _cardConfig?: LovelaceCardConfig; @state() private _sectionConfig?: LovelaceSectionConfig; @@ -83,6 +85,7 @@ export class HuiDialogEditCard this._params = params; this._GUImode = true; this._guiModeAvailable = true; + this._open = true; this._sectionConfig = this._params.sectionConfig; @@ -100,13 +103,18 @@ export class HuiDialogEditCard this._confirmCancel(); return false; } + this._open = false; + return true; + } + + private _dialogClosed(): void { + this._open = false; this._params = undefined; this._cardConfig = undefined; this._error = undefined; this._documentationURL = undefined; this._dirty = false; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected updated(changedProps: PropertyValues): void { @@ -157,41 +165,39 @@ export class HuiDialogEditCard } return html` - - - - ${heading} - ${this._documentationURL !== undefined - ? html` - - - - ` - : nothing} - + + ${heading} + ${this._documentationURL !== undefined + ? html` + + + + ` + : nothing}
@@ -226,34 +231,35 @@ export class HuiDialogEditCard : ``}
- ${this._cardConfig !== undefined - ? html` - - ${this.hass!.localize( - !this._cardEditorEl || this._GUImode - ? "ui.panel.lovelace.editor.edit_card.show_code_editor" - : "ui.panel.lovelace.editor.edit_card.show_visual_editor" - )} - - ` - : ""} -
+ + ${this._cardConfig !== undefined + ? html` + + ${this.hass!.localize( + !this._cardEditorEl || this._GUImode + ? "ui.panel.lovelace.editor.edit_card.show_code_editor" + : "ui.panel.lovelace.editor.edit_card.show_visual_editor" + )} + + ` + : ""} ${this.hass!.localize("ui.common.cancel")} ${this._cardConfig !== undefined && this._dirty ? html` ` : ``} -
-
+ + `; } @@ -383,26 +389,18 @@ export class HuiDialogEditCard --code-mirror-max-height: calc(100vh - 176px); } - ha-dialog { - --mdc-dialog-max-width: 100px; + ha-wa-dialog { --dialog-z-index: 6; - --mdc-dialog-max-width: 90vw; - --dialog-content-padding: 24px 12px; + --dialog-content-padding: var(--ha-space-2); } .content { - width: calc(90vw - 48px); - max-width: 1000px; + width: 100%; + max-width: 100%; } @media all and (max-width: 450px), all and (max-height: 500px) { /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - height: 100%; - --mdc-dialog-max-height: 100%; - --dialog-surface-top: 0px; - --mdc-dialog-max-width: 100vw; - } .content { width: 100%; max-width: 100%; @@ -498,20 +496,10 @@ export class HuiDialogEditCard margin-inline-end: auto; margin-inline-start: initial; } - .header { - display: flex; - align-items: center; - justify-content: space-between; - } - ha-dialog-header a { + ha-wa-dialog a[slot="headerActionItems"] { color: inherit; text-decoration: none; } - - [slot="primaryAction"] { - gap: var(--ha-space-2); - display: flex; - } `, ]; } diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-suggest-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-suggest-card.ts index 628546c997..b71c60e68d 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-suggest-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-suggest-card.ts @@ -5,6 +5,8 @@ import { customElement, property, query, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; import "../../../../components/ha-yaml-editor"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-spinner"; import type { HaYamlEditor } from "../../../../components/ha-yaml-editor"; @@ -30,6 +32,8 @@ export class HuiDialogSuggestCard extends LitElement { @state() private _params?: SuggestCardDialogParams; + @state() private _open = false; + @state() private _cardConfig?: LovelaceCardConfig[]; @state() private _sectionConfig?: LovelaceSectionConfig; @@ -42,6 +46,7 @@ export class HuiDialogSuggestCard extends LitElement { this._params = params; this._cardConfig = params.cardConfig; this._sectionConfig = params.sectionConfig; + this._open = true; if (!Object.isFrozen(this._cardConfig)) { this._cardConfig = deepFreeze(this._cardConfig); } @@ -54,6 +59,11 @@ export class HuiDialogSuggestCard extends LitElement { } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { + this._open = false; this._params = undefined; this._cardConfig = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); @@ -107,13 +117,13 @@ export class HuiDialogSuggestCard extends LitElement { return nothing; } return html` -
${this._renderPreview()} @@ -128,44 +138,46 @@ export class HuiDialogSuggestCard extends LitElement { ` : nothing}
- - ${this._params.yaml - ? this.hass!.localize("ui.common.close") - : this.hass!.localize("ui.common.cancel")} - - ${!this._params.yaml - ? html` - ${!(this._sectionConfig && this._viewSupportsSection) - ? html` - - ${this.hass!.localize( - "ui.panel.lovelace.editor.suggest_card.create_own" - )} - - ` - : nothing} - - ${this.hass!.localize( - "ui.panel.lovelace.editor.suggest_card.add" - )} - - ` - : nothing} -
+ + + ${this._params.yaml + ? this.hass!.localize("ui.common.close") + : this.hass!.localize("ui.common.cancel")} + + ${!this._params.yaml + ? html` + ${!(this._sectionConfig && this._viewSupportsSection) + ? html` + + ${this.hass!.localize( + "ui.panel.lovelace.editor.suggest_card.create_own" + )} + + ` + : nothing} + + ${this.hass!.localize( + "ui.panel.lovelace.editor.suggest_card.add" + )} + + ` + : nothing} + + `; } @@ -173,20 +185,7 @@ export class HuiDialogSuggestCard extends LitElement { return [ haStyleDialog, css` - @media all and (max-width: 450px), all and (max-height: 500px) { - /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - max-height: 100%; - height: 100%; - } - } - @media all and (min-width: 850px) { - ha-dialog { - width: 845px; - } - } - ha-dialog { - max-width: 845px; + ha-wa-dialog { --dialog-z-index: 6; } .hidden { diff --git a/src/panels/lovelace/editor/dashboard-strategy-editor/dialogs/dialog-dashboard-strategy-editor.ts b/src/panels/lovelace/editor/dashboard-strategy-editor/dialogs/dialog-dashboard-strategy-editor.ts index 0e6171d389..eba5fafac8 100644 --- a/src/panels/lovelace/editor/dashboard-strategy-editor/dialogs/dialog-dashboard-strategy-editor.ts +++ b/src/panels/lovelace/editor/dashboard-strategy-editor/dialogs/dialog-dashboard-strategy-editor.ts @@ -1,17 +1,13 @@ -import { - mdiAccountHardHat, - mdiClose, - mdiDotsVertical, - mdiPlaylistEdit, -} from "@mdi/js"; +import { mdiAccountHardHat, mdiDotsVertical, mdiPlaylistEdit } from "@mdi/js"; import type { CSSResultGroup } from "lit"; import { LitElement, css, html, nothing } from "lit"; import { customElement, property, query, state } from "lit/decorators"; +import { ifDefined } from "lit/directives/if-defined"; import type { HASSDomEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event"; import "../../../../../components/ha-button"; -import "../../../../../components/ha-dialog"; -import "../../../../../components/ha-dialog-header"; +import "../../../../../components/ha-dialog-footer"; +import "../../../../../components/ha-wa-dialog"; import "../../../../../components/ha-dropdown"; import "../../../../../components/ha-dropdown-item"; import "../../../../../components/ha-icon-button"; @@ -42,6 +38,8 @@ class DialogDashboardStrategyEditor extends LitElement { @state() private _guiModeAvailable? = true; + @state() private _open = false; + @query("hui-dashboard-strategy-element-editor") private _strategyEditorEl?: HuiDashboardStrategyElementEditor; @@ -50,10 +48,15 @@ class DialogDashboardStrategyEditor extends LitElement { ): Promise { this._params = params; this._strategyConfig = params.config.strategy; + this._open = true; await this.updateComplete; } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { this._params = undefined; this._strategyConfig = undefined; this._guiModeAvailable = true; @@ -73,10 +76,6 @@ class DialogDashboardStrategyEditor extends LitElement { this._guiModeAvailable = ev.detail.guiModeAvailable; } - private _opened() { - this._strategyEditorEl?.focusYamlEditor(); - } - private async _save(): Promise { await this._params!.saveConfig({ ...this._params!.config, @@ -136,52 +135,40 @@ class DialogDashboardStrategyEditor extends LitElement { ); return html` - - + - ${title} - ${this._params.title - ? html`${this._params.title}` - : nothing} - - - - ${this.hass!.localize( - `ui.panel.lovelace.editor.edit_view.edit_${!this._GUImode ? "ui" : "yaml"}` - )} - - - - ${this.hass.localize( - "ui.panel.lovelace.editor.strategy-editor.take_control" - )} - - - - + ${this.hass!.localize( + `ui.panel.lovelace.editor.edit_view.edit_${!this._GUImode ? "ui" : "yaml"}` + )} + + + + ${this.hass.localize( + "ui.panel.lovelace.editor.strategy-editor.take_control" + )} + + +
- - ${this.hass!.localize("ui.common.delete")} - - - ${this.hass!.localize("ui.common.cancel")} - - - ${this.hass!.localize("ui.common.save")} - -
+ + + ${this.hass!.localize("ui.common.delete")} + + + ${this.hass!.localize("ui.common.cancel")} + + + ${this.hass!.localize("ui.common.save")} + + + `; } @@ -220,34 +209,8 @@ class DialogDashboardStrategyEditor extends LitElement { haStyleDialog, haStyleDialogFixedTop, css` - ha-dialog { + ha-wa-dialog { --dialog-content-padding: 0 24px; - --mdc-dialog-min-width: min( - 640px, - calc(100vw - var(--safe-area-inset-x)) - ); - --mdc-dialog-max-width: min( - 640px, - calc(100vw - var(--safe-area-inset-x)) - ); - --mdc-dialog-max-height: calc( - 100vh - var(--ha-space-20) - var(--safe-area-inset-y) - ); - } - - @media all and (max-width: 450px), all and (max-height: 500px) { - /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - height: 100%; - --dialog-surface-top: 0px; - --mdc-dialog-min-width: 100vw; - --mdc-dialog-max-width: 100vw; - --mdc-dialog-min-height: 100vh; - --mdc-dialog-min-height: 100svh; - --mdc-dialog-max-height: 100vh; - --mdc-dialog-max-height: 100svh; - --dialog-content-padding: 8px; - } } `, ]; diff --git a/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts b/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts index 95de539e64..88acc6b90c 100644 --- a/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts +++ b/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts @@ -3,7 +3,8 @@ import { css, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; -import { createCloseHeading } from "../../../../components/ha-dialog"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import type { HassDialog } from "../../../../dialogs/make-dialog-manager"; import { haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; @@ -21,16 +22,23 @@ export class HuiCreateDialogHeaderFooter @state() private _params?: CreateHeaderFooterDialogParams; + @state() private _open = false; + public async showDialog( params: CreateHeaderFooterDialogParams ): Promise { this._params = params; + this._open = true; } public closeDialog(): boolean { + this._open = false; + return true; + } + + private _dialogClosed(): void { this._params = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected render() { @@ -39,22 +47,20 @@ export class HuiCreateDialogHeaderFooter } return html` -
${headerFooterElements.map( @@ -67,7 +73,7 @@ export class HuiCreateDialogHeaderFooter .type=${headerFooter.type} @click=${this._handleHeaderFooterPicked} @keyDown=${this._handleHeaderFooterPicked} - dialogInitialFocus + ?autofocus=${index === 0} >
@@ -79,12 +85,16 @@ export class HuiCreateDialogHeaderFooter ` )}
-
- + + ${this.hass!.localize("ui.common.cancel")} -
- + + `; } @@ -129,22 +139,7 @@ export class HuiCreateDialogHeaderFooter return [ haStyleDialog, css` - @media all and (max-width: 450px), all and (max-height: 500px) { - /* overrule the ha-style-dialog max-height on small screens */ - ha-dialog { - --mdc-dialog-max-height: 100%; - height: 100%; - } - } - - @media all and (min-width: 850px) { - ha-dialog { - --mdc-dialog-min-width: 550px; - } - } - - ha-dialog { - --mdc-dialog-max-width: 550px; + ha-wa-dialog { --dialog-content-padding: 2px 24px 20px 24px; --dialog-z-index: 6; } diff --git a/src/panels/lovelace/editor/hui-dialog-save-config.ts b/src/panels/lovelace/editor/hui-dialog-save-config.ts index ac1721830b..db2ac8b894 100644 --- a/src/panels/lovelace/editor/hui-dialog-save-config.ts +++ b/src/panels/lovelace/editor/hui-dialog-save-config.ts @@ -1,11 +1,11 @@ -import { mdiClose, mdiHelpCircle } from "@mdi/js"; +import { mdiHelpCircle } from "@mdi/js"; import type { CSSResultGroup } from "lit"; import { LitElement, css, html, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../common/dom/fire_event"; import "../../../components/ha-button"; -import "../../../components/ha-dialog"; -import "../../../components/ha-dialog-header"; +import "../../../components/ha-dialog-footer"; +import "../../../components/ha-wa-dialog"; import "../../../components/ha-formfield"; import "../../../components/ha-icon-button"; import "../../../components/ha-switch"; @@ -30,6 +30,8 @@ export class HuiSaveConfig extends LitElement implements HassDialog { @state() private _saving: boolean; + @state() private _open = false; + public constructor() { super(); this._saving = false; @@ -38,12 +40,17 @@ export class HuiSaveConfig extends LitElement implements HassDialog { public showDialog(params: SaveDialogParams): void { this._params = params; this._emptyConfig = false; + this._open = true; } public closeDialog(): boolean { + this._open = false; + return true; + } + + private _dialogClosed(): void { this._params = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected render() { @@ -55,34 +62,25 @@ export class HuiSaveConfig extends LitElement implements HassDialog { "ui.panel.lovelace.editor.save_config.header" ); return html` - - + - ${heading} - - - - +

${this.hass!.localize("ui.panel.lovelace.editor.save_config.para")} @@ -103,7 +101,7 @@ export class HuiSaveConfig extends LitElement implements HassDialog { ` @@ -126,47 +124,44 @@ export class HuiSaveConfig extends LitElement implements HassDialog { `}

${this._params.mode === "storage" ? html` - - ${this.hass!.localize("ui.common.cancel")} - - - ${this.hass!.localize( - "ui.panel.lovelace.editor.save_config.save" - )} - + + + ${this.hass!.localize("ui.common.cancel")} + + + ${this.hass!.localize( + "ui.panel.lovelace.editor.save_config.save" + )} + + ` : html` - - ${this.hass!.localize( - "ui.panel.lovelace.editor.save_config.close" - )} + + + ${this.hass!.localize( + "ui.panel.lovelace.editor.save_config.close" + )} + + `} -
+ `; } - private _close(ev?: Event) { - if (ev) { - ev.stopPropagation(); - } - this.closeDialog(); - } - private _emptyConfigChanged(ev) { this._emptyConfig = ev.target.checked; } @@ -196,11 +191,11 @@ export class HuiSaveConfig extends LitElement implements HassDialog { return [ haStyleDialog, css` - ha-dialog { + ha-wa-dialog { --dialog-content-padding: 0 24px 24px 24px; } - ha-dialog-header a { + ha-wa-dialog [slot="headerActionItems"] { color: inherit; text-decoration: none; } diff --git a/src/panels/lovelace/editor/section-editor/hui-dialog-edit-section.ts b/src/panels/lovelace/editor/section-editor/hui-dialog-edit-section.ts index c4c53db097..430f6b6d13 100644 --- a/src/panels/lovelace/editor/section-editor/hui-dialog-edit-section.ts +++ b/src/panels/lovelace/editor/section-editor/hui-dialog-edit-section.ts @@ -11,8 +11,9 @@ import { classMap } from "lit/directives/class-map"; import { fireEvent } from "../../../../common/dom/fire_event"; import { stopPropagation } from "../../../../common/dom/stop_propagation"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog"; import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-dropdown"; import "../../../../components/ha-dropdown-item"; import "../../../../components/ha-icon-button"; @@ -67,6 +68,8 @@ export class HuiDialogEditSection @state() private _currTab: (typeof TABS)[number] = TABS[0]; + @state() private _open = false; + @query("ha-yaml-editor") private _editor?: HaYamlEditor; protected updated(changedProperties: PropertyValues) { @@ -80,6 +83,7 @@ export class HuiDialogEditSection public async showDialog(params: EditSectionDialogParams): Promise { this._params = params; + this._open = true; this.lovelace = params.lovelace; @@ -93,12 +97,16 @@ export class HuiDialogEditSection } public closeDialog() { + this._open = false; + return true; + } + + private _dialogClosed(): void { this._params = undefined; this._yamlMode = false; this._config = undefined; this._currTab = TABS[0]; fireEvent(this, "dialog-closed", { dialog: this.localName }); - return true; } protected render() { @@ -116,7 +124,7 @@ export class HuiDialogEditSection content = html` `; @@ -147,20 +155,19 @@ export class HuiDialogEditSection } return html` - - + @@ -213,18 +220,20 @@ export class HuiDialogEditSection : nothing} ${content} - - ${this.hass!.localize("ui.common.cancel")} - + + + ${this.hass!.localize("ui.common.cancel")} + - - ${this.hass!.localize("ui.common.save")} - - + + ${this.hass!.localize("ui.common.save")} + + + `; } @@ -417,7 +426,10 @@ export class HuiDialogEditSection haStyleDialog, haStyleDialogFixedTop, css` - ha-dialog.yaml-mode { + ha-wa-dialog { + --dialog-content-padding: var(--ha-space-6); + } + ha-wa-dialog.yaml-mode { --dialog-content-padding: 0; } ha-tab-group-tab { @@ -427,11 +439,6 @@ export class HuiDialogEditSection width: 100%; justify-content: center; } - @media all and (min-width: 600px) { - ha-dialog { - --mdc-dialog-min-width: 600px; - } - } `, ]; } diff --git a/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts b/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts index f48378cf31..9e0d076cb3 100644 --- a/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts +++ b/src/panels/lovelace/editor/select-view/hui-dialog-select-view.ts @@ -4,11 +4,12 @@ import { customElement, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-alert"; import "../../../../components/ha-button"; -import { createCloseHeading } from "../../../../components/ha-dialog"; import "../../../../components/ha-icon"; +import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-list"; import "../../../../components/ha-radio-list-item"; import "../../../../components/ha-select"; +import "../../../../components/ha-wa-dialog"; import type { LovelaceConfig } from "../../../../data/lovelace/config/types"; import { fetchConfig } from "../../../../data/lovelace/config/types"; import { isStrategyView } from "../../../../data/lovelace/config/view"; @@ -41,16 +42,23 @@ export class HuiDialogSelectView extends LitElement { @state() private _selectedViewIdx = 0; + @state() private _open = false; + public showDialog(params: SelectViewDialogParams): void { this._config = params.lovelaceConfig; this._urlPath = params.urlPath; this._params = params; + this._open = true; if (this._params.allowDashboardChange) { this._getDashboards(); } } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { this._params = undefined; fireEvent(this, "dialog-closed", { dialog: this.localName }); } @@ -63,14 +71,13 @@ export class HuiDialogSelectView extends LitElement { const defaultPanel = getDefaultPanelUrlPath(this.hass); return html` - ${this._params.allowDashboardChange ? html` ({ value: dashboard.url_path, @@ -93,7 +101,6 @@ export class HuiDialogSelectView extends LitElement { ? 1 : a.label.localeCompare(b.label) )} - dialogInitialFocus > ` : nothing} @@ -107,7 +114,7 @@ export class HuiDialogSelectView extends LitElement { >` : this._config.views.length > 1 ? html` - + ${this._config.views.map((view, idx) => { const isStrategy = isStrategyView(view); @@ -121,6 +128,8 @@ export class HuiDialogSelectView extends LitElement { .selected=${this._selectedViewIdx === idx} .disabled=${isStrategy && !this._params?.includeStrategyViews} + ?autofocus=${idx === 0 && + !this._params!.allowDashboardChange} > ${view.title}${isStrategy @@ -135,22 +144,23 @@ export class HuiDialogSelectView extends LitElement { ` : nothing} - - ${this.hass!.localize("ui.common.cancel")} - - - ${this._params.actionLabel || this.hass!.localize("ui.common.move")} - - + + + ${this.hass!.localize("ui.common.cancel")} + + + ${this._params.actionLabel || this.hass!.localize("ui.common.move")} + + + `; } diff --git a/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts b/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts index 2c7c314ed2..639c068e1e 100644 --- a/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts +++ b/src/panels/lovelace/editor/view-editor/hui-dialog-edit-view.ts @@ -14,8 +14,9 @@ import { navigate } from "../../../../common/navigate"; import { deepEqual } from "../../../../common/util/deep-equal"; import "../../../../components/ha-alert"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog"; import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-dropdown"; import "../../../../components/ha-dropdown-item"; import "../../../../components/ha-spinner"; @@ -85,6 +86,8 @@ export class HuiDialogEditView extends LitElement { @state() private _currentType = getViewType(); + @state() private _open = false; + get _type(): string { return getViewType(this._config); } @@ -100,6 +103,7 @@ export class HuiDialogEditView extends LitElement { public showDialog(params: EditViewDialogParams): void { this._params = params; + this._open = true; if (this._params.viewIndex === undefined) { this._config = { @@ -123,6 +127,10 @@ export class HuiDialogEditView extends LitElement { } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { this._params = undefined; this._config = {}; this._yamlMode = false; @@ -153,7 +161,7 @@ export class HuiDialogEditView extends LitElement { content = html` `; @@ -200,20 +208,19 @@ export class HuiDialogEditView extends LitElement { this._config?.sections?.length; return html` - - + @@ -290,37 +297,39 @@ export class HuiDialogEditView extends LitElement { : nothing} ${content} - ${this._params.viewIndex !== undefined - ? html` - - ${this.hass!.localize( - "ui.panel.lovelace.editor.edit_view.delete" - )} - - ` - : nothing} - - ${this._saving - ? html`` + + ${this._params.viewIndex !== undefined + ? html` + + ${this.hass!.localize( + "ui.panel.lovelace.editor.edit_view.delete" + )} + + ` : nothing} - ${this.hass!.localize("ui.common.save")} - + + ${this._saving + ? html`` + : nothing} + ${this.hass!.localize("ui.common.save")} + + `; } @@ -634,7 +643,10 @@ export class HuiDialogEditView extends LitElement { haStyleDialog, haStyleDialogFixedTop, css` - ha-dialog.yaml-mode { + ha-wa-dialog { + --dialog-content-padding: var(--ha-space-6); + } + ha-wa-dialog.yaml-mode { --dialog-content-padding: 0; } h2 { @@ -676,12 +688,6 @@ export class HuiDialogEditView extends LitElement { left: 50%; transform: translate(-50%, -50%); } - - @media all and (min-width: 600px) { - ha-dialog { - --mdc-dialog-min-width: 600px; - } - } `, ]; } diff --git a/src/panels/lovelace/editor/view-header/hui-dialog-edit-view-header.ts b/src/panels/lovelace/editor/view-header/hui-dialog-edit-view-header.ts index 9f0a0013f3..dc7c106769 100644 --- a/src/panels/lovelace/editor/view-header/hui-dialog-edit-view-header.ts +++ b/src/panels/lovelace/editor/view-header/hui-dialog-edit-view-header.ts @@ -1,4 +1,4 @@ -import { mdiClose, mdiDotsVertical, mdiPlaylistEdit } from "@mdi/js"; +import { mdiDotsVertical, mdiPlaylistEdit } from "@mdi/js"; import type { CSSResultGroup, PropertyValues } from "lit"; import { LitElement, css, html, nothing } from "lit"; import { customElement, property, query, state } from "lit/decorators"; @@ -6,8 +6,8 @@ import { classMap } from "lit/directives/class-map"; import { fireEvent } from "../../../../common/dom/fire_event"; import { deepEqual } from "../../../../common/util/deep-equal"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog"; -import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-dropdown"; import "../../../../components/ha-dropdown-item"; import "../../../../components/ha-spinner"; @@ -40,6 +40,8 @@ export class HuiDialogEditViewHeader extends LitElement { @query("ha-yaml-editor") private _editor?: HaYamlEditor; + @state() private _open = false; + protected updated(changedProperties: PropertyValues) { if (this._yamlMode && changedProperties.has("_yamlMode")) { const config = { @@ -54,9 +56,14 @@ export class HuiDialogEditViewHeader extends LitElement { this._dirty = false; this._config = this._params.config; + this._open = true; } public closeDialog(): void { + this._open = false; + } + + private _dialogClosed(): void { this._params = undefined; this._config = undefined; this._yamlMode = false; @@ -76,7 +83,7 @@ export class HuiDialogEditViewHeader extends LitElement { content = html` `; @@ -95,52 +102,45 @@ export class HuiDialogEditViewHeader extends LitElement { ); return html` - - + -

${title}

- - - - ${this.hass!.localize( - `ui.panel.lovelace.editor.edit_view_header.edit_${!this._yamlMode ? "yaml" : "ui"}` - )} - - - -
+ + ${this.hass!.localize( + `ui.panel.lovelace.editor.edit_view_header.edit_${!this._yamlMode ? "yaml" : "ui"}` + )} + + + ${content} - - ${this.hass!.localize("ui.common.save")} -
+ + + ${this.hass!.localize("ui.common.save")} + + `; } @@ -198,20 +198,9 @@ export class HuiDialogEditViewHeader extends LitElement { haStyleDialog, haStyleDialogFixedTop, css` - ha-dialog.yaml-mode { + ha-wa-dialog.yaml-mode { --dialog-content-padding: 0; } - h2 { - margin: 0; - font-size: inherit; - font-weight: inherit; - } - - @media all and (min-width: 600px) { - ha-dialog { - --mdc-dialog-min-width: 600px; - } - } `, ]; }