Skip to content

Commit 5f6d322

Browse files
Refactor typography system to use CSS custom properties
- Switch from pixel-based font sizes to rem units only, removing px fallbacks - Remove deprecated `text-display-*` mixins (see migration notes for v11.0.2) - Refactor typography mixins to use CSS custom properties instead of Sass variables - `text-title-*` and `text-body-*` mixins now use `--theme-*` variables - Rename CSS variables to use `--token-` prefix for consistency: - `--body-text-color` → `--token-body-text-color` - `--title-text-color` → `--token-title-text-color` - `--body-font-family` → `--token-body-font-family` - `--title-font-family` → `--token-title-font-family` - Remove redundant `@supports (--css: variables)` blocks for font properties - Clean up font-family declarations now handled by typography mixins - Update Firefox and Mozilla theme files with new variable naming - Update CHANGELOG with breaking changes - remove unused type-scale() mixin and associated lookup tables - change tokens to use scale for naming instead of tshirt sizes BREAKING CHANGE: Font sizes no longer include px fallbacks. All typography now requires CSS custom property support (browsers without support are effectively unsupported as of this change). visual regression fixes for forms,footer, sidebar lang switcher
1 parent a3bbf09 commit 5f6d322

40 files changed

+457
-823
lines changed

CHANGELOG.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
1+
# HEAD
2+
3+
This version introduces some major modernization changes around CSS and drops browser support for XXXX.
4+
5+
The good news is we don't expect any visible changes in modern browsers and you should be able to do some automated visual regression testing to help with the migration.
6+
7+
Introducing theme variables! CSS variables beginning with `--theme-` will adjust based on media queries.
8+
9+
## Modernization
10+
11+
### Typography
12+
13+
* Transition from Sass variables to CSS variables for typography. (#982)
14+
* Renamed existing CSS variables to use `--token-` prefix.
15+
* Introduced CSS variables with the `--theme-` prefix for values that adjust based on media queries.
16+
17+
### Color
18+
19+
* To come in follow up PR.
20+
21+
## Migration Tips
22+
23+
* Browser support
24+
* If you require support for older browsers we recommend adding some post-processing to your work flow for css variables and font sizes in pixels.
25+
* `text-title-*` mixins now declare `font-family`.
26+
* You can remove any `font-family` declarations from places which use these mixins (unless you don't want the default heading font).
27+
* Update Sass variables to use CSS variables:
28+
* `$body-text-color``var(--theme-body-text-color)`
29+
* `$body-text-color-inverse``var(--theme-body-text-color-inverse)`
30+
* `$body-text-color-secondary``var(--theme-body-text-color-secondary)`
31+
* `$body-text-color-secondary-inverse``var(--theme-body-text-color-secondary-inverse)`
32+
* `$title-text-color``var(--token-title-text-color)`
33+
* `$title-text-color-inverse``var(--token-title-text-color-inverse)`
34+
* `$body-font-family``var(--theme-body-font-family)`
35+
* `$title-font-family``var(--theme-title-font-family)`
36+
* `$body-line-height``var(--theme-body-line-height)`
37+
* Rename CSS variables:
38+
* `--body-text-color``--token-body-text-color`
39+
* `--body-text-color-inverse``--token-body-text-color-inverse`
40+
* `--body-text-color-secondary``--token-body-text-color-secondary`
41+
* `--body-text-color-secondary-inverse``--token-body-text-color-secondary-inverse`
42+
* `--title-text-color``--token-title-text-color`
43+
* `--title-text-color-inverse``--token-title-text-color-inverse`
44+
* `--body-font-family``--theme-body-font-family`
45+
* `--title-font-family``--theme-title-font-family`
46+
* `--body-line-height``--theme-body-line-height`
47+
* Replace any remaining `text-display-*` usage with the equivalent `text-title-*` mixin (see migration notes for version 11.0.2.):
48+
* `text-display-xxl``text-title-2xl`
49+
* `text-display-xl``text-title-xl`
50+
* `text-display-lg``text-title-lg`
51+
* `text-display-md``text-title-md`
52+
* `text-display-sm``text-title-sm`
53+
* `text-display-xs``text-title-xs`
54+
* `text-display-xxs``text-title-2xs`
55+
156
# 22.0.0
257

358
## Features
@@ -199,8 +254,8 @@ stating variables explicitly, like this:
199254

200255
@supports (--css: variables) {
201256
background-color: var(--background-color-inverse);
202-
color: var(--body-text-color-inverse);
203-
line-height: var(--body-line-height);
257+
color: var(--token-body-text-color-inverse);
258+
line-height: var(--token-body-line-height);
204259
}
205260
}
206261
```

assets/sass/protocol/base/elements/_document.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@ html {
1010
}
1111

1212
body {
13-
@include text-body-md;
1413
background: $background-color;
1514
color: $body-text-color;
16-
font-family: $body-font-family;
17-
line-height: $body-line-height;
1815
-moz-osx-font-smoothing: grayscale;
1916
-webkit-font-smoothing: antialiased;
17+
@include text-body-md;
2018

2119
@supports (--css: variable) {
2220
background: var(--background-color);
23-
color: var(--body-text-color);
24-
font-family: var(--body-font-family);
25-
line-height: var(--body-line-height);
21+
color: var(--token-body-text-color);
2622
}
2723
}
2824

assets/sass/protocol/base/elements/_forms.scss

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@ legend {
2828
max-width: 100%; // 1
2929
padding: 0; // 3
3030
white-space: normal; // 1
31-
.mzp-u-inline & {
32-
@include forms.field-label;
33-
}
34-
@include text-body-lg;
35-
font-family: $body-font-family;
36-
font-weight: bold;
3731
margin-bottom: forms.$field-v-spacing;
32+
font-weight: bold;
33+
@include text-body-lg;
3834

39-
@supports (--css: variables) {
40-
font-family: var(--body-font-family);
35+
.mzp-u-inline & {
36+
@include forms.field-label;
4137
}
4238
}
4339

@@ -46,9 +42,9 @@ input,
4642
select,
4743
optgroup,
4844
textarea {
49-
@include font-base;
5045
@include text-body-md;
51-
line-height: 1.25;
46+
@include font-base;
47+
line-height: var(--theme-button-line-height);
5248
}
5349

5450
button,
@@ -249,7 +245,7 @@ input[type='file'] {
249245
background: $color-white;
250246
border-radius: forms.$field-border-radius;
251247
border: forms.$field-border;
252-
line-height: 1.25;
248+
line-height: var(--theme-button-line-height);
253249
margin: 0 0 forms.$field-v-spacing;
254250

255251
&:hover {

assets/sass/protocol/base/elements/_links.scss

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,9 @@ a {
4848
}
4949

5050
.mzp-c-cta-link {
51-
font-family: $button-font-family;
51+
font-family: var(--theme-button-font-family);
5252
font-weight: bold;
5353

54-
@supports (--css: variables) {
55-
font-family: var(--button-font-family);
56-
}
57-
5854
&.mzp-t-xs {
5955
@include text-body-sm;
6056
}
@@ -69,29 +65,14 @@ a {
6965

7066
&.mzp-t-lg {
7167
@include text-title-xs;
72-
font-family: $title-font-family;
73-
74-
@supports (--css: variables) {
75-
font-family: var(--title-font-family);
76-
}
7768
}
7869

7970
&.mzp-t-xl {
8071
@include text-title-sm;
81-
font-family: $title-font-family;
82-
83-
@supports (--css: variables) {
84-
font-family: var(--title-font-family);
85-
}
8672
}
8773

8874
&.mzp-t-2xl {
8975
@include text-title-lg;
90-
font-family: $title-font-family;
91-
92-
@supports (--css: variables) {
93-
font-family: var(--title-font-family);
94-
}
9576
}
9677

9778
// Icon support

assets/sass/protocol/base/elements/_quotes.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ blockquote {
1010
border-color: $color-marketing-gray-20;
1111
border-style: solid;
1212
color: $title-text-color;
13-
font-family: $title-font-family;
1413
font-weight: bold;
1514
margin: $spacing-lg auto;
1615
padding: $spacing-sm $spacing-lg;
@@ -29,11 +28,10 @@ blockquote {
2928
}
3029

3130
@supports (--css: variables) {
32-
color: var(--title-text-color);
33-
font-family: var(--title-font-family);
31+
color: var(--token-title-text-color);
3432

3533
cite {
36-
color: var(--body-text-color-secondary);
34+
color: var(--token-body-text-color-secondary);
3735
}
3836
}
3937
}

assets/sass/protocol/base/elements/_titles.scss

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ h3,
1212
h4,
1313
h5,
1414
h6 {
15-
$default-font-weight: bold;
16-
font-family: $title-font-family;
1715
color: $title-text-color;
18-
font-weight: $default-font-weight;
16+
font-family: var(--theme-title-font-family);
17+
font-variant-ligatures: var(--theme-title-font-ligatures);
18+
letter-spacing: var(--theme-title-letter-spacing);
1919
text-wrap: balance;
2020
margin: 0 0 0.5em;
2121

@@ -24,14 +24,10 @@ h6 {
2424
}
2525

2626
@supports (--css: variables) {
27-
font-family: var(--title-font-family);
28-
font-variant-ligatures: var(--title-font-ligatures);
29-
font-weight: var(--title-font-weight, #{$default-font-weight});
30-
letter-spacing: var(--title-letter-spacing);
31-
color: var(--title-text-color);
27+
color: var(--token-title-text-color);
3228

3329
.mzp-t-dark & {
34-
color: var(--title-text-color-inverse);
30+
color: var(--token-title-text-color-inverse);
3531
}
3632
}
3733
}

assets/sass/protocol/base/utilities/_backgrounds.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
@supports (--css: variables) {
3030
background-color: var(--background-color-inverse);
31-
color: var(--body-text-color-inverse);
31+
color: var(--token-body-text-color-inverse);
3232
}
3333
}
3434

assets/sass/protocol/base/utilities/_rich-text.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
@use '../../includes/lib' as *;
6-
@import '../../base/elements/tables';
6+
@use '../../base/elements/tables' as *;
77

88
.mzp-u-rich-text {
99
h2 {
@@ -17,10 +17,9 @@
1717
}
1818

1919
h4 {
20-
@include text-body-lg;
21-
font-family: var(--body-font-family);
2220
margin-bottom: $layout-xs;
2321
margin-top: $layout-xs;
22+
@include text-body-lg;
2423
}
2524

2625
@media #{$mq-md} {

assets/sass/protocol/base/utilities/_titles.scss

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,34 @@
99

1010
.mzp-u-title-2xl {
1111
@include text-title-2xl;
12-
font-family: $title-font-family;
13-
14-
@supports (--css: variables) {
15-
font-family: var(--title-font-family);
16-
}
1712
}
1813

1914
.mzp-u-title-xl {
2015
@include text-title-xl;
21-
font-family: $title-font-family;
22-
23-
@supports (--css: variables) {
24-
font-family: var(--title-font-family);
25-
}
2616
}
2717

2818
.mzp-u-title-lg {
2919
@include text-title-lg;
30-
font-family: $title-font-family;
31-
32-
@supports (--css: variables) {
33-
font-family: var(--title-font-family);
34-
}
3520
}
3621

3722
.mzp-u-title-md {
3823
@include text-title-md;
39-
font-family: $title-font-family;
40-
41-
@supports (--css: variables) {
42-
font-family: var(--title-font-family);
43-
}
4424
}
4525

4626
.mzp-u-title-sm {
4727
@include text-title-sm;
48-
font-family: $title-font-family;
49-
50-
@supports (--css: variables) {
51-
font-family: var(--title-font-family);
52-
}
5328
}
5429

5530
.mzp-u-title-xs {
5631
@include text-title-xs;
57-
font-family: $title-font-family;
58-
59-
@supports (--css: variables) {
60-
font-family: var(--title-font-family);
61-
}
6232
}
6333

6434
.mzp-u-title-2xs {
6535
@include text-title-2xs;
66-
font-family: $title-font-family;
67-
68-
@supports (--css: variables) {
69-
font-family: var(--title-font-family);
70-
}
7136
}
7237

7338
.mzp-u-title-3xs {
7439
@include text-title-3xs;
75-
font-family: $title-font-family;
76-
77-
@supports (--css: variables) {
78-
font-family: var(--title-font-family);
79-
}
8040
}
8141

8242
// Utility class for centered text.

assets/sass/protocol/components/_button.scss

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
border: 2px solid transparent;
1717
cursor: pointer;
1818
display: inline-block;
19-
font-family: $button-font-family;
19+
font-family: var(--theme-button-font-family);
2020
font-weight: bold;
21-
line-height: $body-line-height;
21+
line-height: var(--theme-button-line-height);
2222
padding: $spacing-sm $spacing-md;
2323
text-align: center;
2424
text-decoration: none !important; /* stylelint-disable-line declaration-no-important */
@@ -41,11 +41,6 @@
4141
opacity: 0.6;
4242
pointer-events: none;
4343
}
44-
45-
@supports (--css: variables) {
46-
font-family: var(--button-font-family);
47-
line-height: var(--body-line-height);
48-
}
4944
}
5045

5146
// Sizes
@@ -208,9 +203,9 @@
208203
}
209204

210205
.mzp-c-button-download-privacy-link {
211-
@include text-body-xs;
212206
display: block;
213207
margin-top: forms.$info-v-spacing;
208+
@include text-body-xs;
214209

215210
a {
216211
color: inherit;

0 commit comments

Comments
 (0)