diff --git a/packages/components/src/components/modal/_modal.scss b/packages/components/src/components/modal/_modal.scss index 1ff401eeff69..23fc11dcc331 100644 --- a/packages/components/src/components/modal/_modal.scss +++ b/packages/components/src/components/modal/_modal.scss @@ -71,8 +71,9 @@ .#{$prefix}--modal-container { position: relative; - display: flex; - flex-direction: column; + display: grid; + grid-template-rows: auto 1fr auto; + grid-template-columns: auto; background-color: $ui-01; width: 100%; height: 100%; @@ -83,31 +84,98 @@ transition: transform $duration--moderate-02 motion(exit, expressive); @include carbon--breakpoint(md) { - width: 50%; + width: 84%; max-width: 768px; max-height: 90%; height: auto; } @include carbon--breakpoint(lg) { - max-height: 80%; + width: 60%; + max-height: 84%; + } + + @include carbon--breakpoint(xlg) { + width: 48%; + } + } + + .#{$prefix}--modal-container--xs { + @include carbon--breakpoint(md) { + width: 48%; + } + + @include carbon--breakpoint(lg) { + width: 32%; + max-height: 48%; + } + + @include carbon--breakpoint(xlg) { + width: 24%; + + .#{$prefix}--modal-header, + .#{$prefix}--modal-content, + .#{$prefix}--modal-content__regular-content { + padding-right: rem(16px); + } + } + } + + .#{$prefix}--modal-container--sm { + @include carbon--breakpoint(md) { + width: 60%; + } + + @include carbon--breakpoint(lg) { + width: 42%; + max-height: 72%; + } + + @include carbon--breakpoint(xlg) { + width: 36%; + } + } + + .#{$prefix}--modal-container--lg { + @include carbon--breakpoint(md) { + width: 96%; + } + + @include carbon--breakpoint(lg) { + width: 84%; + max-height: 96%; + } + + @include carbon--breakpoint(xlg) { + width: 72%; } } .#{$prefix}--modal-header, .#{$prefix}--modal-content { - padding-right: 25%; padding-left: 1rem; } .#{$prefix}--modal-header, - .#{$prefix}--modal-footer { - flex-shrink: 0; + .#{$prefix}--modal-content, + .#{$prefix}--modal-content__regular-content { + padding-right: 20%; + } + + .#{$prefix}--modal-content--with-form { + padding-right: 1rem; + + @include carbon--breakpoint(xlg) { + padding-right: 1rem; // Override for `.#{$prefix}--modal-content` + } } .#{$prefix}--modal-header { padding-top: 1rem; margin-bottom: $carbon--spacing-03; + + grid-row: 1/1; + grid-column: 1/-1; } .#{$prefix}--modal-header__label { @@ -126,6 +194,9 @@ .#{$prefix}--modal-content { @include type-style('body-long-01'); + grid-row: 2/-2; + grid-column: 1/-1; + overflow-y: auto; margin-bottom: $carbon--spacing-08; color: $text-01; @@ -140,8 +211,28 @@ } } - .#{$prefix}--modal-content > * { - @include type-style('body-long-01'); + .#{$prefix}--modal-content { + > * { + @include type-style('body-long-01'); + } + } + + .#{$prefix}--modal-content--overflow-indicator { + grid-row: 2/-2; + grid-column: 1/-1; + width: 100%; + height: rem(16px); + content: ''; + position: absolute; + left: 0; + bottom: $carbon--spacing-08; + background-image: linear-gradient(to bottom, transparent, $ui-01); + } + + .#{$prefix}--modal-content:focus + ~ .#{$prefix}--modal-content--overflow-indicator { + width: calc(100% - 4px); + margin: 0 2px 2px 2px; } .#{$prefix}--modal-footer { @@ -150,6 +241,9 @@ height: 4rem; background-color: $modal-footer-background-color; + grid-row: -1/-1; + grid-column: 1/-1; + button.#{$prefix}--btn { max-width: none; flex: 1; diff --git a/packages/components/src/components/modal/modal.config.js b/packages/components/src/components/modal/modal.config.js index 9c786f23eb2a..fa65b84729d1 100644 --- a/packages/components/src/components/modal/modal.config.js +++ b/packages/components/src/components/modal/modal.config.js @@ -29,6 +29,45 @@ module.exports = { classCloseButton: `${prefix}--btn--secondary`, }, }, + { + name: 'xs', + label: 'Transactional Modal (XS)', + context: { + idSuffix: Math.random() + .toString(36) + .substr(2), + hasFooter: true, + classPrimaryButton: `${prefix}--btn--primary`, + classCloseButton: `${prefix}--btn--secondary`, + size: 'xs', + }, + }, + { + name: 'sm', + label: 'Transactional Modal (Small)', + context: { + idSuffix: Math.random() + .toString(36) + .substr(2), + hasFooter: true, + classPrimaryButton: `${prefix}--btn--primary`, + classCloseButton: `${prefix}--btn--secondary`, + size: 'sm', + }, + }, + { + name: 'lg', + label: 'Transactional Modal (Large)', + context: { + idSuffix: Math.random() + .toString(36) + .substr(2), + hasFooter: true, + classPrimaryButton: `${prefix}--btn--primary`, + classCloseButton: `${prefix}--btn--secondary`, + size: 'lg', + }, + }, { name: 'nofooter', label: 'Passive Modal', @@ -42,6 +81,45 @@ module.exports = { classCloseButton: `${prefix}--btn--secondary`, }, }, + { + name: 'nofooter-xs', + label: 'Passive Modal (XS)', + context: { + idSuffix: Math.random() + .toString(36) + .substr(2), + hasFooter: false, + classPrimaryButton: `${prefix}--btn--primary`, + classCloseButton: `${prefix}--btn--secondary`, + size: 'xs', + }, + }, + { + name: 'nofooter-sm', + label: 'Passive Modal (Small)', + context: { + idSuffix: Math.random() + .toString(36) + .substr(2), + hasFooter: false, + classPrimaryButton: `${prefix}--btn--primary`, + classCloseButton: `${prefix}--btn--secondary`, + size: 'sm', + }, + }, + { + name: 'nofooter-lg', + label: 'Passive Modal (Large)', + context: { + idSuffix: Math.random() + .toString(36) + .substr(2), + hasFooter: false, + classPrimaryButton: `${prefix}--btn--primary`, + classCloseButton: `${prefix}--btn--secondary`, + size: 'lg', + }, + }, { name: 'danger', label: 'Danger Modal', diff --git a/packages/components/src/components/modal/modal.hbs b/packages/components/src/components/modal/modal.hbs index f253d3ea9f13..3e5d2b7630fc 100644 --- a/packages/components/src/components/modal/modal.hbs +++ b/packages/components/src/components/modal/modal.hbs @@ -10,7 +10,7 @@