Skip to content

Commit c30c97f

Browse files
authored
Use flexbox gap (#2133)
1 parent 0e0c2b7 commit c30c97f

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

.changeset/curvy-ears-rule.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': patch
3+
---
4+
5+
Button Group and Inline Lists now use `gap` properties instead of margin, removing the need for negative margins on the parent element

src/objects/button-group/button-group.scss

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77
/// changing to Flexbox Gap once browser support is better in the future).
88

99
.o-button-group {
10-
--gap: #{size.$spacing-gap-button-group-default};
11-
1210
display: flex;
1311
flex-wrap: wrap;
14-
margin: calc(var(--gap) / -2); /* 1 */
15-
16-
> * {
17-
margin: calc(var(--gap) / 2); /* 1 */
18-
}
12+
gap: size.$spacing-gap-button-group-default;
1913
}
2014

2115
///

src/objects/list/list.scss

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,14 @@
1616
}
1717

1818
/// Modifier: Inline
19-
///
20-
/// By default, this uses negative margins on the sides to account for extra
21-
/// margin between child elements. This allows child elements to reach the edges
22-
/// of their parent while maintaining consistent gaps between.
23-
///
24-
/// This would be a _lot_ more elegant if it used the Flexbox-compatible `gap`
25-
/// property. But unfortunately there is no way to test for that without false
26-
/// positives as of this writing.
27-
///
28-
/// @link https://medium.com/@schofeld/mind-the-flex-gap-c9cd1b4b35d8
29-
/// @link https://github.com/w3c/csswg-drafts/issues/3559
3019

3120
.o-list--inline {
21+
column-gap: size.$spacing-list-inline-gap;
3222
display: flex;
3323
flex-wrap: wrap;
34-
margin-inline: math.div(size.$spacing-list-inline-gap, -2);
3524
}
3625

37-
.o-list--inline > * {
38-
margin-inline: math.div(size.$spacing-list-inline-gap, 2);
39-
}
26+
/// Modifier: Columns
4027

4128
@for $i from 2 through 3 {
4229
.o-list--#{$i}-column {

0 commit comments

Comments
 (0)