Skip to content

Commit 2b44c64

Browse files
aileenjeffriesAileen R Jeffries
andauthored
adding new background color utilities and a light text utility (#2580)
* adding new background color utilities and a light text utility * adding a u-text-dark and removing text inherit from u-bg-none * I don't think we need u-text-inherit --------- Co-authored-by: Aileen R Jeffries <aileen.jeffries@MacBook-Air.local>
1 parent 37444db commit 2b44c64

6 files changed

Lines changed: 128 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Canvas, Meta } from '@storybook/addon-docs/blocks';
2+
3+
import * as BackgroundStories from './background.stories.js';
4+
5+
<Meta of={BackgroundStories} />
6+
7+
# Background
8+
9+
These utilities apply background colors. For accessibility purposes, these utilities should be paired with u-text-light.
10+
11+
<Canvas of={BackgroundStories.Green} />
12+
13+
<Canvas of={BackgroundStories.Purple} />
14+
15+
<Canvas of={BackgroundStories.Fuchsia} />
16+
17+
<Canvas of={BackgroundStories.Orange} />
18+
19+
<Canvas of={BackgroundStories.None} />
20+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@use '../../compiled/tokens/scss/color';
2+
3+
.u-bg-green {
4+
background: color.$base-green !important;
5+
}
6+
7+
.u-bg-purple {
8+
background: color.$base-purple !important;
9+
}
10+
11+
.u-bg-fuchsia {
12+
background: color.$base-fuchsia !important;
13+
}
14+
15+
.u-bg-orange {
16+
background: color.$base-orange !important;
17+
}
18+
19+
.u-bg-none {
20+
background: transparent !important;
21+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/** @import { Args, Meta, StoryObj } from '@storybook/html' */
2+
import './background.scss';
3+
4+
/** @param {Args} args */
5+
const backgroundStory = (args) => {
6+
const classNames = [args.color || ''];
7+
const textColor = [args.text || ''];
8+
const className = classNames
9+
.map((segment) => (segment.length > 0 ? `u-bg-${segment}` : 'u-bg'))
10+
.join(' ');
11+
return `<div class="u-text-${textColor} ${className} u-pad-n1">${className}</div>`;
12+
};
13+
14+
/** @type {Meta} */
15+
const meta = {
16+
title: 'Utilities/Background',
17+
argTypes: {
18+
color: {
19+
options: ['green', 'purple', 'fuchsia', 'orange', 'none'],
20+
type: {
21+
name: 'enum',
22+
value: ['green', 'purple', 'fuchsia', 'orange', 'none'],
23+
},
24+
control: { type: 'inline-radio' },
25+
},
26+
text: {
27+
options: ['light', 'dark'],
28+
},
29+
},
30+
render: (args) => backgroundStory(args),
31+
};
32+
33+
export default meta;
34+
35+
/** @type {StoryObj} */
36+
export const Green = {
37+
args: { color: 'green', text: 'light' },
38+
};
39+
40+
/** @type {StoryObj} */
41+
export const Purple = {
42+
args: { color: 'purple', text: 'light' },
43+
};
44+
45+
/** @type {StoryObj} */
46+
export const Fuchsia = {
47+
args: { color: 'fuchsia', text: 'light' },
48+
};
49+
50+
/** @type {StoryObj} */
51+
export const Orange = {
52+
args: { color: 'orange', text: 'light' },
53+
};
54+
55+
/** @type {StoryObj} */
56+
export const None = {
57+
args: { color: 'none', text: 'dark' },
58+
};

‎src/utilities/text/demo/light.twig‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% embed '@cloudfour/objects/container/container.twig' with {
2+
class: 'o-container--pad'
3+
} only %}
4+
{% block content %}
5+
<div class="u-bg-green u-pad-n1">
6+
<p class="u-text-light">This is text that has the u-text-light utility class applied.</p>
7+
</div>
8+
<div class="u-text-light u-pad-n1">
9+
<p class="u-text-dark">This is text that has the u-text-dark utility class applied, overriding the u-text-light class applied to the parent element.</p>
10+
</div>
11+
{% endblock %}
12+
{% endembed %}

‎src/utilities/text/text.scss‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
color: var(--theme-color-text-action) !important;
1919
}
2020

21+
.u-text-light {
22+
color: color.$text-light !important;
23+
}
24+
25+
.u-text-dark {
26+
color: color.$text-dark !important;
27+
}
28+
2129
/// Size
2230

2331
.u-text-big {

‎src/utilities/text/text.stories.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/** @import { Meta, StoryObj } from '@storybook/html' */
22
import colorDemo from './demo/color.twig';
33
import colorDemoSource from './demo/color.twig?raw';
4+
import lightDemo from './demo/light.twig';
5+
import lightDemoSource from './demo/light.twig?raw';
46
import noWrapDemo from './demo/nowrap.twig';
57
import noWrapDemoSource from './demo/nowrap.twig?raw';
68
import sizeDemo from './demo/size.twig';
@@ -29,6 +31,13 @@ export const ActionText = {
2931
render: (args) => colorDemo(args),
3032
};
3133

34+
/** @type {StoryObj} */
35+
export const LightText = {
36+
name: 'Light and dark text',
37+
parameters: { docs: { source: { code: lightDemoSource } } },
38+
render: (args) => lightDemo(args),
39+
};
40+
3241
/** @type {StoryObj} */
3342
export const TextAlignCenter = {
3443
name: 'Text-align center',

0 commit comments

Comments
 (0)