From ab0d584acfe188dafcddef503bd4eb25181dd7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Curda?= Date: Mon, 30 Dec 2024 14:52:17 +0100 Subject: [PATCH] Feat(web): Introduce Drawer component #DS-1580 --- .../web/src/scss/components/Drawer/README.md | 1 + .../src/scss/components/Drawer/_Drawer.scss | 53 + .../scss/components/Drawer/_DrawerDialog.scss | 37 + .../src/scss/components/Drawer/_theme.scss | 25 + .../web/src/scss/components/Drawer/index.html | 1296 +++++++++++++++++ .../web/src/scss/components/Drawer/index.scss | 2 + packages/web/src/scss/components/index.scss | 1 + 7 files changed, 1415 insertions(+) create mode 100644 packages/web/src/scss/components/Drawer/README.md create mode 100644 packages/web/src/scss/components/Drawer/_Drawer.scss create mode 100644 packages/web/src/scss/components/Drawer/_DrawerDialog.scss create mode 100644 packages/web/src/scss/components/Drawer/_theme.scss create mode 100644 packages/web/src/scss/components/Drawer/index.html create mode 100644 packages/web/src/scss/components/Drawer/index.scss diff --git a/packages/web/src/scss/components/Drawer/README.md b/packages/web/src/scss/components/Drawer/README.md new file mode 100644 index 0000000000..96f088846f --- /dev/null +++ b/packages/web/src/scss/components/Drawer/README.md @@ -0,0 +1 @@ +# Drawer diff --git a/packages/web/src/scss/components/Drawer/_Drawer.scss b/packages/web/src/scss/components/Drawer/_Drawer.scss new file mode 100644 index 0000000000..90aae6694b --- /dev/null +++ b/packages/web/src/scss/components/Drawer/_Drawer.scss @@ -0,0 +1,53 @@ +@use 'theme'; + +.Drawer { + --drawer-scale: #{theme.$transition-scale-ratio}; + + all: unset; + position: fixed; + inset: 0; + z-index: 1; + display: flex; + overflow-y: auto; + background: linear-gradient(#{theme.$backdrop-background-color}, #{theme.$backdrop-background-color}); + visibility: hidden; + opacity: 0; + pointer-events: none; + overscroll-behavior: contain; + + &::backdrop { + background-color: transparent; + } + + @media (prefers-reduced-motion: no-preference) { + transition-property: visibility, opacity; + transition-duration: theme.$transition-duration; + } +} + +.Drawer:has(.DrawerDialog--scrollable) { + overflow: hidden; +} + +.Drawer--center, +.Drawer:not(.Drawer--left, .Drawer--right) { + justify-content: center; +} + +.Drawer--left { + justify-content: start; +} + +.Drawer--right { + justify-content: end; +} + +.Drawer[open] { + --drawer-scale: 1; + --drawer-translate-y: 0; + + visibility: visible; + opacity: 1; + user-select: text; // 6. + pointer-events: auto; +} diff --git a/packages/web/src/scss/components/Drawer/_DrawerDialog.scss b/packages/web/src/scss/components/Drawer/_DrawerDialog.scss new file mode 100644 index 0000000000..d8e513f665 --- /dev/null +++ b/packages/web/src/scss/components/Drawer/_DrawerDialog.scss @@ -0,0 +1,37 @@ +// 1. Use ScrollView's backdoor to fix its height inside DrawerDialog in Safari. +// 2. We need to set the box-sizing again because the parent element unsets styles using `all: unset`. +// 3. Intentionally transition also the worse performing properties to smooth out the changes of viewport size around +// the tablet breakpoint. However, `top` and `bottom` are not transitioned when switching from and to `auto`. +// 4. Override bottom padding of parent `.Drawer` in the docked variant. + +@use 'sass:map'; +@use '../../tools/breakpoint'; +@use '../../tools/typography'; +@use 'theme'; + +.DrawerDialog { + @include typography.generate(theme.$typography); + + --scroll-view-vertical-height: auto; + + display: flex; + flex-direction: column; + box-sizing: border-box; + width: theme.$dialog-width; + max-width: calc(100% - #{theme.$padding-x}); + height: theme.$dialog-height; + max-height: theme.$dialog-max-height; + overflow-x: var(--drawer-body-overflow-x, visible); + overflow-y: var(--drawer-body-overflow-y, visible); + color: theme.$dialog-text-color; + background-color: theme.$dialog-background-color; + box-shadow: theme.$dialog-shadow; + transform: translateY(var(--drawer-translate-y)) scale(var(--drawer-scale)); + transform-origin: var(--drawer-transform-origin); + overscroll-behavior: contain; + + @media (prefers-reduced-motion: no-preference) { + transition-property: width, height, max-height, border-radius, transform; + transition-duration: inherit; + } +} diff --git a/packages/web/src/scss/components/Drawer/_theme.scss b/packages/web/src/scss/components/Drawer/_theme.scss new file mode 100644 index 0000000000..6e70512f1d --- /dev/null +++ b/packages/web/src/scss/components/Drawer/_theme.scss @@ -0,0 +1,25 @@ +@use '@tokens' as tokens; +@use '../../settings/transitions'; + +$breakpoints: tokens.$breakpoints; +$padding-x: tokens.$space-900; +$padding-x-tablet: tokens.$space-1400; +$padding-y: tokens.$space-700; +$typography: tokens.$body-medium-regular; +$transition-duration: transitions.$duration-200; +$transition-scale-ratio: transitions.$scale-ratio-large-objects; +$transition-shift-distance: transitions.$shift-distance-medium; + +$backdrop-background-color: tokens.$background-backdrop; + +$common-padding-x: tokens.$space-900; +$common-padding-x-tablet: tokens.$space-1000; + +// ModalDialog +$dialog-width: 375px; +$dialog-height: auto; +$dialog-max-height: none; +$dialog-text-color: tokens.$text-primary; +$dialog-border-radius: tokens.$radius-300; +$dialog-background-color: tokens.$background-primary; +$dialog-shadow: tokens.$shadow-300; diff --git a/packages/web/src/scss/components/Drawer/index.html b/packages/web/src/scss/components/Drawer/index.html new file mode 100644 index 0000000000..868fe467e7 --- /dev/null +++ b/packages/web/src/scss/components/Drawer/index.html @@ -0,0 +1,1296 @@ +{{#> web/layout/default title="Modal" parentPageName="Components" }} + + + +
+ +
+ +

Modal

+ +
+ + + + + + + +
+ + +
+

Modal Title

+ +
+ + + +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+ +
+
Modal alignment:
+ + + +
+ + +
+
Footer alignment (from tablet up):
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+
+ Optional description +
+
+ + +
+
+ + +
+ + +
+ + + + + + + + +
+ + +
+

Modal with a Form

+ +
+ + + +
+ +
+ + +
+

+ The primary action is a button with type="submit" and closes the dialog on submission. +

+ +
+ + + +
+
+ + +
+
+ + +
+ + +
+ + + + + + + + +
+ + +
+

Modal Title

+ +
+ + + +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+ + +
+ + + +
+
+ Optional description +
+
+ + +
+
+ + +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +

Scrolling Long Content

+ +
+ + + + + + + +
+ + +
+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia perferendis reprehenderit, voluptate. Cum delectus dicta +

+ +
+ + + +
+ + + {{setVar "blocks" 1 2 3 4 5 6 7 8 9 }} + {{#each @root.blocks}} +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+ {{/each}} + + +
+ + + +
+
+ + +
+
+ + +
+ + +
+ + + + + + + + +
+ + +
+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia perferendis reprehenderit, voluptate. Cum delectus dicta +

+ +
+ + + +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+ +
+ + + +
+
+ + +
+
+ + +
+ + +
+ + + + + + + + +
+ + +
+

+ Modal with ScrollView +

+ +
+ + + +
+
+
+ + +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+ +
+ + +
+
+ +
+ + + +
+
+ + +
+
+ + +
+ + +
+ + + + + + + + +
+ + +
+

Modal with Custom Height

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

Stacking Modals

+ +
+ + + + + + + +
+ + +
+

Modal Title

+ +
+ + + +
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+ +
+ + + +
+
+ +
+
+ + +
+ + +
+ + + + + +
+ + +
+

Stacked Modal Title

+ +
+ + + +
+ +

+ Dolor quis metus a lorem, et elit pulvinar ligula condimentum non congue rhoncus molestie, at sem + viverra maximus nunc. Posuere pretium accumsan, pharetra vel integer sit amet volutpat neque fringilla, + non mauris erat id augue libero. Porta non congue, et iaculis et vehicula convallis non purus placerat + cursus, rhoncus laoreet nec et elit. Proin luctus, bibendum adipiscing ut ollicitudin vehicula nisi + nunc et, sollicitudin eget tristique nec commodo. Porttitor ligula, tellus vehicula arcu vestibulum + sed rutrum placerat, dui quis facilisis eget. Suscipit molestie, nibh maximus enim vestibulum aenean + ut libero sed imperdiet, curabitur et elit venenatis posuere. +
+ Sapien vitae, dui sollicitudin nullam dolor quis nec nulla sapien, diam a ollicitudin non nulla nisl. + Quis orci porta, ac nec sapien ornare imperdiet a vel convallis, adipiscing ullamcorper lectus quis + pharetra. At nullam rutrum, nisl eget sit amet pulvinar ultricies nec porta, diam a sem odio a mauris + eu. Suscipit sodales, fusce ante cursus convallis dui vel dolor potenti nulla fusce gravida. +

+ +
+ + + +
+
+ + +
+
+ + +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +

Disabled Backdrop Click

+ +
+ + + + + +
+ +
+

Modal Title

+ +
+ +
+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+
+ +
+
+ + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +

Hidden Close Button and Disabled Escape Key

+ +
+ + + + + + +
+ +
+

Modal Title

+
+ +
+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia + perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis + provident unde. Eveniet, iste, molestiae? +

+
+ + + +
+ +
+ +
+ +
+ +
+ +{{/web/layout/default }} diff --git a/packages/web/src/scss/components/Drawer/index.scss b/packages/web/src/scss/components/Drawer/index.scss new file mode 100644 index 0000000000..1cfc43df90 --- /dev/null +++ b/packages/web/src/scss/components/Drawer/index.scss @@ -0,0 +1,2 @@ +@forward 'Drawer'; +@forward 'DrawerDialog'; diff --git a/packages/web/src/scss/components/index.scss b/packages/web/src/scss/components/index.scss index 13a2888365..a9123faa6b 100644 --- a/packages/web/src/scss/components/index.scss +++ b/packages/web/src/scss/components/index.scss @@ -8,6 +8,7 @@ @forward 'Collapse'; @forward 'Container'; @forward 'Divider'; +@forward 'Drawer'; @forward 'Dropdown'; @forward 'FieldGroup'; @forward 'FileUploader';