Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-houses-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': minor
---

Add layout modifier to the List object
14 changes: 14 additions & 0 deletions src/mixins/_fluid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
17 changes: 17 additions & 0 deletions src/objects/list/list.scss
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
);
}
}
}
15 changes: 14 additions & 1 deletion src/objects/list/list.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const tagNames = ['ul', 'ol'];

<Meta
title="Objects/List"
parameters={{ docs: { inlineStories: false } }}
argTypes={{
class: { type: { name: 'string' } },
items: { type: { name: 'array' }, defaultValue: defaultItems },
Expand All @@ -32,7 +33,9 @@ The `o-list` object presents list items in a straightforward and unopinionated m
By default, `o-list` removes default spacing and list item decorators:

<Canvas>
<Story name="Default">{(args) => template(args)}</Story>
<Story name="Default" height="200px">
{(args) => template(args)}
</Story>
</Canvas>

## Inline List
Expand All @@ -44,3 +47,13 @@ The `o-list--inline` modifier arranges items in a horizontal row, wrapping to ne
{(args) => template(args)}
</Story>
</Canvas>

## 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`).

<Canvas>
<Story name="Column" args={{ class: 'o-list--3-column@l' }}>
{(args) => template(args)}
</Story>
</Canvas>