diff --git a/src/panels/config/backup/dialogs/dialog-change-backup-encryption-key.ts b/src/panels/config/backup/dialogs/dialog-change-backup-encryption-key.ts index 8fd8e2c3fe..29963cd1cf 100644 --- a/src/panels/config/backup/dialogs/dialog-change-backup-encryption-key.ts +++ b/src/panels/config/backup/dialogs/dialog-change-backup-encryption-key.ts @@ -1,15 +1,14 @@ import { mdiClose, mdiContentCopy, mdiDownload } from "@mdi/js"; import type { CSSResultGroup } from "lit"; import { LitElement, css, html, nothing } from "lit"; -import { customElement, property, query, state } from "lit/decorators"; +import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import { copyToClipboard } from "../../../../common/util/copy-clipboard"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-icon-button"; import "../../../../components/ha-icon-button-prev"; -import "../../../../components/ha-md-dialog"; -import type { HaMdDialog } from "../../../../components/ha-md-dialog"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-md-list"; import "../../../../components/ha-md-list-item"; import "../../../../components/ha-password-field"; @@ -31,20 +30,18 @@ type Step = (typeof STEPS)[number]; class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { @property({ attribute: false }) public hass!: HomeAssistant; - @state() private _opened = false; + @state() private _open = false; @state() private _step?: Step; @state() private _params?: ChangeBackupEncryptionKeyDialogParams; - @query("ha-md-dialog") private _dialog!: HaMdDialog; - @state() private _newEncryptionKey?: string; public showDialog(params: ChangeBackupEncryptionKeyDialogParams): void { this._params = params; this._step = STEPS[0]; - this._opened = true; + this._open = true; this._newEncryptionKey = generateEncryptionKey(); } @@ -52,10 +49,10 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { if (this._params!.cancel) { this._params!.cancel(); } - if (this._opened) { + if (this._open) { fireEvent(this, "dialog-closed", { dialog: this.localName }); } - this._opened = false; + this._open = false; this._step = undefined; this._params = undefined; this._newEncryptionKey = undefined; @@ -64,7 +61,7 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { private _done() { this._params?.submit!(true); - this._dialog.close(); + this.closeDialog(); } private _previousStep() { @@ -84,10 +81,6 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { } protected render() { - if (!this._opened || !this._params) { - return nothing; - } - const dialogTitle = this._step === "current" || this._step === "new" ? this.hass.localize( @@ -96,36 +89,40 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { : ""; return html` - - - ${this._step === "new" - ? html` - - ` - : html` - - `} - ${dialogTitle} - -
${this._renderStepContent()}
-
+ + ${this._step === "new" + ? html` + + ` + : html` + + `} + ${this._renderStepContent()} + ${this._step === "current" ? html` - + ${this.hass.localize("ui.common.next")} ` : this._step === "new" ? html` ` : html` - + ${this.hass.localize( "ui.panel.config.backup.dialogs.change_encryption_key.actions.done" )} `} -
-
+ + `; } @@ -287,10 +284,8 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { haStyle, haStyleDialog, css` - ha-md-dialog { - width: 90vw; - max-width: 560px; - --dialog-content-padding: 8px 24px; + ha-wa-dialog { + --dialog-content-padding: var(--ha-space-2) var(--ha-space-6); } ha-md-list { background: none; @@ -321,14 +316,7 @@ class DialogChangeBackupEncryptionKey extends LitElement implements HassDialog { flex: none; margin: -16px; } - @media all and (max-width: 450px), all and (max-height: 500px) { - ha-md-dialog { - max-width: none; - } - div[slot="content"] { - margin-top: 0; - } - } + p { margin-top: 0; } diff --git a/src/panels/config/backup/dialogs/dialog-show-backup-encryption-key.ts b/src/panels/config/backup/dialogs/dialog-show-backup-encryption-key.ts index f9052e8442..2a157948d9 100644 --- a/src/panels/config/backup/dialogs/dialog-show-backup-encryption-key.ts +++ b/src/panels/config/backup/dialogs/dialog-show-backup-encryption-key.ts @@ -1,15 +1,14 @@ import { mdiClose, mdiContentCopy, mdiDownload } from "@mdi/js"; import type { CSSResultGroup } from "lit"; import { LitElement, css, html, nothing } from "lit"; -import { customElement, property, query, state } from "lit/decorators"; +import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import { copyToClipboard } from "../../../../common/util/copy-clipboard"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-icon-button"; import "../../../../components/ha-icon-button-prev"; -import "../../../../components/ha-md-dialog"; -import type { HaMdDialog } from "../../../../components/ha-md-dialog"; +import "../../../../components/ha-wa-dialog"; import "../../../../components/ha-md-list"; import "../../../../components/ha-md-list-item"; import "../../../../components/ha-password-field"; @@ -24,89 +23,83 @@ import type { ShowBackupEncryptionKeyDialogParams } from "./show-dialog-show-bac class DialogShowBackupEncryptionKey extends LitElement implements HassDialog { @property({ attribute: false }) public hass!: HomeAssistant; - @state() private _params?: ShowBackupEncryptionKeyDialogParams; + @state() private _open = false; - @query("ha-md-dialog") private _dialog!: HaMdDialog; + @state() private _params?: ShowBackupEncryptionKeyDialogParams; public showDialog(params: ShowBackupEncryptionKeyDialogParams): void { this._params = params; + this._open = true; } public closeDialog() { + if (this._open) { + fireEvent(this, "dialog-closed", { dialog: this.localName }); + } + this._open = false; this._params = undefined; - fireEvent(this, "dialog-closed", { dialog: this.localName }); return true; } - private _closeDialog() { - this._dialog.close(); - } - protected render() { if (!this._params) { return nothing; } return html` - - + + +

+ ${this.hass.localize( + "ui.panel.config.backup.dialogs.show_encryption_key.description" + )} +

+
+

${this._params?.currentKey}

- - ${this.hass.localize( - "ui.panel.config.backup.dialogs.show_encryption_key.title" - )} - - -
-

- ${this.hass.localize( - "ui.panel.config.backup.dialogs.show_encryption_key.description" - )} -

-
-

${this._params?.currentKey}

- -
- - - - ${this.hass.localize( - "ui.panel.config.backup.encryption_key.download_emergency_kit" - )} - - - ${this.hass.localize( - "ui.panel.config.backup.encryption_key.download_emergency_kit_description" - )} - - - - ${this.hass.localize( - "ui.panel.config.backup.encryption_key.download_emergency_kit_action" - )} - - -
-
- + + + + ${this.hass.localize( + "ui.panel.config.backup.encryption_key.download_emergency_kit" + )} + + + ${this.hass.localize( + "ui.panel.config.backup.encryption_key.download_emergency_kit_description" + )} + + + + ${this.hass.localize( + "ui.panel.config.backup.encryption_key.download_emergency_kit_action" + )} + + + + + ${this.hass.localize("ui.common.close")} -
- + + `; } @@ -135,10 +128,8 @@ class DialogShowBackupEncryptionKey extends LitElement implements HassDialog { haStyle, haStyleDialog, css` - ha-md-dialog { - width: 90vw; - max-width: 560px; - --dialog-content-padding: 8px 24px; + ha-wa-dialog { + --dialog-content-padding: var(--ha-space-2) var(--ha-space-6); } ha-md-list { background: none; @@ -169,14 +160,7 @@ class DialogShowBackupEncryptionKey extends LitElement implements HassDialog { flex: none; margin: -16px; } - @media all and (max-width: 450px), all and (max-height: 500px) { - ha-md-dialog { - max-width: none; - } - div[slot="content"] { - margin-top: 0; - } - } + p { margin-top: 0; }