@@ -53,6 +53,7 @@ export type DialogWidth = "small" | "medium" | "large" | "full";
5353 * @cssprop --dialog-surface-margin-top - Top margin for the dialog surface.
5454 *
5555 * @attr {boolean} open - Controls the dialog open state.
56+ * @attr {("alert"|"standard")} type - Dialog type. Defaults to "standard".
5657 * @attr {("small"|"medium"|"large"|"full")} width - Preferred dialog width preset. Defaults to "medium".
5758 * @attr {boolean} prevent-scrim-close - Prevents closing the dialog by clicking the scrim/overlay. Defaults to false.
5859 * @attr {string} header-title - Header title text. If not set, the headerTitle slot is used.
@@ -84,6 +85,9 @@ export class HaWaDialog extends LitElement {
8485 @property ( { type : Boolean , reflect : true } )
8586 public open = false ;
8687
88+ @property ( { reflect : true } )
89+ public type : "alert" | "standard" = "standard" ;
90+
8791 @property ( { type : String , reflect : true , attribute : "width" } )
8892 public width : DialogWidth = "medium" ;
8993
@@ -200,18 +204,7 @@ export class HaWaDialog extends LitElement {
200204 haStyleScrollbar ,
201205 css `
202206 wa-dialog {
203- --full-width : var (
204- --ha-dialog-width-full ,
205- min (
206- 95vw ,
207- calc (
208- 100vw - var (--safe-area-inset-left , var (--ha-space-0 )) - var (
209- --safe-area-inset-right ,
210- var (--ha-space-0 )
211- )
212- )
213- )
214- );
207+ --full-width : var (--ha-dialog-width-full , min (95vw , var (--safe-width )));
215208 --width : min (var (--ha-dialog-width-md , 580px ), var (--full-width ));
216209 --spacing : var (--dialog-content-padding , var (--ha-space-6 ));
217210 --show-duration : var (--ha-dialog-show-duration , 200ms );
@@ -228,8 +221,7 @@ export class HaWaDialog extends LitElement {
228221 --ha-dialog-border-radius ,
229222 var (--ha-border-radius-3xl )
230223 );
231- max-width : var (--ha-dialog-max-width , 100vw );
232- max-width : var (--ha-dialog-max-width , 100svw );
224+ max-width : var (--ha-dialog-max-width , var (--safe-width ));
233225 }
234226
235227 : host ([width = "small" ]) wa-dialog {
@@ -249,34 +241,57 @@ export class HaWaDialog extends LitElement {
249241 max-width : var (--width , var (--full-width ));
250242 max-height : var (
251243 --ha-dialog-max-height ,
252- calc (100 % - var (--ha-space-20 ))
244+ calc (var ( --safe-height ) - var (--ha-space-20 ))
253245 );
254246 min-height : var (--ha-dialog-min-height );
255247 position : var (--dialog-surface-position , relative);
256248 margin-top : var (--dialog-surface-margin-top , auto);
249+ /* Used to offset the dialog from the safe areas when space is limited */
250+ transform : translate (
251+ calc (
252+ var (--safe-area-offset-left , var (--ha-space-0 )) - var (
253+ --safe-area-offset-right ,
254+ var (--ha-space-0 )
255+ )
256+ ),
257+ calc (
258+ var (--safe-area-offset-top , var (--ha-space-0 )) - var (
259+ --safe-area-offset-bottom ,
260+ var (--ha-space-0 )
261+ )
262+ )
263+ );
257264 display : flex;
258265 flex-direction : column;
259266 overflow : hidden;
260267 }
261268
262269 @media all and (max-width : 450px ), all and (max-height : 500px ) {
263- : host {
270+ : host ([ type = "standard" ]) {
264271 --ha-dialog-border-radius : var (--ha-space-0 );
265- }
266-
267- wa-dialog {
268- --full-width : var (--ha-dialog-width-full , 100vw );
269- }
270272
271- wa-dialog ::part (dialog ) {
272- min-height : var (--ha-dialog-min-height , 100vh );
273- min-height : var (--ha-dialog-min-height , 100svh );
274- max-height : var (--ha-dialog-max-height , 100vh );
275- max-height : var (--ha-dialog-max-height , 100svh );
276- padding-top : var (--safe-area-inset-top , var (--ha-space-0 ));
277- padding-bottom : var (--safe-area-inset-bottom , var (--ha-space-0 ));
278- padding-left : var (--safe-area-inset-left , var (--ha-space-0 ));
279- padding-right : var (--safe-area-inset-right , var (--ha-space-0 ));
273+ wa-dialog {
274+ /* Make the container fill the whole screen width and not the safe width */
275+ --full-width : var (--ha-dialog-width-full , 100vw );
276+ --width : var (--full-width );
277+ }
278+
279+ wa-dialog ::part (dialog ) {
280+ /* Make the dialog fill the whole screen height and not the safe height */
281+ min-height : var (--ha-dialog-min-height , 100vh );
282+ min-height : var (--ha-dialog-min-height , 100dvh );
283+ max-height : var (--ha-dialog-max-height , 100vh );
284+ max-height : var (--ha-dialog-max-height , 100dvh );
285+ margin-top : 0 ;
286+ margin-bottom : 0 ;
287+ /* Use safe area as padding instead of the container size */
288+ padding-top : var (--safe-area-inset-top );
289+ padding-bottom : var (--safe-area-inset-bottom );
290+ padding-left : var (--safe-area-inset-left );
291+ padding-right : var (--safe-area-inset-right );
292+ /* Reset the transform to center the dialog */
293+ transform : none;
294+ }
280295 }
281296 }
282297
0 commit comments