Skip to content

Commit e099664

Browse files
authored
Add u-inline-block utility (#1974)
1 parent 2ed8b97 commit e099664

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

.changeset/strange-toys-bake.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 `u-inline-block` utility
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +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>
1+
<div class="u-clearfix u-border-medium u-pad-1">
2+
<div class="u-border-medium u-pad-1 u-size-inline-1/2" style="float: right;">Im floating!</div>
33
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="u-border-md u-pad-1" style="max-width: 11em;">
2+
Look how the last two words <span class="u-inline-block">stay together</span>
3+
</div>

src/utilities/display/display.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
@use '../../mixins/a11y';
22

3-
/**
4-
* Hide from everything but assistive devices.
5-
*/
6-
3+
/// Hide from everything but assistive devices.
74
.u-hidden-visually {
85
@include a11y.sr-only($important: true);
96
}
107

11-
/**
12-
* Clearfix: forces a container to expand to fit floated children
13-
* https://www.cssmojo.com/latest-new-clearfix-so-far/
14-
*/
8+
/// Clearfix: forces a container to expand to fit floated children
9+
/// @link https://www.cssmojo.com/latest-new-clearfix-so-far/
1510
.u-clearfix::after {
1611
clear: both;
1712
content: '';
1813
display: block;
1914
}
15+
16+
/// Set `display` to `inline-block`
17+
.u-inline-block {
18+
display: inline-block;
19+
}

src/utilities/display/display.stories.mdx

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

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

@@ -30,3 +31,11 @@ The `u-clearfix` class forces a container to expand to fit floated children.
3031
<Canvas>
3132
<Story name="Clearfix">{clearfixDemo}</Story>
3233
</Canvas>
34+
35+
## Inline Block
36+
37+
The `u-inline-block` class sets the `display` property to `inline-block`. This can be used to discourage inline elements from breaking across multiple lines.
38+
39+
<Canvas>
40+
<Story name="Inline Block">{inlineBlockDemo}</Story>
41+
</Canvas>

0 commit comments

Comments
 (0)