Skip to content

Commit 38ab8b0

Browse files
authored
More consistent column gaps (#1896)
1 parent 43ef700 commit 38ab8b0

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

.changeset/sweet-pumpkins-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Made Cloud Cover column gaps consistent with the Deck layout object to improve visual relationship of `content` and `extra` blocks

src/components/cloud-cover/cloud-cover.scss

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
@use '../../compiled/tokens/scss/breakpoint';
33
@use '../../compiled/tokens/scss/color';
44
@use '../../compiled/tokens/scss/size';
5-
@use '../../mixins/ms';
65
@use '../../mixins/fluid';
6+
@use '../../mixins/spacing';
77

88
/// Setting the breakpoint to `m` (40em) results in an awkward layout
99
/// when using the Subscribe form in the `extra` slot. However, setting
@@ -13,14 +13,22 @@
1313

1414
$_cloud-cover-breakpoint: 45em;
1515

16-
/// We can't use `grid-gap` exclusively due to some containers only being present
17-
/// some of the time, so we re-use this value for `grid-gap` and for `margin`
18-
/// later on.
16+
/// We can't use `gap` exclusively due to some containers only being present
17+
/// some of the time, so we re-use this value for `gap` and for `margin` later
18+
/// on.
1919
///
2020
/// @type Number
2121
/// @access private
2222

23-
$_gap: ms.step(1);
23+
$_row_gap: size.$rhythm-default;
24+
25+
/// At wider sizes we want to add a bit more horizontal/inline space between
26+
/// content sections.
27+
///
28+
/// @type Number
29+
/// @access private
30+
31+
$_column_gap: spacing.$fluid-gap;
2432

2533
/// The ideal cloud size is a factor of both the viewport width and height, and
2634
/// we size other elements based on factors of this value. This function returns
@@ -146,8 +154,8 @@ $_gap: ms.step(1);
146154

147155
.c-cloud-cover__inner {
148156
align-items: center;
157+
column-gap: $_column_gap;
149158
display: grid;
150-
grid-column-gap: $_gap;
151159
grid-template-areas:
152160
'.'
153161
'scene'
@@ -242,7 +250,7 @@ $_gap: ms.step(1);
242250
*/
243251

244252
@media (width < $_cloud-cover-breakpoint) {
245-
margin-block-start: $_gap;
253+
margin-block-start: $_row_gap;
246254
}
247255
}
248256

@@ -267,7 +275,7 @@ $_gap: ms.step(1);
267275

268276
@media (width < $_cloud-cover-breakpoint) {
269277
block-size: _cloud-space(2);
270-
margin-block-end: $_gap;
278+
margin-block-end: $_row_gap;
271279
}
272280

273281
/**
@@ -295,7 +303,7 @@ $_gap: ms.step(1);
295303

296304
@media (width < $_cloud-cover-breakpoint) {
297305
block-size: _cloud-space(3);
298-
margin-block: $_gap 0;
306+
margin-block: $_row_gap 0;
299307
}
300308

301309
/**

src/components/cloud-cover/demo/extra.twig

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22
{% block heading %}
33
{% include '@cloudfour/components/heading/heading.twig' with {
44
level: -2,
5-
content: 'What We Do'
5+
content: 'Articles'
66
} only %}
77
{% endblock %}
88
{% block content %}
99
<p>
10-
We
11-
{% include '@cloudfour/components/icon/icon.twig' with {
12-
name: 'heart',
13-
title: 'love',
14-
inline: true
15-
} only %}
16-
<span class="u-hidden-visually">love</span>
17-
solving tough puzzles through design and&nbsp;code.
10+
Sharing what we learn exploring the frontier of the web.
1811
</p>
1912
{% endblock %}
2013
{% block extra %}

src/mixins/_spacing.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ $fluid-spacing-inline-negative: fluid.fluid-clamp(
2929
$fluid-spacing-breakpoint-min,
3030
$fluid-spacing-breakpoint-max
3131
);
32+
$fluid-gap: fluid.fluid-clamp(
33+
size.$spacing-gap-fluid-min,
34+
size.$spacing-gap-fluid-max,
35+
$fluid-spacing-breakpoint-min,
36+
$fluid-spacing-breakpoint-max
37+
);
3238

3339
@mixin fluid-padding-block() {
3440
padding-block: $fluid-spacing-block;

src/objects/deck/deck.scss

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
@use '../../compiled/tokens/scss/breakpoint';
22
@use '../../compiled/tokens/scss/size';
3-
@use '../../mixins/fluid';
43
@use '../../mixins/media-query';
54
@use '../../mixins/spacing';
65

76
/**
87
* 1. If horizontal items are shown at the wrong column count, they will appear
98
* to break the grid. This rule keeps items densely packed so it will always
109
* appear visually correct.
11-
*
12-
* @todo Use progressive enhancement so older browsers get a minimal fallback.
1310
*/
1411

1512
.o-deck {
1613
display: grid;
1714
grid-auto-flow: dense; /* 1 */
18-
grid-gap: fluid.fluid-clamp(
19-
size.$spacing-gap-fluid-min,
20-
size.$spacing-gap-fluid-max,
21-
breakpoint.$s,
22-
breakpoint.$xl
23-
);
15+
grid-gap: spacing.$fluid-gap;
2416

2517
/**
2618
* We define a media query for our initial grid so child elements will flex

0 commit comments

Comments
 (0)