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/cool-dolls-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': minor
---

Add clearfix utility
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/utilities/display/demo/clearfix.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="u-clearfix" style="border: 3px solid black; padding: 15px">
<div style="width: 500px; height: 500px; background: green; float: right">I'm floating!</div>
</div>
10 changes: 10 additions & 0 deletions src/utilities/display/display.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@
.u-hidden-visually {
@include a11y.sr-only($important: true);
}

/**
* Clearfix: forces a container to expand to fit floated children
* https://www.cssmojo.com/latest-new-clearfix-so-far/
*/
.u-clearfix::after {
clear: both;
content: '';
display: block;
}
9 changes: 9 additions & 0 deletions src/utilities/display/display.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs';
import hiddenVisuallyDemo from './demo/hidden-visually.twig';
import clearfixDemo from './demo/clearfix.twig';

<Meta title="Utilities/Display" />

Expand All @@ -21,3 +22,11 @@ In this example, the link will include text when read aloud:
<Canvas>
<Story name="Hidden Visually">{hiddenVisuallyDemo}</Story>
</Canvas>

## Clearfix

The `u-clearfix` class forces a container to expand to fit floated children.

<Canvas>
<Story name="Clearfix">{clearfixDemo}</Story>
</Canvas>