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
20 changes: 20 additions & 0 deletions src/utilities/background/background.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Canvas, Meta } from '@storybook/addon-docs/blocks';

import * as BackgroundStories from './background.stories.js';

<Meta of={BackgroundStories} />

# Background

These utilities apply background colors. For accessibility purposes, these utilities should be paired with u-text-light.

<Canvas of={BackgroundStories.Green} />

<Canvas of={BackgroundStories.Purple} />

<Canvas of={BackgroundStories.Fuchsia} />

<Canvas of={BackgroundStories.Orange} />

<Canvas of={BackgroundStories.None} />

21 changes: 21 additions & 0 deletions src/utilities/background/background.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@use '../../compiled/tokens/scss/color';

.u-bg-green {
background: color.$base-green !important;
}

.u-bg-purple {
background: color.$base-purple !important;
}

.u-bg-fuchsia {
background: color.$base-fuchsia !important;
}

.u-bg-orange {
background: color.$base-orange !important;
}

.u-bg-none {
background: transparent !important;
}
58 changes: 58 additions & 0 deletions src/utilities/background/background.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/** @import { Args, Meta, StoryObj } from '@storybook/html' */
import './background.scss';

/** @param {Args} args */
const backgroundStory = (args) => {
const classNames = [args.color || ''];
const textColor = [args.text || ''];
const className = classNames
.map((segment) => (segment.length > 0 ? `u-bg-${segment}` : 'u-bg'))
.join(' ');
return `<div class="u-text-${textColor} ${className} u-pad-n1">${className}</div>`;
};

/** @type {Meta} */
const meta = {
title: 'Utilities/Background',
argTypes: {
color: {
options: ['green', 'purple', 'fuchsia', 'orange', 'none'],
type: {
name: 'enum',
value: ['green', 'purple', 'fuchsia', 'orange', 'none'],
},
control: { type: 'inline-radio' },
},
text: {
options: ['light', 'dark'],
},
},
render: (args) => backgroundStory(args),
};

export default meta;

/** @type {StoryObj} */
export const Green = {
args: { color: 'green', text: 'light' },
};

/** @type {StoryObj} */
export const Purple = {
args: { color: 'purple', text: 'light' },
};

/** @type {StoryObj} */
export const Fuchsia = {
args: { color: 'fuchsia', text: 'light' },
};

/** @type {StoryObj} */
export const Orange = {
args: { color: 'orange', text: 'light' },
};

/** @type {StoryObj} */
export const None = {
args: { color: 'none', text: 'dark' },
};
12 changes: 12 additions & 0 deletions src/utilities/text/demo/light.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% embed '@cloudfour/objects/container/container.twig' with {
class: 'o-container--pad'
} only %}
{% block content %}
<div class="u-bg-green u-pad-n1">
<p class="u-text-light">This is text that has the u-text-light utility class applied.</p>
</div>
<div class="u-text-light u-pad-n1">
<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>
</div>
{% endblock %}
{% endembed %}
8 changes: 8 additions & 0 deletions src/utilities/text/text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
color: var(--theme-color-text-action) !important;
}

.u-text-light {
color: color.$text-light !important;
}

.u-text-dark {
color: color.$text-dark !important;
}

/// Size

.u-text-big {
Expand Down
9 changes: 9 additions & 0 deletions src/utilities/text/text.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/** @import { Meta, StoryObj } from '@storybook/html' */
import colorDemo from './demo/color.twig';
import colorDemoSource from './demo/color.twig?raw';
import lightDemo from './demo/light.twig';
import lightDemoSource from './demo/light.twig?raw';
import noWrapDemo from './demo/nowrap.twig';
import noWrapDemoSource from './demo/nowrap.twig?raw';
import sizeDemo from './demo/size.twig';
Expand Down Expand Up @@ -29,6 +31,13 @@ export const ActionText = {
render: (args) => colorDemo(args),
};

/** @type {StoryObj} */
export const LightText = {
name: 'Light and dark text',
parameters: { docs: { source: { code: lightDemoSource } } },
render: (args) => lightDemo(args),
};

/** @type {StoryObj} */
export const TextAlignCenter = {
name: 'Text-align center',
Expand Down
Loading