diff --git a/src/dialogs/more-info/components/lights/dialog-light-color-favorite.ts b/src/dialogs/more-info/components/lights/dialog-light-color-favorite.ts index 61e72cebf5..06fcb931f8 100644 --- a/src/dialogs/more-info/components/lights/dialog-light-color-favorite.ts +++ b/src/dialogs/more-info/components/lights/dialog-light-color-favorite.ts @@ -1,17 +1,12 @@ -import { mdiClose } from "@mdi/js"; import type { CSSResultGroup } from "lit"; import { css, html, LitElement, nothing } from "lit"; -import { customElement, property, query, state } from "lit/decorators"; +import { customElement, property, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; -import "../../../../components/ha-dialog-header"; +import "../../../../components/ha-dialog-footer"; import "../../../../components/ha-icon-button-toggle"; -import type { HaMdDialog } from "../../../../components/ha-md-dialog"; -import { - getMobileCloseToBottomAnimation, - getMobileOpenFromBottomAnimation, -} from "../../../../components/ha-md-dialog"; +import "../../../../components/ha-wa-dialog"; import type { EntityRegistryEntry } from "../../../../data/entity/entity_registry"; import type { LightColor, LightEntity } from "../../../../data/light"; import { @@ -41,7 +36,7 @@ class DialogLightColorFavorite extends LitElement { @state() private _modes: LightPickerMode[] = []; - @query("ha-md-dialog") private _dialog?: HaMdDialog; + @state() private _open = false; public async showDialog( dialogParams: LightColorFavoriteDialogParams @@ -50,10 +45,11 @@ class DialogLightColorFavorite extends LitElement { this._dialogParams = dialogParams; this._color = dialogParams.initialColor ?? this._computeCurrentColor(); this._updateModes(); + this._open = true; } public closeDialog(): void { - this._dialog?.close(); + this._open = false; } private _updateModes() { @@ -120,16 +116,8 @@ class DialogLightColorFavorite extends LitElement { ); } - private async _cancel() { - this._dialogParams?.cancel?.(); - } - - private _cancelDialog() { - this._cancel(); - this.closeDialog(); - } - private _dialogClosed(): void { + this._open = false; this._dialogParams = undefined; this._entry = undefined; this._color = undefined; @@ -138,7 +126,7 @@ class DialogLightColorFavorite extends LitElement { private async _save() { if (!this._color) { - this._cancel(); + this.closeDialog(); return; } this._dialogParams?.submit?.(this._color); @@ -159,83 +147,76 @@ class DialogLightColorFavorite extends LitElement { } return html` - - - - ${this._dialogParams?.title} - -
-
- ${this._modes.length > 1 - ? html` -
- ${this._modes.map( - (value) => html` - - - - ` - )} -
- ` - : nothing} -
-
- ${this._mode === "color_temp" - ? html` - - - ` - : nothing} - ${this._mode === "color" - ? html` - - - ` - : nothing} -
+
+ ${this._modes.length > 1 + ? html` +
+ ${this._modes.map( + (value) => html` + + + + ` + )} +
+ ` + : nothing}
-
- +
+ ${this._mode === "color_temp" + ? html` + + + ` + : nothing} + ${this._mode === "color" + ? html` + + + ` + : nothing} +
+ + ${this.hass.localize("ui.common.cancel")} - ${this.hass.localize("ui.common.save")} -
- + ${this.hass.localize("ui.common.save")} + + + `; } @@ -243,23 +224,18 @@ class DialogLightColorFavorite extends LitElement { return [ haStyleDialog, css` - ha-md-dialog { - min-width: 420px; /* prevent width jumps when switching modes */ - max-height: min( + ha-wa-dialog { + --ha-dialog-width-md: 420px; /* prevent width jumps when switching modes */ + --ha-dialog-max-height: min( 600px, 100% - 48px ); /* prevent scrolling on desktop */ } @media all and (max-width: 450px), all and (max-height: 500px) { - ha-md-dialog { - min-width: 100%; - min-height: auto; - max-height: calc(100% - 100px); - margin-bottom: 0; - - --md-dialog-container-shape-start-start: 28px; - --md-dialog-container-shape-start-end: 28px; + ha-wa-dialog { + --ha-dialog-width-md: 100vw; + --ha-dialog-max-height: calc(100% - 100px); } } diff --git a/src/dialogs/more-info/components/lights/show-dialog-light-color-favorite.ts b/src/dialogs/more-info/components/lights/show-dialog-light-color-favorite.ts index 5369584d06..ca0618dfeb 100644 --- a/src/dialogs/more-info/components/lights/show-dialog-light-color-favorite.ts +++ b/src/dialogs/more-info/components/lights/show-dialog-light-color-favorite.ts @@ -7,7 +7,6 @@ export interface LightColorFavoriteDialogParams { title: string; initialColor?: LightColor; submit?: (color?: LightColor) => void; - cancel?: () => void; } export const loadLightColorFavoriteDialog = () => @@ -18,7 +17,6 @@ export const showLightColorFavoriteDialog = ( dialogParams: LightColorFavoriteDialogParams ) => new Promise((resolve) => { - const origCancel = dialogParams.cancel; const origSubmit = dialogParams.submit; fireEvent(element, "show-dialog", { @@ -26,12 +24,6 @@ export const showLightColorFavoriteDialog = ( dialogImport: loadLightColorFavoriteDialog, dialogParams: { ...dialogParams, - cancel: () => { - resolve(null); - if (origCancel) { - origCancel(); - } - }, submit: (color: LightColor) => { resolve(color); if (origSubmit) {