Skip to content

Commit d44a18d

Browse files
Add text color utilities to the Colors tokens PR
1 parent 3d2f01c commit d44a18d

File tree

8 files changed

+265
-12
lines changed

8 files changed

+265
-12
lines changed

scss/_maps.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,27 @@ $ouds-backgrounds: (
141141
"transparent": transparent,
142142
) !default;
143143
// scss-docs-end ouds-maps-opacities
144+
145+
// scss-docs-start ouds-maps-text-colors
146+
$ouds-text-colors: (
147+
"brand-primary": var(--#{$prefix}color-content-brand-primary),
148+
"default": var(--#{$prefix}color-content-default),
149+
"disabled": var(--#{$prefix}color-content-disabled),
150+
"muted": var(--#{$prefix}color-content-muted),
151+
"on-brand-primary": var(--#{$prefix}color-content-on-brand-primary),
152+
"on-status-emphasized": var(--#{$prefix}color-content-on-status-emphasized),
153+
"on-status-emphasized-alt": var(--#{$prefix}color-content-on-status-emphasized-alt),
154+
"on-status-muted": var(--#{$prefix}color-content-on-status-muted),
155+
"status-info": var(--#{$prefix}color-content-status-info),
156+
"status-negative": var(--#{$prefix}color-content-status-negative),
157+
"status-positive": var(--#{$prefix}color-content-status-positive),
158+
"status-warning": var(--#{$prefix}color-content-status-warning),
159+
"always-black": var(--#{$prefix}color-always-black),
160+
"always-white": var(--#{$prefix}color-always-white),
161+
"always-on-black": var(--#{$prefix}color-always-on-black),
162+
"always-on-white": var(--#{$prefix}color-always-on-white),
163+
) !default;
164+
// scss-docs-end ouds-maps-text-colors
144165
// End mod
145166

146167
// Re-assigned maps

scss/_utilities.scss

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ $utilities: map-merge(
980980
"body-emphasis": var(--#{$prefix}emphasis-color),
981981
"reset": inherit,
982982
)
983-
)
983+
),
984+
bootstrap-compatibility: true
984985
),
985986
"text-opacity": (
986987
css-var: true,
@@ -990,14 +991,23 @@ $utilities: map-merge(
990991
50: .5,
991992
75: .75,
992993
100: 1
993-
)
994+
),
995+
bootstrap-compatibility: true
994996
),
995997
"text-color": (
996998
property: color,
997999
class: text,
998-
values: $utilities-text-emphasis-colors
1000+
values: $utilities-text-emphasis-colors,
1001+
bootstrap-compatibility: true
9991002
),
10001003
// scss-docs-end utils-color
1004+
// scss-docs-start utils-color-ouds
1005+
"color-ouds": (
1006+
property: color,
1007+
class: text,
1008+
values: $ouds-text-colors
1009+
),
1010+
// scss-docs-end utils-color-ouds
10011011
// scss-docs-start utils-links
10021012
"link-opacity": (
10031013
css-var: true,

site/content/docs/0.0/content/typography.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ While not shown above, feel free to use `<b>` and `<i>` in HTML5. `<b>` is meant
240240

241241
## Text utilities
242242

243-
Change text alignment, transform, style, weight, line-height, decoration<!-- and color--> with our [text utilities]({{< docsref "/utilities/text" >}})<!-- and [color utilities]({{< docsref "/utilities/colors" >}})-->.
243+
Change text alignment, transform, style, weight, line-height, decoration and color with our [text utilities]({{< docsref "/utilities/text" >}}) and [color utilities]({{< docsref "/utilities/colors" >}}).
244244

245245
## Abbreviations
246246

site/content/docs/0.0/customize/color-palette.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ Here's how you should use these in your Sass:
128128
}
129129
```
130130

131-
<!-- [Color]({{< docsref "/utilities/colors" >}}) and -->
132-
[Background]({{< docsref "/utilities/background" >}}) utility classes are also available for setting <!--`color` and -->`background-color`.
131+
[Color]({{< docsref "/utilities/colors" >}}) and [Background]({{< docsref "/utilities/background" >}}) utility classes are also available for setting `color` and `background-color`.
133132
</details>
134133

135134
## CSS

site/content/docs/0.0/getting-started/accessibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ OUDS Web's interactive components<!--—such as modal dialogs, dropdown menus, a
2424

2525
Because OUDS Web's components are purposely designed to be fairly generic, authors may need to include further <abbr title="Accessible Rich Internet Applications">ARIA</abbr> roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
2626

27-
<!--### Color contrast
27+
<!-- TODO LM: ### Color contrast
2828
2929
Some combinations of colors that currently make up OUDS Web's default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to *insufficient* color contrast (below the recommended [WCAG 2.1 text color contrast ratio of 4.5:1](https://www.w3.org/TR/WCAG/#contrast-minimum) and the [WCAG 2.1 non-text color contrast ratio of 3:1](https://www.w3.org/TR/WCAG21/#non-text-contrast)), particularly when used against a light background.
3030

site/content/docs/0.0/utilities/background.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ toc: true
1717
Background utilities like `.bg-*` are generated from our `$ouds-backgrounds` Sass map and respond to color modes.
1818

1919
Similar to the contextual text color classes, set the background of an element to any contextual class. Background utilities **do not set `color`**, so depending on the cases you'll want to use an additional:
20-
* `[data-bs-theme]` [color mode attribute]({{< docsref "/customize/color-modes#how-to-use" >}}) when the element using a background utility contains complex sub-elements such as components that need to respond to color modes
21-
<!-- * `.text-*` [color utilities]({{< docsref "/utilities/colors" >}}) when the background color remains the same in light and dark mode
22-
* `.text-bg-*` [color & background helper]({{< docsref "/helpers/color-background" >}}) from our [theme colors]({{< docsref "/customize/color-theme#theming" >}}) -->
20+
* `[data-bs-theme]` [color mode attribute]({{< docsref "/customize/color-modes#how-to-use" >}}) is the best option all the time and moreover when the element using a background utility contains complex sub-elements such as components that need to respond to color modes
21+
* `.text-*` [color utilities]({{< docsref "/utilities/colors" >}}) when the background color remains the same in light and dark mode
22+
<!-- * `.text-bg-*` [color & background helper]({{< docsref "/helpers/color-background" >}}) from our [theme colors]({{< docsref "/customize/color-theme#theming" >}}) -->
2323

2424
{{< bootstrap-compatibility >}}
2525

site/content/docs/0.0/utilities/colors.md

Lines changed: 225 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,228 @@ aliases:
88
toc: true
99
---
1010

11-
{{< callout-soon "page" >}}
11+
{{< callout info >}}
12+
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
13+
{{< /callout >}}
14+
15+
## Colors
16+
17+
Colorize text with color utilities.<!-- If you want to colorize links, you can use the [`.link-*` helper classes]({{< docsref "/helpers/colored-links" >}}) which have `:hover` and `:focus` states.-->
18+
<!-- To colorize icons, please refer to our [icon color documentation]({{< docsref "extend/icons#modify-icons-color" >}}). -->
19+
20+
OUDS Web provides many `.text-*` and `.bg-*` utilities, but they should be used with care to meet our design specifications and [WCAG 2.2 accessibility standards for color contrast](https://www.w3.org/TR/WCAG/#distinguishable).
21+
To be sure to respect the specifications, it is necessary to define `color`, `background-color` and `font-size` altogether.
22+
23+
Thus, the `.text-primary` color on white background (`#f16e00`) can only be used in a font size greater than 24px (using for example `.fs-3` utility), or 19px bold (using for example `.fs-4` and `.fw-bold` utilities).
24+
The `.text-primary` color on dark background (`#ff7900`) can be used in any size, and it shouldn't be used on light grey backgrounds at all.
25+
26+
Here are some compliant combinations examples for texts:
27+
28+
{{< example >}}
29+
<div class="p-1" data-bs-theme="light">
30+
<p class="text-brand-primary p-short">Text brand-primary</p>
31+
<p class="text-default p-short">Text default</p>
32+
<p class="text-disabled p-short">Text disabled</p>
33+
<p class="text-muted p-short">Text muted</p>
34+
<div data-bs-theme="light"><p class="text-on-brand-primary bg-brand-primary p-short">Text on-brand-primary</p></div>
35+
<div data-bs-theme=""><p class="text-on-status-emphasized p-short">Text on-status-emphasized</p></div>
36+
<div data-bs-theme=""><p class="text-on-status-emphasized-alt p-short">Text on-status-emphasized-alt</p></div>
37+
<div data-bs-theme=""><p class="text-on-status-muted p-short">Text on-status-muted</p></div>
38+
<p class="text-status-info p-short">Text status-info</p>
39+
<p class="text-status-negative p-short">Text status-negative</p>
40+
<p class="text-status-positive p-short">Text status-positive</p>
41+
<p class="text-status-warning p-short">Text status-warning</p>
42+
<div data-bs-theme="light"><p class="text-always-black p-short">Text always-black</p></div>
43+
<div data-bs-theme="dark"><p class="text-always-white p-short">Text always-white</p></div>
44+
<div data-bs-theme="dark"><p class="text-always-on-black p-short">Text always-on-black</p></div>
45+
<div data-bs-theme="light"><p class="text-always-on-white p-short">Text always-on-white</p></div>
46+
</div>
47+
{{< /example >}}
48+
49+
<!-- TODO LM: Insert table including text-brand-primary, font-weight, and font-size depending on the background-color/color mode or maybe lists the allowed couples depending on the font-size/font-weight -->
50+
51+
If you don't see the couple you need, please mind using one of the table
52+
53+
{{< bs-table >}}
54+
| Font reference | Allowed `.text-*` and `.bg-*` couples |
55+
| --- | --- |
56+
| All `font-sizes`/`font-weight` are allowed | |
57+
| | |
58+
| | |
59+
{{< /bs-table >}}
60+
61+
{{< callout warning >}}
62+
When the interface allows to switch between light and dark backgrounds, the light mode stricter restrictions must be applied!
63+
{{< /callout >}}
64+
65+
<!-- The following colors are meant to be used with icons.
66+
67+
{{< example >}}
68+
{{< colors.inline >}}
69+
{{- range (index $.Site.Data "theme-colors") }}
70+
<p class="text-{{ .name }}{{ with .contrast_color }} bg-{{ . }}{{ end }}">.text-{{ .name }}</p>
71+
{{- end -}}
72+
{{< /colors.inline >}}
73+
74+
<p class="text-body">.text-body</p>
75+
<p class="text-body-emphasis">.text-body-emphasis</p>
76+
<p class="text-body-secondary">.text-body-secondary</p>
77+
78+
<p class="text-black bg-white">.text-black</p>
79+
<p class="text-white bg-black">.text-white</p>
80+
{{< /example >}} -->
81+
82+
<!-- <details>
83+
<summary>See Bootstrap examples that are incompatible with Orange Design System.</summary>
84+
<br>
85+
{{< design-callout-alert >}}
86+
Some of the colors combinations below do not belong to the Orange Design System specifications, and do not meet accessibility standards.
87+
88+
Please refer to our [Orange's colors section]({{< docsref "/utilities/colors#colors" >}}) above and to the [Color guidelines](https://system.design.orange.com/0c1af118d/p/7059a5-colour/b/17b829) on the Orange Design System website.
89+
{{< /design-callout-alert >}}
90+
91+
{{< example >}}
92+
{{< colors.inline >}}
93+
{{- range (index $.Site.Data "theme-colors") }}
94+
<p class="text-{{ .name }}{{ with .contrast_color }} bg-{{ . }}{{ end }}">.text-{{ .name }}</p>
95+
<p class="text-{{ .name }}-emphasis{{ with .contrast_color }} bg-{{ . }}{{ end }}">.text-{{ .name }}-emphasis</p>
96+
{{- end -}}
97+
{{< /colors.inline >}}
98+
99+
<p class="text-body">.text-body</p>
100+
<p class="text-body-emphasis">.text-body-emphasis</p>
101+
<p class="text-body-secondary">.text-body-secondary</p>
102+
<p class="text-body-tertiary">.text-body-tertiary</p>
103+
104+
<p class="text-black bg-white">.text-black</p>
105+
<p class="text-white bg-black">.text-white</p>
106+
<p class="text-black-50 bg-white">.text-black-50</p>
107+
<p class="text-white-50 bg-black">.text-white-50</p>
108+
{{< /example >}}
109+
110+
{{< callout warning >}}
111+
**Deprecation:** With the addition of `.text-opacity-*` utilities and CSS variables for text utilities, `.text-black-50` and `.text-white-50` are deprecated as of v5.1.0. They'll be removed in v6.0.0.
112+
{{< /callout >}}
113+
</details> -->
114+
115+
<!-- ## Opacity
116+
117+
{{< added-in "5.1.0" >}}
118+
119+
As of v5.1.0, text color utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
120+
121+
### How it works
122+
123+
Consider our default `.text-primary` utility.
124+
125+
```css
126+
.text-primary {
127+
--bs-text-opacity: 1;
128+
color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
129+
}
130+
```
131+
132+
We use an RGB version of our `--bs-primary` (with the value of `241, 110, 0` in light mode) CSS variable and attached a second CSS variable, `--bs-text-opacity`, for the alpha transparency (with a default value `1` thanks to a local CSS variable). That means anytime you use `.text-primary` now, your computed `color` value is `rgba(241, 110, 0, 1)` in light mode. The local CSS variable inside each `.text-*` class avoids inheritance issues so nested instances of the utilities don't automatically have a modified alpha transparency.
133+
134+
When used in dark mode, `--bs-primary-rgb` will use the value of (with the value of `255, 121, 0`).
135+
136+
### Example
137+
138+
To change that opacity, override `--bs-text-opacity` via custom styles or inline styles.
139+
140+
<details>
141+
<summary>See Bootstrap examples that are incompatible with Orange Design System.</summary>
142+
<br>
143+
{{< design-callout-alert >}}
144+
Some of the colors combinations below do not belong to the Orange Design System specifications, and do not meet accessibility standards.
145+
146+
Please refer to our [Orange's colors section]({{< docsref "/utilities/colors#colors" >}}) above.
147+
{{< /design-callout-alert >}}
148+
149+
{{< example >}}
150+
<div class="text-primary">This is default primary text</div>
151+
<div class="text-primary" style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>
152+
{{< /example >}}
153+
154+
Or, choose from any of the `.text-opacity` utilities:
155+
156+
{{< example >}}
157+
<div class="text-primary">This is default primary text</div>
158+
<div class="text-primary text-opacity-75">This is 75% opacity primary text</div>
159+
<div class="text-primary text-opacity-50">This is 50% opacity primary text</div>
160+
<div class="text-primary text-opacity-25">This is 25% opacity primary text</div>
161+
{{< /example >}}
162+
</details> -->
163+
164+
## Specificity
165+
166+
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a `<div>` or more semantic element with the desired class.
167+
168+
## CSS
169+
170+
<!-- TODO LM: The rest of it -->
171+
172+
In addition to the following Sass functionality, consider reading about our included [CSS custom properties]({{< docsref "/customize/css-variables" >}}) (aka CSS variables) for colors and more.
173+
174+
### Sass variables
175+
176+
Most `color` utilities are generated by our theme colors, reassigned from our generic color palette variables.
177+
178+
<!-- Boosted mod -->
179+
Boosted supersedes Bootstrap color variables with Orange brand color.
180+
181+
{< scss-docs name="brand-colors" file="scss/_variables.scss" >}}
182+
183+
{< scss-docs name="brand-colors-dark" file="scss/_variables-dark.scss" >}}
184+
185+
{{< scss-docs name="color-variables" file="scss/_variables.scss" >}}
186+
187+
{{< scss-docs name="theme-color-variables" file="scss/_variables.scss" >}}
188+
189+
{{< scss-docs name="theme-color-dark-variables" file="scss/_variables-dark.scss" >}}
190+
191+
Grayscale colors are also available, but only a subset are used to generate any utilities.
192+
193+
{{< scss-docs name="gray-color-variables" file="scss/_variables.scss" >}}
194+
195+
{{< scss-docs name="theme-text-map" file="scss/_maps.scss" >}}
196+
197+
Variables for setting colors in `.text-*-emphasis` utilities in light and dark mode:
198+
199+
{{< scss-docs name="theme-text-variables" file="scss/_variables.scss" >}}
200+
201+
{{< scss-docs name="theme-text-dark-variables" file="scss/_variables-dark.scss" >}}
202+
203+
### Sass maps
204+
205+
Theme colors are then put into a Sass map so we can loop over them to generate our utilities, component modifiers, and more.
206+
207+
{{< scss-docs name="theme-colors-map" file="scss/_variables.scss" >}}
208+
209+
{{< scss-docs name="theme-colors-dark-map" file="scss/_variables-dark.scss" >}}
210+
211+
Grayscale colors are also available as a Sass map. **This map is not used to generate any utilities.**
212+
213+
{{< scss-docs name="gray-colors-map" file="scss/_variables.scss" >}}
214+
215+
RGB colors are generated from a separate Sass map:
216+
217+
{{< scss-docs name="theme-colors-rgb" file="scss/_maps.scss" >}}
218+
219+
{{< scss-docs name="theme-colors-rgb-dark" file="scss/_maps.scss" >}}
220+
221+
Color opacities build on that with their own map that's consumed by the utilities API:
222+
223+
{{< scss-docs name="utilities-text-colors" file="scss/_maps.scss" >}}
224+
225+
Color mode adaptive text colors are also available as a Sass map:
226+
227+
{{< scss-docs name="theme-text-map" file="scss/_maps.scss" >}}
228+
229+
{{< scss-docs name="theme-text-dark-map" file="scss/_maps.scss" >}}
230+
231+
### Sass utilities API
232+
233+
Color utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
234+
235+
{{< scss-docs name="utils-color" file="scss/_utilities.scss" >}}

site/data/sidebar.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@
195195
- title: Background
196196
- title: Borders
197197
- title: Colors
198-
draft: true
199198
- title: Display
200199
- title: Flex
201200
- title: Float

0 commit comments

Comments
 (0)