Skip to content

Commit 30641c9

Browse files
CSS text utility classes (#1499)
This PR introduces two text utility CSS classes: - `u-text-no-wrap` - `u-text-action`
1 parent fb5bd17 commit 30641c9

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

.changeset/old-trees-compare.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 CSS text utility classes

src/utilities/text/demo/color.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% embed '@cloudfour/objects/container/container.twig' with {
2+
class: 'o-container--pad'
3+
} only %}
4+
{% block content %}
5+
<p>This is default text.</p>
6+
<p class="u-text-action">This is text that has the utility class applied.</p>
7+
{% endblock %}
8+
{% endembed %}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% embed '@cloudfour/objects/container/container.twig' with {
2+
class: 'o-container--pad'
3+
} only %}
4+
{% block content %}
5+
<div style="padding-right: 50%">
6+
<div class="u-pad-n1" style="border: 2px solid">
7+
<p>This text will wrap: <strong>The quick brown
8+
fox jumps over the lazy dog.</strong></p>
9+
</div>
10+
</div>
11+
{% endblock %}
12+
{% endembed %}
13+
{% embed '@cloudfour/objects/container/container.twig' with {
14+
class: 'o-container--pad'
15+
} only %}
16+
{% block content %}
17+
<div style="padding-right: 50%">
18+
<div class="u-pad-n1" style="border: 2px solid">
19+
<p>This text will not wrap: <strong class="u-text-no-wrap">The quick brown
20+
fox jumps over the lazy dog.</strong></p>
21+
</div>
22+
</div>
23+
{% endblock %}
24+
{% endembed %}

src/utilities/text/text.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use "../../compiled/tokens/scss/color";
2+
3+
.u-text-no-wrap {
4+
white-space: nowrap !important;
5+
}
6+
7+
.u-text-action {
8+
color: var(--theme-color-text-action) !important;
9+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Story, Canvas, Meta } from '@storybook/addon-docs/blocks';
2+
// The '!!raw-loader!' syntax is a non-standard, Webpack-specific, syntax.
3+
// See: https://github.com/webpack-contrib/raw-loader#examples
4+
// For now, it seems likely Storybook is pretty tied to Webpack, therefore, we are
5+
// okay with the following Webpack-specific raw loader syntax. It's better to leave
6+
// the ESLint rule enabled globally, and only thoughtfully disable as needed (e.g.
7+
// within a Storybook docs page and not within an actual component).
8+
// This can be revisited in the future if Storybook no longer relies on Webpack.
9+
// eslint-disable-next-line @cloudfour/import/no-webpack-loader-syntax
10+
import noWrapDemoSource from '!!raw-loader!./demo/nowrap.twig';
11+
import noWrapDemo from './demo/nowrap.twig';
12+
// The '!!raw-loader!' syntax is a non-standard, Webpack-specific, syntax.
13+
// See: https://github.com/webpack-contrib/raw-loader#examples
14+
// For now, it seems likely Storybook is pretty tied to Webpack, therefore, we are
15+
// okay with the following Webpack-specific raw loader syntax. It's better to leave
16+
// the ESLint rule enabled globally, and only thoughtfully disable as needed (e.g.
17+
// within a Storybook docs page and not within an actual component).
18+
// This can be revisited in the future if Storybook no longer relies on Webpack.
19+
// eslint-disable-next-line @cloudfour/import/no-webpack-loader-syntax
20+
import colorDemoSource from '!!raw-loader!./demo/color.twig';
21+
import colorDemo from './demo/color.twig';
22+
23+
<Meta title="Utilities/Text" />
24+
25+
# Text
26+
27+
Utilities for controlling text properties.
28+
29+
## White-space nowrap
30+
31+
- `u-text-no-wrap`
32+
33+
Utility for controlling the white-space wrapping of text, applies `white-space: nowrap`.
34+
35+
Notice in the second example how the `some-long-text` text doesn't wrap.
36+
37+
<Canvas>
38+
<Story
39+
name="White-space nowrap"
40+
parameters={{ docs: { source: { code: noWrapDemoSource } } }}
41+
>
42+
{(args) => noWrapDemo(args)}
43+
</Story>
44+
</Canvas>
45+
46+
## Action text
47+
48+
- `u-text-action`
49+
50+
Utility that changes the text color to the "action" text color.
51+
52+
<Canvas>
53+
<Story
54+
name="Action text"
55+
parameters={{ docs: { source: { code: colorDemoSource } } }}
56+
>
57+
{(args) => colorDemo(args)}
58+
</Story>
59+
</Canvas>

0 commit comments

Comments
 (0)