Animation
Installation
yarn add @chewy/kib-foundationsImport
@use '~@chewy/kib-foundations/src/animation';Functions
get-properties
@function get-properties($theme: settings.$preferred-theme) { ... }@function get-properties($theme: settings.$preferred-theme) { $theme-map: common.get-theme-map(settings.$themes, $theme); @each $key, $value in $theme-map { $theme-map: map.set($theme-map, 'animation', $key, $value); } @return common.flatten-map($theme-map); }
Description
Returns a theme's animations as a flattened map with kebab-cased names
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$theme | Name of the theme | String | settings.$preferred-theme |
Returns
Map —Final flattened map
Requires
- [function]
get-theme-map - [function]
flatten-map - [variable]
themes
Used by
- [mixin]
custom-properties - [mixin]
custom-properties - [mixin]
custom-properties
-get-animation-value
@function -get-animation-value($theme: settings.$default-theme, $alias) { ... }@function -get-animation-value($theme: settings.$default-theme, $alias) { $theme-map: common.get-theme-map(settings.$themes, $theme); $has-key: map.has-key($theme-map, $path...); @if not $has-key { @error "Animation value (#{$path}) not found."; } @return map.get($theme-map, $path...); }
Description
Retrieves a animation style property value
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$theme | Name of the theme | String | settings.$default-theme |
$alias | Alias of animation unit | String | — none |
Returns
Number —Spacing value from the theme
Throws
Animation value (#{$path}) not found.
Requires
- [function]
get-theme-map - [function]
get - [variable]
themes
Used by
- [function]
-get-animation-property
-get-animation-property
@function -get-animation-property($path) { ... }@function -get-animation-property($path) { $theme-map: common.get-theme-map(settings.$themes, settings.$preferred-theme); @if not map.has-key($theme-map, $path...) { @error "The animation property (#{$path}) does not exist."; } $property: common.get-property-name('animation', $path...); $fallback: -get-animation-value(settings.$preferred-theme, $path...); @return string.unquote('var(#{$property}, #{$fallback})'); }
Description
Get a single animation style property definition.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$path | The map path to the desired property definition. | List | — none |
Returns
List or String or Number —Return the value of the animation property.
Throws
The animation property (#{$path}) does not exist.
Requires
- [function]
get-theme-map - [function]
get-property-name - [function]
-get-animation-value - [variable]
themes - [variable]
preferred-theme
-get-color
@function -get-color($theme: common.$default-theme, $colorset: settings.$default-colorset, $path...) { ... }@function -get-color($theme: common.$default-theme, $colorset: settings.$default-colorset, $path...) { $theme-map: common.get-theme-map(tokens.$chirp-themes, $theme); $is-default: $colorset == settings.$default-colorset; $has-key: map.has-key($theme-map, $colorset, $path...); @if $has-key == false { @if $is-default == false { @warn "Attempting to fallback to '#{settings.$default-colorset}' colors"; @return -get-color($theme, settings.$default-colorset, $path...); } @else { @error "Color not found: '#{$path}'"; } } @return map.get($theme-map, $colorset, $path...); }
Description
Retrieves a color from a theme
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$theme | The name of the theme to lookup | String | common.$default-theme |
$colorset | 'light' and 'dark' colorset | String | settings.$default-colorset |
$path... | Comma separated path to a theme's color | List | — none |
Returns
Color —Color value from the theme
Throws
Color not found:
Requires
- [function]
get-theme-map - [function]
get - [variable]
chirp-themes - [variable]
default-colorset
-get-valid-path
@function -get-valid-path($path...) { ... }@function -get-valid-path($path...) { $property: common.get-property-name($path...); @if map.has-key(settings.$deprecated-property-names, $property) { $new-path: map.get(settings.$deprecated-property-names, $property); @warn "Color '#{$path}' is deprecated, please switch to '#{$new-path}'"; @return $new-path; } @return $path; }
Description
Checks for deprecated color paths and if so, updates to the correct color path
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$path... | Comma separated path to a theme's color | List | — none |
Returns
List —Comma separated path to a theme's color
Requires
- [function]
get-property-name - [function]
get - [variable]
deprecated-property-names
get
@function get($path...) { ... }@function get($path...) { @return get-property($path...); }
Description
Creates a custom property reference from a color path
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$path... | Comma separated path to a theme's color | List | — none |
Returns
String —CSS var() function with a fallback color
Example
Basic usage
@use '~@chewy/kib-foundations/src/color';
.inverse-content {
background-color: color.get('ui-bg', '06');
color: color.get('text', 'inverse');
}Used by
- [mixin]
root-container - [mixin]
item-header-wrapper - [mixin]
item-trigger-wrapper - [mixin]
item-header-icon - [mixin]
item-content - [mixin]
item-content-open - [mixin]
item-content-closed - [mixin]
item-content-icon - [mixin]
item-close-button-focused - [mixin]
title - [mixin]
actions - [mixin]
actions-dismissible - [mixin]
action-trigger - [function]
-get-animation-value - [function]
-get-color - [function]
-get-valid-path - [function]
-get-themes - [mixin]
apply - [mixin]
root - [mixin]
variant - [mixin]
landscape-layout - [mixin]
landscape-condensed - [mixin]
full-border-radius - [mixin]
top-border-radius - [mixin]
root - [mixin]
eyebrow - [mixin]
author - [mixin]
author-image - [mixin]
link - [mixin]
transparent-landscape - [mixin]
landscape - [mixin]
transparent - [mixin]
root - [mixin]
landscape - [mixin]
transparent - [mixin]
landscape-transparent - [mixin]
font-styles-x - [function]
-get-fallback - [function]
-get-nested-fallback - [function]
-get-themes - [mixin]
root-container - [mixin]
list - [mixin]
item - [function]
height-calc - [mixin]
root - [mixin]
base - [mixin]
text - [mixin]
focus - [mixin]
halo - [mixin]
default-button-styles - [mixin]
button-styles - [mixin]
size-large - [mixin]
size-medium - [mixin]
size-small - [mixin]
root - [mixin]
base - [mixin]
siblings - [mixin]
default-button-styles - [mixin]
button-styles - [mixin]
size-medium - [mixin]
size-small - [mixin]
icon - [mixin]
icon-position-end - [mixin]
button-padding - [mixin]
base - [mixin]
header - [mixin]
controls - [mixin]
view-all-link - [mixin]
view-all-button - [mixin]
chip-deselected-styles - [mixin]
chip-action-disabled-styles - [mixin]
chip-choice-base-styles - [mixin]
chip-choice-selected-styles - [mixin]
chip-choice-active-styles - [mixin]
chip-choice-hover-styles - [mixin]
chip-choices-container-styles - [mixin]
chip-choices-child-styles - [mixin]
chip-selected-styles - [mixin]
container-styles - [mixin]
child-styles - [mixin]
choice-root - [mixin]
choice-append-container - [mixin]
range-label - [mixin]
rating-heading - [mixin]
rating-control - [mixin]
icon-focus-indicator - [mixin]
active-colors - [mixin]
inactive-colors - [mixin]
count - [mixin]
action - [mixin]
control-fill - [mixin]
label - [function]
-get-color - [function]
-get-valid-path - [function]
get-theme-colorset-properties - [mixin]
root - [mixin]
media-container - [mixin]
body - [mixin]
bottom - [mixin]
root - [mixin]
title - [mixin]
overline - [mixin]
content - [mixin]
source - [mixin]
swipe-affordance - [mixin]
text-shadow - [mixin]
has-source - [mixin]
controls-container - [mixin]
rotate-control - [mixin]
input-adornment - [mixin]
picker-calendar-container - [mixin]
picker-controls-bar - [mixin]
picker-toolbar - [mixin]
picker-toolbar-title - [mixin]
picker-toolbar-selected-date - [mixin]
picker-dialog-content - [mixin]
picker-dialog-content-input - [mixin]
sm-margin-styles - [mixin]
elevation - [mixin]
content - [mixin]
heading - [mixin]
messaging - [mixin]
heading-lg - [mixin]
root-container - [mixin]
label-required - [mixin]
field - [mixin]
icon-with-action - [mixin]
action-wrapper - [mixin]
action - [mixin]
error-message - [mixin]
error-icon - [mixin]
field-root-container - [mixin]
field-control - [mixin]
field-icon - [mixin]
field-label-content - [mixin]
field-messages-container - [mixin]
field-messages-common - [mixin]
autocomplete-menu - [mixin]
autocomplete-option - [mixin]
root-container - [mixin]
label - [mixin]
label-with-message - [mixin]
help - [mixin]
help-bottom - [mixin]
content - [mixin]
alert - [mixin]
icon - [mixin]
error-message - [mixin]
error-icon - [mixin]
group-label - [mixin]
group-messages-above - [mixin]
group-messages-below - [function]
get-theme-map - [mixin]
variation - [mixin]
nav - [mixin]
font-styles-x - [mixin]
icon-size - [mixin]
icon-circle - [mixin]
label - [mixin]
root-container - [mixin]
root-container-with-subtitle - [mixin]
image-wrapper - [mixin]
icon-wrapper - [mixin]
compact - [mixin]
subtitle - [mixin]
icon-container - [mixin]
dismiss-button - [mixin]
default - [function]
get-map-by-key-safe - [mixin]
root-container - [mixin]
icon - [mixin]
root-container - [mixin]
status - [mixin]
no-results - [mixin]
item - [mixin]
item-active - [mixin]
label - [mixin]
menu-link - [mixin]
menu-link-icon-wrapper - [mixin]
menu-group-link - [mixin]
menu-group-toggle - [mixin]
header - [mixin]
title - [mixin]
content - [mixin]
actions - [mixin]
base - [mixin]
content - [mixin]
title-container - [mixin]
title - [mixin]
metadata - [mixin]
description - [mixin]
attribute - [mixin]
base - [mixin]
content - [mixin]
pseudo-styles - [mixin]
navigation-tile-has-media - [mixin]
navigation-tile-vertical - [mixin]
navigation-tile-vertical-content - [mixin]
normalize-blocks - [mixin]
normalize-text - [mixin]
normalize-lists - [mixin]
normalize-code - [mixin]
root-container - [mixin]
list-item-previous - [mixin]
list-item-next - [mixin]
card-root - [mixin]
avatar-wrapper - [mixin]
caption - [mixin]
list-item - [mixin]
badge - [mixin]
icon-wrapper - [mixin]
icon-restricted - [mixin]
icon-promotion - [mixin]
icon-chewy-plus - [mixin]
canvas-landscape-extended - [mixin]
canvas-content - [mixin]
choices-landscape - [mixin]
actions-flat - [mixin]
label - [mixin]
flag - [mixin]
canvas - [mixin]
append - [mixin]
root-container - [mixin]
autoship-logo-condensed - [mixin]
row - [mixin]
append-content - [mixin]
root-container - [mixin]
count-wrapper - [mixin]
rating-display - [mixin]
row - [mixin]
sponsor - [mixin]
subtitle - [mixin]
title - [mixin]
content - [mixin]
icon - [mixin]
button - [mixin]
card-heading - [mixin]
card-heading-airy - [mixin]
card-content - [mixin]
card-content-airy - [mixin]
label - [mixin]
content - [mixin]
detail - [mixin]
stacked-detail-airy - [mixin]
stacked-detail - [mixin]
avatar-airy - [mixin]
avatar - [mixin]
name-airy - [mixin]
metadata-airy - [mixin]
name - [mixin]
metadata - [mixin]
root-container - [mixin]
count-wrapper - [mixin]
action - [mixin]
root-container - [mixin]
icon-container - [mixin]
input-container - [mixin]
helper-text - [mixin]
title - [mixin]
read-only-input - [mixin]
header-wrapper - [mixin]
header-small - [mixin]
subheading - [mixin]
card-root - [mixin]
card-disabled - [mixin]
selected - [mixin]
selected-hover - [mixin]
selected-pressed - [mixin]
append-container-indent - [mixin]
header - [mixin]
title-icon - [mixin]
control-back - [mixin]
content-shadows - [mixin]
content - [mixin]
content-single-panel-actions - [mixin]
step-content - [mixin]
step-actions - [mixin]
root-container - [mixin]
base - [mixin]
base-styles - [mixin]
text-skeleton - [mixin]
label - [mixin]
actions - [mixin]
actions-stacked - [mixin]
action - [function]
-get-themes - [mixin]
standalone-link - [mixin]
standalone-link-icon-svg - [mixin]
standalone-link-label - [mixin]
heading - [mixin]
group - [mixin]
text-swatch - [mixin]
text-swatch-header - [mixin]
text-swatch-details - [mixin]
selected - [mixin]
unavailable - [mixin]
both-selected-unavailable - [mixin]
indeterminate - [mixin]
both-selected-indeterminate - [mixin]
unavailable-text-with-strikethru - [mixin]
unavailable-text-indeterminate - [mixin]
image-swatch - [mixin]
image-swatch-header - [mixin]
image-strikethrough - [mixin]
swatch-shared-styles - [mixin]
wrap-layout - [mixin]
nav - [mixin]
nav-list - [mixin]
trigger - [mixin]
trigger-active - [mixin]
tag-variant - [mixin]
secondary-variant - [mixin]
button-variant - [mixin]
button-variant-hover - [mixin]
tooltip - [mixin]
trigger - [mixin]
content - [function]
get-weight - [function]
get-type-style-with-fallback - [function]
get-type-style-variant-weight - [function]
-get-type-style-value - [mixin]
style-as - [mixin]
root-container - [mixin]
meta-data - [mixin]
item - [mixin]
item-content - [function]
-get-spacing-value - [mixin]
header - [mixin]
title-icon - [mixin]
control-back - [mixin]
content-shadows - [mixin]
content-single-panel-actions - [mixin]
step-content - [mixin]
step-content-with-sheet - [mixin]
step-actions - [mixin]
base - [mixin]
item-base
-get-themes
@function -get-themes($tokens) { ... }@function -get-themes($tokens) { $themes: (); @each $name, $theme in $tokens { $themes: map.set($themes, $name, map.get($theme, 'animation')); } @return $themes; }
Variables
preferred-theme
$preferred-theme: common.$preferred-theme !default;Description
Name of the preferred theme to look for properties first. If not found it will fallback to common.$default-theme.
Type
String
Used by
- [function]
-get-animation-property - [mixin]
apply - [function]
get-type-style-with-fallback - [function]
-get-type-style-property
page-entry-movement
$page-entry-movement: unit.rem(170px);Description
Page top starting position
Type
Number
page-fade-transition-duration
$page-fade-transition-duration: 1000ms !default;Description
Page fade transitions duration
Type
Number
page-slide-transition-duration
$page-slide-transition-duration: 500ms !default;Description
Page slide Group transitions duration
Type
Number
themes
$themes: (...);$themes: -get-themes(tokens.$chirp-animation);
Description
Map of animation themes
Type
Map
Used by
- [function]
get-properties - [function]
-get-animation-value - [function]
-get-animation-property - [function]
-get-themes - [mixin]
apply - [function]
get-properties - [function]
get - [function]
-get-fallback - [function]
-get-nested-fallback - [function]
-get-themes - [function]
get-theme-map - [function]
-get-themes - [function]
get-type-style-with-fallback - [function]
get-type-style-variant-weight - [function]
get-properties - [function]
-get-type-style-value - [function]
-get-type-style-property - [function]
-get-spacing-value - [function]
get-properties
aliases
$aliases: (...);$aliases: ();
Description
Map of animation style aliases to facilitate deprecation and removal of animation styles Currently a placeholder.
Type
Map
Used by
- [mixin]
style-as
deprecated-property-names
$deprecated-property-names: (...);$deprecated-property-names: ();
Mixins
custom-properties
@mixin custom-properties($theme: 'base', $deprecated: false, $overrides) { ... }@mixin custom-properties($theme: 'base', $deprecated: false, $overrides) { $animation-properties: functions.get-properties($theme); @if $overrides { $animation-properties: map.deep-merge($animation-properties, $overrides); } @each $key, $value in $animation-properties { #{common.get-property-name($key)}: $value; } }
Description
Generates CSS Custom Properties for a Chirp theme's animation tokens
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$theme | The name of the theme to look up | String | 'base' |
$deprecated | Includes custom properties for deprecated animation styles | Bool | false |
$overrides | Map that overrides any matching values within the theme | Map | — none |
Example
Apply all available properties to the :root of the page
@use '~@chewy/kib-foundations/src/animation';
:root {
@include animation.custom-properties;
}Apply properties to a selector
@use '~@chewy/kib-foundations/src/animation';
.chirp-animation {
@include animation.custom-properties;
}Override a animation property
@use '~@chewy/kib-foundations/src/animation';
.chirp-animation-custom {
@include animation.custom-properties($overrides: ('text-typeface': Roboto));
}Requires
- [function]
get-properties - [function]
get-property-name
apply
@mixin apply($name, $variant, $alternate) { ... }@mixin apply($name, $variant, $alternate) { $variant: functions.get-last-item($animation-style); $animation-style: functions.remove-last-item($animation-style); $animations: common.get-theme-map(settings.$themes, settings.$preferred-theme); $alias: $animation-style; $style: map.get($animations, $alias...); $not-rendered: true; @each $name in map.keys($style) { $is-variant-match: if(str-index($name, '-#{$variant}'), true, false); $is-subtle: if(str-index($name, '-subtle'), true, false); $is-standard: if(str-index($name, '-standard'), true, false); $value: map.get($style, $name); $valueType: ''; @if $is-variant-match { @if $is-subtle { $valueType: common.str-replace($name, '-subtle', ''); } @else if $is-standard { $valueType: common.str-replace($name, '-standard', ''); } @else { $valueType: $name; } } @if $valueType == 'duration' or $valueType == 'function' { $fallback: #{map.get($style, $name)}; $value: string.unquote('var(#{$value}, #{$fallback})'); --animation-press-scale-#{$valueType}: #{$value}; } @else_if ($valueType == "amount" or $valueType == "amount-hover") and $is-variant-match { $property: common.get-property-name('animation', append($alias, $name)); $fallback: ''; $value: string.unquote('var(#{$property}, #{$fallback})'); --animation-press-scale-#{$valueType}: #{$value}; } } $animation-press-scale-amount-standard: 0; $animation-press-scale-amount-subtle: 0; $animation-press-scale-amount-standard-hover: 0; $animation-press-scale-amount-subtle-hover: 0; @each $name in map.keys($style) { $is-variant-match: if(str-index($name, '-#{$variant}'), true, false); $is-variant-match-string: if(str-index($name, '-#{$variant}'), 'true', 'false'); $is-subtle: if(str-index($name, '-subtle'), true, false); $is-standard: if(str-index($name, '-standard'), true, false); $value: map.get($style, $name); $valueType: ''; @if $is-variant-match { @if $is-subtle { $valueType: common.str-replace($name, '-subtle', ''); } @else if $is-standard { $valueType: common.str-replace($name, '-standard', ''); } @else { $valueType: $name; } } @if ($is-subtle or $is-standard) { @if $is-variant-match { --animation-press-scale-#{$valueType}: #{map.get($style, $name)}; } } @else { --animation-press-scale-#{$name}: #{map.get($style, $name)}; } } // duration transition: transform var(--animation-press-scale-duration, #{map.get($style, 'duration')}) var(--animation-press-scale-function, #{map.get($style, 'function')}); @media (hover: hover) and (pointer: fine) { &:hover { transform: scale3d( var(--animation-press-scale-amount-hover), var(--animation-press-scale-amount-hover), 1 ); } } // normal &:active { transform: scale3d(var(--animation-press-scale-amount), var(--animation-press-scale-amount), 1); } // reduced motion @media (prefers-reduced-motion: reduce) { transition: none; } @each $name in map.keys($style) { $is-variant-match: if(str-index($name, '-#{$variant}'), true, false); $is-variant-match-string: if(str-index($name, '-#{$variant}'), 'true', 'false'); $is-subtle: if(str-index($name, '-subtle'), true, false); $is-standard: if(str-index($name, '-standard'), true, false); $value: map.get($style, $name); $valueType: ''; $newNewName: str-quote(common.str-replace(str-quote($name), '-subtle', '')); @if $is-variant-match { @if $is-subtle { $valueType: common.str-replace($name, '-subtle', ''); } @else if $is-standard { $valueType: common.str-replace($name, '-standard', ''); } @else { $valueType: $name; } } } }
Description
Generate styles using custom properties from a defined animation style.
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$name | The name of the animation style | String | — none |
$variant | The variant name of the animation style | String | — none |
$alternate | Applies the deprecated alternate animation style definition | Boolean | — none |
Example
Apply styles for a animation style definition
@use '~@chewy/kib-foundations/src/animation';
.my-custom-class {
@include animation.style-as('display-1');
}Apply styles for a variant animation style
@use '~@chewy/kib-foundations/src/animation';
.my-custom-class {
@include animation.style-as('editorial-heading-2', 'strong');
}Apply styles for a deprecated alternate animation style definition
@use '~@chewy/kib-foundations/src/animation';
.my-custom-class {
@include animation.style-as('display-1', $alternate: true);
}Requires
- [function]
get-theme-map - [function]
get - [function]
str-replace - [function]
get-property-name - [variable]
themes - [variable]
preferred-theme
page-entry-common
@mixin page-entry-common($delay: '0') { ... }@mixin page-entry-common($delay: '0') { animation-delay: $delay; animation-fill-mode: both; }
Description
Page entry shared attributes
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$delay | delay preset | Number | '0' |
Requires
- [variable]
delay
Used by
- [mixin]
page-entry-fade-up - [mixin]
page-entry-fade-in - [mixin]
page-entry-slide-up
page-entry-fade-up
@mixin page-entry-fade-up($delay: '0', $fade-duration: 'settings.$fade-transition-duration', $slide-duration: 'settings.$slide-transition-duration') { ... }@mixin page-entry-fade-up($delay: '0', $fade-duration: 'settings.$fade-transition-duration', $slide-duration: 'settings.$slide-transition-duration') { @include page-entry-common($delay); animation-name: kib-animation-page-entry-fade-in, kib-animation-page-entry-slide-up; animation-duration: $fade-duration, $slide-duration; @media (prefers-reduced-motion: reduce) { animation: none; } }
Description
Page entry fade up transition
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$delay | delay preset | Number | '0' |
$fade-duration | fade duration preset | Number | 'settings.$fade-transition-duration' |
$slide-duration | slide duration preset | Number | 'settings.$slide-transition-duration' |
Requires
- [mixin]
page-entry-common - [variable]
delay
page-entry-fade-in
@mixin page-entry-fade-in($delay: '0', $duration: 'settings.$fade-transition-duration') { ... }@mixin page-entry-fade-in($delay: '0', $duration: 'settings.$fade-transition-duration') { @include page-entry-common($delay); animation-name: kib-animation-page-entry-fade-in; animation-duration: $duration; @media (prefers-reduced-motion: reduce) { animation: none; } }
Description
Page entry fade in transition
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$delay | delay preset | Number | '0' |
$duration | duration preset | Number | 'settings.$fade-transition-duration' |
Requires
- [mixin]
page-entry-common - [variable]
delay - [variable]
duration
page-entry-slide-up
@mixin page-entry-slide-up($delay: '0', $duration: 'settings.$slide-transition-duration') { ... }@mixin page-entry-slide-up($delay: '0', $duration: 'settings.$slide-transition-duration') { @include page-entry-common($delay); animation-name: kib-animation-page-entry-slide-up; animation-duration: $duration; @media (prefers-reduced-motion: reduce) { animation: none; } }
Description
Page entry slide up transition
Parameters
| parameter Name | parameter Description | parameter Type | parameter Default value |
|---|---|---|---|
$delay | delay preset | Number | '0' |
$duration | duration preset | Number | 'settings.$slide-transition-duration' |
Requires
- [mixin]
page-entry-common - [variable]
delay - [variable]
duration