diff --git a/docs/migrations/web/MIGRATION-v2.md b/docs/migrations/web/MIGRATION-v2.md index 760206003c..bbda80099a 100644 --- a/docs/migrations/web/MIGRATION-v2.md +++ b/docs/migrations/web/MIGRATION-v2.md @@ -15,7 +15,9 @@ Introducing version 2 of the _spirit-web_ package - [Dropdown: Classes](#dropdown-classes) - [Dropdown: Combined Placements](#dropdown-combined-placements) - [Dropdown: Shadow Feature Flag](#dropdown-shadow-feature-flag) + - [Modal: Custom Height](#modal-custom-height) - [Modal: (Non)Scrollable](#modal-nonscrollable) + - [Modal: Custom Height](#modal-custom-height) - [Modal: Uniform Variant Feature Flag](#modal-uniform-variant-feature-flag) - [Grid: GridSpan Component](#grid-gridspan-component) - [Tooltip: Data Selector Controlled Placement Feature Flag](#tooltip-data-selector-controlled-placement-feature-flag) @@ -141,6 +143,19 @@ to the `.ModalDialog` element. - `.ModalDialog` → `.ModalDialog .ModalDialog--scrollable` +### Modal: Custom Height + +The `--modal-preferred-height-mobile`, `--modal-preferred-height-tablet`, +`--modal-max-height-tablet` custom properties were renamed. + +#### Migration Guide + +Update the custom properties in your project to use the new names: + +- `--modal-preferred-height-mobile` → `--modal-dialog-height` +- `--modal-preferred-height-tablet` → `--modal-dialog-height-tablet` +- `--modal-max-height-tablet` → `--modal-dialog-max-height-tablet` + ### Modal: Uniform Variant Feature Flag The feature flag enabling the uniform variant of modal was removed and the diff --git a/packages/web/src/scss/components/Modal/README.md b/packages/web/src/scss/components/Modal/README.md index 1f30328f83..e340455ba0 100644 --- a/packages/web/src/scss/components/Modal/README.md +++ b/packages/web/src/scss/components/Modal/README.md @@ -274,15 +274,20 @@ limit. You can set a custom preferred height of ModalDialog using a custom property: -- `--modal-preferred-height-mobile` for mobile screens, and -- `--modal-preferred-height-tablet` for tablet screens and up. +- `--modal-dialog-height` for mobile screens and up, +- `--modal-dialog-height-tablet` for tablet screens and up. +- `--modal-dialog-height-desktop` for desktop screens and up. + +The custom properties fall back to the previous breakpoint using the mobile-first approach. For example, if you set +`--modal-dialog-height-tablet` while leaving `--modal-dialog-height-desktop` unset, the value will be used for +both tablet and desktop screens. This is useful for Modals with dynamic content, e.g. a list of items that can be added or removed, or a multistep wizard. ```html
@@ -300,11 +305,21 @@ The default maximum height of a scrollable ModalDialog is **600 px**, as long as If the viewport is smaller, scrollable ModalDialog will shrink to fit the viewport. In such case, the ModalDialog height will calculate as "viewport height (`100dvh`) minus 1100 spacing". -You can use the custom property `--modal-max-height-tablet` to override the default maximum height limit on tablet -screens and up: +You can set a custom preferred height of ModalDialog using a custom property: + +- `--modal-dialog-max-height` for mobile screens and up, +- `--modal-dialog-max-height-tablet` for tablet screens and up. +- `--modal-dialog-max-height-desktop` for desktop screens and up. + +The custom properties fall back to the previous breakpoint using the mobile-first approach. For example, if you set +`--modal-dialog-max-height-tablet` while leaving `--modal-dialog-max-height-desktop` unset, the value will be used for both tablet and +desktop screens. ```html -
+
``` diff --git a/packages/web/src/scss/components/Modal/_ModalDialog.scss b/packages/web/src/scss/components/Modal/_ModalDialog.scss index e0876e5288..ddbdbbabe8 100644 --- a/packages/web/src/scss/components/Modal/_ModalDialog.scss +++ b/packages/web/src/scss/components/Modal/_ModalDialog.scss @@ -55,6 +55,11 @@ height: theme.$dialog-scrollable-height-tablet; max-height: theme.$dialog-scrollable-max-height-tablet; } + + @include breakpoint.up(map.get(theme.$breakpoints, desktop)) { + height: theme.$dialog-scrollable-height-desktop; + max-height: theme.$dialog-scrollable-max-height-desktop; + } } .ModalDialog--dockOnMobile { diff --git a/packages/web/src/scss/components/Modal/_theme.scss b/packages/web/src/scss/components/Modal/_theme.scss index 904b678695..5537dc1750 100644 --- a/packages/web/src/scss/components/Modal/_theme.scss +++ b/packages/web/src/scss/components/Modal/_theme.scss @@ -25,14 +25,31 @@ $dialog-border-radius: tokens.$radius-200; $dialog-background-color: tokens.$background-basic; $dialog-shadow: tokens.$shadow-300; -$dialog-scrollable-height: var(--modal-preferred-height-mobile, min-content); +$_dialog-scrollable-default-height: min-content; +$_dialog-scrollable-default-max-height: 600px; + +$dialog-scrollable-height: var(--modal-dialog-height, #{$_dialog-scrollable-default-height}); $dialog-scrollable-height-tablet: var( - --modal-preferred-height-tablet, - var(--modal-preferred-height-mobile, min-content) + --modal-dialog-height-tablet, + var(--modal-dialog-height, #{$_dialog-scrollable-default-height}) +); +$dialog-scrollable-height-desktop: var( + --modal-dialog-height-desktop, + var(--modal-dialog-height-tablet, var(--modal-dialog-height, #{$_dialog-scrollable-default-height})) +); +$dialog-scrollable-max-height: min( + var(--modal-dialog-max-height, #{$_dialog-scrollable-default-max-height}), + calc(100dvh - #{2 * $padding-y}) ); -$dialog-scrollable-max-height: min(var(--modal-max-height-mobile, 600px), calc(100dvh - #{2 * $padding-y})); $dialog-scrollable-max-height-tablet: min( - var(--modal-max-height-tablet, var(--modal-max-height-mobile, 600px)), + var(--modal-dialog-max-height-tablet, var(--modal-dialog-max-height, #{$_dialog-scrollable-default-max-height})), + calc(100dvh - #{2 * $padding-y}) +); +$dialog-scrollable-max-height-desktop: min( + var( + --modal-dialog-max-height-desktop, + var(--modal-dialog-max-height-tablet, var(--modal-dialog-max-height, #{$_dialog-scrollable-default-max-height})) + ), calc(100dvh - #{2 * $padding-y}) ); @@ -41,7 +58,7 @@ $dialog-docked-margin-top: tokens.$space-1100; $dialog-docked-expanded-min-height: calc(100dvh - #{$dialog-docked-margin-top}); -$dialog-docked-scrollable-height: var(--modal-preferred-height-mobile, min-content); +$dialog-docked-scrollable-height: var(--modal-dialog-height, #{$_dialog-scrollable-default-height}); $dialog-docked-scrollable-max-height: $dialog-docked-expanded-min-height; // ModalHeader diff --git a/packages/web/src/scss/components/Modal/index.html b/packages/web/src/scss/components/Modal/index.html index a01cf784b8..3cf718a0bd 100644 --- a/packages/web/src/scss/components/Modal/index.html +++ b/packages/web/src/scss/components/Modal/index.html @@ -694,7 +694,7 @@

@@ -719,16 +719,224 @@

Modal with Custo
-

- This modal has a custom height of 400px set via the --modal-preferred-height-mobile CSS - custom property. -

-

- This modal has a custom height of 500px set via the --modal-preferred-height-tablet CSS - custom property. -

- - + + +
+
+ + +
+ + + 400 px + + +
+
+ + + 600 px + + +
+
+
+ + +
+ + + 500 px + + +
+
+ + + 600 px + + +
+
+
+ + +
+ + + 600 px + + +
+
+ + + 600 px + + +
+
+
+