Skip to content

Commit 08bea80

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 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). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 054482e commit 08bea80

28 files changed

+332
-495
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(--token-body-text-color)`
29+
* `$body-text-color-inverse``var(--token-body-text-color-inverse)`
30+
* `$body-text-color-secondary``var(--token-body-text-color-secondary)`
31+
* `$body-text-color-secondary-inverse``var(--token-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(--token-body-font-family)`
35+
* `$title-font-family``var(--token-title-font-family)`
36+
* `$body-line-height``var(--token-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``--token-body-font-family`
45+
* `--title-font-family``--token-title-font-family`
46+
* `--body-line-height``--token-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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@ body {
1313
@include text-body-md;
1414
background: $background-color;
1515
color: $body-text-color;
16-
font-family: $body-font-family;
17-
line-height: $body-line-height;
1816
-moz-osx-font-smoothing: grayscale;
1917
-webkit-font-smoothing: antialiased;
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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ legend {
3232
@include forms.field-label;
3333
}
3434
@include text-body-lg;
35-
font-family: $body-font-family;
35+
font-family: var(--token-body-font-family);
3636
font-weight: bold;
3737
margin-bottom: forms.$field-v-spacing;
38-
39-
@supports (--css: variables) {
40-
font-family: var(--body-font-family);
41-
}
4238
}
4339

4440
button,

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(--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: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ h3,
1212
h4,
1313
h5,
1414
h6 {
15-
$default-font-weight: bold;
16-
font-family: $title-font-family;
15+
font-family: var(--token-title-font-family);
16+
font-variant-ligatures: var(--token-title-font-ligatures);
1717
color: $title-text-color;
18-
font-weight: $default-font-weight;
1918
text-wrap: balance;
2019
margin: 0 0 0.5em;
2120

@@ -24,14 +23,10 @@ h6 {
2423
}
2524

2625
@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);
26+
color: var(--token-title-text-color);
3227

3328
.mzp-t-dark & {
34-
color: var(--title-text-color-inverse);
29+
color: var(--token-title-text-color-inverse);
3530
}
3631
}
3732
}

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
h4 {
2020
@include text-body-lg;
21-
font-family: var(--body-font-family);
21+
font-family: var(--token-body-font-family);
2222
margin-bottom: $layout-xs;
2323
margin-top: $layout-xs;
2424
}

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
border: 2px solid transparent;
1717
cursor: pointer;
1818
display: inline-block;
19-
font-family: $button-font-family;
19+
font-family: var(--button-font-family);
2020
font-weight: bold;
2121
line-height: $body-line-height;
2222
padding: $spacing-sm $spacing-md;
@@ -44,7 +44,7 @@
4444

4545
@supports (--css: variables) {
4646
font-family: var(--button-font-family);
47-
line-height: var(--body-line-height);
47+
line-height: var(--token-body-line-height);
4848
}
4949
}
5050

0 commit comments

Comments
 (0)