Modal
Installation
yarn add @chewy/kib-overlays-styles
Import
@use '~@chewy/kib-overlays-styles/src/kib-modal/styles' as kib-modal;
Mixins
container-wrapper
@mixin container-wrapper() { ... }
@mixin container-wrapper() { position: fixed; display: flex; top: 0; right: 0; left: 0; bottom: 0; justify-content: center; align-items: center; height: 100%; // Note: need 100% here rather than 100vh. Using 100vh will result not vertically centered in ios Chrome & Safar as // url bar height is taken into aacount for the visible height. CDS-4689 resource: https://developers.google.com/web/updates/2016/12/url-bar-resizing width: 100%; z-index: settings.$z-index; }
wrapper-inner
@mixin wrapper-inner($parent) { ... }
@mixin wrapper-inner($parent) { display: flex; justify-content: center; width: 100%; max-height: settings.$max-height-small; max-width: settings.$small-width; @include media.query(min-md) { width: settings.$default-width; max-width: settings.$max-width; max-height: settings.$max-height-large; } #{$parent}__container { width: 100%; // To override width that get set in the modal container which cannot be removed at this moment for previous version CDS-4946 } }
Description
Wrapper-inner container
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$parent | class of the parent | String | — none |
Requires
- [variable]
max-height-small
- [variable]
small-width
- [variable]
default-width
- [variable]
max-width
- [variable]
max-height-large
large-wrapper-inner
@mixin large-wrapper-inner($parent) { ... }
@mixin large-wrapper-inner($parent) { max-height: settings.$max-height-small; width: settings.$small-width; @include media.query(min-md) { width: settings.$default-width; max-width: settings.$max-width-large; max-height: settings.$max-height-large; } #{$parent}__container { width: 100%; // To override width that get set in the modal container which cannot be removed at this moment for previous version CDS-4946 } }
Description
Large wrapper-inner container
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$parent | class of the parent | String | — none |
Requires
- [variable]
max-height-small
- [variable]
small-width
- [variable]
default-width
- [variable]
max-width-large
- [variable]
max-height-large
focus-trap
@mixin focus-trap() { ... }
@mixin focus-trap() { display: flex; width: 100%; justify-content: center; }
Description
React focus trap, need this style to maintain modal width in Chrome & scrollable text height not overlapped title in Safari
Parameters
None.
container
@mixin container() { ... }
@mixin container() { @include kib-foundations.elevation('high'); padding: 0; display: flex; flex-direction: column; background-color: settings.$background-color; border: none; border-radius: settings.$border-radius; mask-image: radial-gradient(white, black); overflow: hidden; -webkit-tap-highlight-color: transparent; position: relative; // Note: Override native style for dialog in Chrome. To maintain the same container wrapper height (flexbox) and remain vertically centered in both Chrome and Safari9/9/21 max-height: 100%; max-width: 100%; @include media.query(min-md) { width: settings.$default-width; max-width: settings.$max-width; max-height: settings.$max-height-large; } }
Description
Modal container
Parameters
None.
Requires
- [variable]
background-color
- [variable]
border-radius
- [variable]
default-width
- [variable]
max-width
- [variable]
max-height-large
TODO's
width, height, max-width, max-height css property can be removed later as they are added in the 'wrapper-inner'. Just keep the styles here for now for the previous package version CDS-4946
container-large
@mixin container-large() { ... }
@mixin container-large() { width: settings.$small-width; max-height: 100%; @include media.query(min-md) { max-width: settings.$max-width-large; max-height: settings.$max-height-large; } }
Description
Large container
Parameters
None.
Requires
- [variable]
small-width
- [variable]
max-width-large
- [variable]
max-height-large
header
@mixin header() { ... }
@mixin header() { padding: spacing.get('s4'); border-bottom: settings.$divider-size kib-divider.$divider-color-default solid; display: flex; align-items: center; @include media.query(min-md) { padding: settings.$large-spacing; } }
Description
Modal header
Parameters
None.
Requires
- [function]
get
- [variable]
divider-size
- [variable]
divider-color-default
- [variable]
large-spacing
title
@mixin title() { ... }
@mixin title() { @include typography.style-as('display-6'); padding-top: 0; margin-top: 0; margin-bottom: 0; margin-right: spacing.get('s4'); flex: 1; color: settings.$title-text-color; }
divider
use shadow instead of divider. Shadow is applied to the content div. Will remove @mixin divider
in next version
@mixin divider($position) { ... }
@mixin divider($position) { content: ''; background: settings.$divider-background; height: settings.$divider-size; position: absolute; right: 0; left: 0; z-index: settings.$divider-z-index; @if $position == 'top' { top: 0; } @if $position == 'bottom' { bottom: 0; } }
Description
Content divider
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$position | position of the divider | String | — none |
Requires
- [variable]
divider-background
- [variable]
divider-size
- [variable]
divider-z-index
Used by
- [mixin]
body
divider-cover
use shadow instead of divider. Shadow is applied to the content div. Will remove @mixin divider-cover
in next version
@mixin divider-cover() { ... }
@mixin divider-cover() { content: ''; background-image: linear-gradient( #{settings.$background-color}, #{settings.$background-color} 100% ); z-index: settings.$divider-cover-z-index; height: settings.$divider-size; flex-shrink: 0; }
Description
Divider cover
Parameters
None.
Requires
- [variable]
background-color
- [variable]
divider-cover-z-index
- [variable]
divider-size
Used by
- [mixin]
body-inner
body
use shadow instead of divider. Shadow is applied to the content div. Will remove @mixin body
in next version
@mixin body() { ... }
@mixin body() { padding: 0; @include typography.style-as('paragraph-1'); display: flex; flex: 1 1 0%; color: settings.$body-text-color; overflow: hidden; overflow-y: auto; position: relative; flex-direction: column; &::before { @include divider(top); } &::after { @include divider(bottom); } }
body-inner
use shadow instead of divider. Shadow is applied to the content div. Will remove @mixin body-inner
in next version
@mixin body-inner() { ... }
@mixin body-inner() { display: flex; flex-direction: column; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; &::before, &::after { @include divider-cover; } }
scrolling-shadow
@mixin scrolling-shadow() { ... }
@mixin scrolling-shadow() { // shadow cover, shadow cover, shadow, shadow background: settings.$content-background-gradient; background-repeat: no-repeat; background-color: settings.$background-color; background-size: settings.$content-background-size; background-attachment: settings.$content-background-attachment; background-position: settings.$content-background-position; }
Description
Scrolling shadow
Parameters
None.
Requires
- [variable]
background-color
- [variable]
content-background-size
- [variable]
content-background-attachment
- [variable]
content-background-position
content
@mixin content() { ... }
@mixin content() { padding: spacing.get('s4'); display: flex; flex: 1 1 0%; color: settings.$body-text-color; overflow: hidden; overflow-y: auto; position: relative; flex-direction: column; // Provide a fallback style for browsers that don't support :focus-visible */ &:focus { box-shadow: inset 0 0 settings.$focus-border settings.$focus-border settings.$focus-color; outline: none; } // Focus style for keyboard-focus on browsers that do support :focus-visible &:focus-visible { box-shadow: inset 0 0 settings.$focus-border settings.$focus-border settings.$focus-color; } // Remove the focus indicator on mouse-focus for browsers that do support :focus-visible &:focus:not(:focus-visible) { box-shadow: none; } &--has-controls { padding-bottom: 0; } // smartphones, touchscreens @media (hover: hover) and (pointer: coarse) { &:focus { box-shadow: none; } } @include media.query(min-md) { padding: spacing.get('s4', 's6', 's6'); &--has-controls { padding-bottom: 0; } } }
Description
Modal content container for spacing
Parameters
None.
Requires
- [function]
get
- [variable]
body-text-color
- [variable]
focus-border
- [variable]
focus-color
control
@mixin control() { ... }
@mixin control() { @include common.control; margin-left: auto; align-self: flex-start; // Top-align close button when header is multi lines &:focus { &::after { opacity: 1; } } &:focus-visible { &::after { opacity: 1; } } &:focus:not(:focus-visible) { &::after { opacity: 0; } } }
Description
Close control
Parameters
None.
actions
@mixin actions() { ... }
@mixin actions() { padding: spacing.get('s4'); @include media.query(min-md) { padding: spacing.get('s6'); } }
Variables
background-color
$background-color: color.get('ui-bg', 'primary') !default;
Description
Background color
Type
Color
border-radius
$border-radius: kib-core.dimensions-get('small') !default;
Description
Border radius
Type
Number
z-index
$z-index: 5001 !default;
divider-z-index
CDS-4902 replace it with overflown text shadow treatment
$divider-z-index: 10 !default;
divider-cover-z-index
CDS-4902 replace it with overflown text shadow treatment
$divider-cover-z-index: 11 !default;
max-width
$max-width: unit.rem(600px) !default;
Description
Max width
Type
Number
max-width-large
$max-width-large: unit.rem(1100px) !default;
Description
Max width on large screen
Type
Number
default-margins
$default-margins: kib-core.dimensions-get('default') * 2 !default;
Description
Modal defaut margin
Type
Number
small-margins
$small-margins: kib-core.dimensions-get('small') * 2 !default;
Description
Modal small margin
Type
Number
large-margins
$large-margins: unit.rem(32px) * 2 !default;
Description
Modal large margin
Type
Number
small-width
$small-width: calc(100% - #{$small-margins}) !default;
Description
Small width
Type
Number
Used by
- [mixin]
wrapper-inner
- [mixin]
large-wrapper-inner
- [mixin]
container-large
default-width
$default-width: calc(100% - #{$large-margins}) !default;
Description
Default width
Type
Number
Used by
- [mixin]
wrapper-inner
- [mixin]
large-wrapper-inner
- [mixin]
container
max-height-large
$max-height-large: calc(100vh - #{$large-margins}) !default;
Description
Max height
Type
Number
Used by
- [mixin]
wrapper-inner
- [mixin]
large-wrapper-inner
- [mixin]
container
- [mixin]
container-large
max-height-small
$max-height-small: calc(100% - #{$small-margins}) !default;
Description
Max height for small modal
Type
Number
Used by
- [mixin]
wrapper-inner
- [mixin]
large-wrapper-inner
focus-border
$focus-border: unit.rem(2px) !default;
Description
Focus border
Type
Number
focus-color
$focus-color: color.get('action', 'cta', 'primary', 'primary') !default;
title-text-color
$title-text-color: color.get('text', 'primary') !default;
body-text-color
$body-text-color: color.get('text', 'primary') !default;
duration
$duration: 0.2s !default;
large-spacing
$large-spacing: spacing.get('s6', 's6', 's4') !default;
divider-background
$divider-background: kib-divider.$divider-color-default !default;
divider-size
$divider-size: kib-divider.$divider-size-xs !default;
content-background-size
$content-background-size: 100% unit.rem(40px), 100% unit.rem(40px), 100% unit.rem(14px),
100% unit.rem(14px);
content-background-position
$content-background-position: 0 0, 0 100%, 0 0, 0 calc(100% - 0.2px);
content-background-attachment
$content-background-attachment: local, local, scroll, scroll;