Skip to content

Commit a8fa1df

Browse files
authored
Add clearfix utility (#1949)
1 parent 9f9a23b commit a8fa1df

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

.changeset/cool-dolls-raise.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 clearfix utility

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="u-clearfix" style="border: 3px solid black; padding: 15px">
2+
<div style="width: 500px; height: 500px; background: green; float: right">I'm floating!</div>
3+
</div>

src/utilities/display/display.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@
77
.u-hidden-visually {
88
@include a11y.sr-only($important: true);
99
}
10+
11+
/**
12+
* Clearfix: forces a container to expand to fit floated children
13+
* https://www.cssmojo.com/latest-new-clearfix-so-far/
14+
*/
15+
.u-clearfix::after {
16+
clear: both;
17+
content: '';
18+
display: block;
19+
}

src/utilities/display/display.stories.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Canvas, Meta, Story } from '@storybook/addon-docs';
22
import hiddenVisuallyDemo from './demo/hidden-visually.twig';
3+
import clearfixDemo from './demo/clearfix.twig';
34

45
<Meta title="Utilities/Display" />
56

@@ -21,3 +22,11 @@ In this example, the link will include text when read aloud:
2122
<Canvas>
2223
<Story name="Hidden Visually">{hiddenVisuallyDemo}</Story>
2324
</Canvas>
25+
26+
## Clearfix
27+
28+
The `u-clearfix` class forces a container to expand to fit floated children.
29+
30+
<Canvas>
31+
<Story name="Clearfix">{clearfixDemo}</Story>
32+
</Canvas>

0 commit comments

Comments
 (0)