diff --git a/.changeset/fresh-houses-smell.md b/.changeset/fresh-houses-smell.md new file mode 100644 index 000000000..ef9130771 --- /dev/null +++ b/.changeset/fresh-houses-smell.md @@ -0,0 +1,5 @@ +--- +'@cloudfour/patterns': minor +--- + +Add layout modifier to the List object diff --git a/src/mixins/_fluid.scss b/src/mixins/_fluid.scss index 13c5bdae9..d63f31a3c 100644 --- a/src/mixins/_fluid.scss +++ b/src/mixins/_fluid.scss @@ -40,6 +40,20 @@ * Fluid properties */ +@mixin column-gap($min-width, $max-width, $min, $max, $include-min: true) { + @if $include-min { + column-gap: $min; + } + + @media (min-width: $min-width) { + column-gap: fluid-calc($min-width, $max-width, $min, $max); + } + + @media (min-width: $max-width) { + column-gap: $max; + } +} + @mixin font-size($min-width, $max-width, $min, $max) { font-size: $min; diff --git a/src/objects/list/list.scss b/src/objects/list/list.scss index 1cff2e52e..3d70c3ceb 100644 --- a/src/objects/list/list.scss +++ b/src/objects/list/list.scss @@ -1,5 +1,8 @@ @use "sass:math"; +@use "../../compiled/tokens/scss/breakpoint"; @use "../../compiled/tokens/scss/size"; +@use '../../mixins/fluid'; +@use '../../mixins/media-query'; /** * Override browser defaults. Note that this means it's very important to @@ -40,3 +43,17 @@ margin-left: math.div(size.$spacing-list-inline-gap, 2); margin-right: math.div(size.$spacing-list-inline-gap, 2); } + +@for $i from 2 through 3 { + .o-list--#{$i}-column { + @include media-query.breakpoint-classes($from: s, $to: xl) { + columns: #{$i}; + @include fluid.column-gap( + breakpoint.$s, + breakpoint.$xl, + size.$spacing-gap-fluid-min, + size.$spacing-gap-fluid-max + ); + } + } +} diff --git a/src/objects/list/list.stories.mdx b/src/objects/list/list.stories.mdx index f45c5c4c9..3490b9fb5 100644 --- a/src/objects/list/list.stories.mdx +++ b/src/objects/list/list.stories.mdx @@ -12,6 +12,7 @@ const tagNames = ['ul', 'ol']; - {(args) => template(args)} + + {(args) => template(args)} + ## Inline List @@ -44,3 +47,13 @@ The `o-list--inline` modifier arranges items in a horizontal row, wrapping to ne {(args) => template(args)} + +## Columns + +Lists can be displayed in multiple columns using a modifier class. Use the format `o-list--X-column@Y`, where `X` is the desired column count (from 2 to 3) and `Y` is the desired [breakpoint](/docs/design-tokens-breakpoint--page) (from `s` to `xl`). + + + + {(args) => template(args)} + +