Skip to content

Commit adae056

Browse files
authored
Add o-container__pad class (#1938)
This PR adds the new `o-container__pad` class, which behaves similarly to the existing `o-container__fill` & `o-container__fill-pad` classes, adding the standard container inline padding to a container child. Fixes #1935
1 parent dbe0b72 commit adae056

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

.changeset/cyan-lies-arrive.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+
Add `o-container__pad` class

src/objects/container/container.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040
}
4141
}
4242

43+
/**
44+
* Child elements that need a bit of inline padding to avoid the viewport edge.
45+
*/
46+
47+
.o-container__pad {
48+
.o-container--pad &,
49+
.o-container--pad-inline & {
50+
@include spacing.fluid-padding-inline;
51+
}
52+
}
53+
4354
/**
4455
* Child elements intended to "fill" the container width. This negates any
4556
* inline padding and border radii.

src/objects/container/container.stories.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ There are times when a child element should attempt to fill the container conten
136136

137137
Two child element classes exist for this purpose:
138138

139+
- `o-container__pad`: Adds the standard container padding to a child element.
139140
- `o-container__fill`: Negates any inline padding so the element will reach the edges of the content container's padding.
140141
- `o-container__fill-pad`: Also applies padding to the element so its content will align with that of the container.
141142

src/objects/container/demo/fill.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
<p>.c-card.c-card--contained</p>
1313
{% endblock %}
1414
{% endembed %}
15+
<p>This card gains the default container padding:</p>
16+
{% embed '@cloudfour/components/card/card.twig' with {
17+
class: 'c-card--contained o-container__pad'
18+
} only %}
19+
{% block content %}
20+
<p>.c-card.c-card--contained.o-container__pad</p>
21+
{% endblock %}
22+
{% endembed %}
1523
<p>This card attempts to fill the container, padding included:</p>
1624
{% embed '@cloudfour/components/card/card.twig' with {
1725
class: 'c-card--contained o-container__fill'

0 commit comments

Comments
 (0)