Skip to content

Commit f7781a1

Browse files
authored
Add Gutenberg font size utilities + misc. typographic token improvements (#1333)
* Add line-height tokens * Use line-height tokens * Add heading level tokens * Update heading mixin to use tokens * Small and big font tokens * Gutenberg font-size utilities Co-authored by: Caleb Eby <[email protected]>
1 parent ad94723 commit f7781a1

File tree

24 files changed

+296
-38
lines changed

24 files changed

+296
-38
lines changed

.changeset/fast-mugs-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Add big, small and heading level font size tokens

.changeset/olive-berries-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Add line-height tokens

.changeset/two-ghosts-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Add font-size utilities for Gutenberg block editor

.changeset/violet-schools-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': patch
3+
---
4+
5+
Fix issue where Gutenberg quote paragraphs were incorrectly sized

.style-dictionary/build.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ StyleDictionary.registerTransform({
4949
},
5050
});
5151

52+
/**
53+
* Custom Transform: Re-join negative number name segments
54+
* Looks for occurrences of `n-{number}` and removes the `-`. Useful for keeping
55+
* negative number modular scale step token names consistent with related class
56+
* names.
57+
*/
58+
StyleDictionary.registerTransform({
59+
name: 'custom/name/i/kebab-rejoin-n',
60+
type: 'name',
61+
transformer: function (prop) {
62+
return prop.name.replace(/-n-(\d)/g, '-n$1');
63+
},
64+
});
65+
5266
/**
5367
* Custom Transform Group: CSS
5468
* This is a modified version of the CSS transform group without the time,
@@ -57,7 +71,12 @@ StyleDictionary.registerTransform({
5771
*/
5872
StyleDictionary.registerTransformGroup({
5973
name: 'custom/transform-group/css',
60-
transforms: ['attribute/cti', 'name/cti/kebab', 'color/css'],
74+
transforms: [
75+
'attribute/cti',
76+
'name/cti/kebab',
77+
'custom/name/i/kebab-rejoin-n',
78+
'color/css',
79+
],
6180
});
6281

6382
/**
@@ -67,7 +86,12 @@ StyleDictionary.registerTransformGroup({
6786
*/
6887
StyleDictionary.registerTransformGroup({
6988
name: 'custom/transform-group/css-category',
70-
transforms: ['attribute/cti', 'custom/name/ti/kebab', 'color/css'],
89+
transforms: [
90+
'attribute/cti',
91+
'custom/name/ti/kebab',
92+
'custom/name/i/kebab-rejoin-n',
93+
'color/css',
94+
],
7195
});
7296

7397
/**
@@ -77,7 +101,12 @@ StyleDictionary.registerTransformGroup({
77101
*/
78102
StyleDictionary.registerTransformGroup({
79103
name: 'custom/transform-group/css-category-type',
80-
transforms: ['attribute/cti', 'custom/name/i/kebab', 'color/css'],
104+
transforms: [
105+
'attribute/cti',
106+
'custom/name/i/kebab',
107+
'custom/name/i/kebab-rejoin-n',
108+
'color/css',
109+
],
81110
});
82111

83112
/**

.style-dictionary/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ module.exports = {
8282
attributes: { category: 'number', type: 'font_weight' },
8383
},
8484
},
85+
{
86+
destination: '_line-height.scss',
87+
format: 'scss/variables',
88+
filter: {
89+
attributes: { category: 'number', type: 'line_height' },
90+
},
91+
},
8592
{
8693
destination: '_opacity.scss',
8794
format: 'scss/variables',

src/base/_defaults.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ figure {
258258
}
259259

260260
figcaption {
261-
font-size: ms.step(-1);
261+
font-size: size.$font-small;
262262
font-style: italic;
263263
text-align: center;
264264
}

src/base/_typography.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@use "_fonts";
22
@use "../compiled/tokens/scss/breakpoint";
33
@use "../compiled/tokens/scss/font-family";
4+
@use "../compiled/tokens/scss/line-height";
45
@use "../mixins/fluid";
56
@use "../mixins/headings";
67
@use "../mixins/ms";
@@ -31,7 +32,7 @@ html {
3132

3233
body {
3334
font-family: font-family.$sans-fallback;
34-
line-height: ms.step(2, 1);
35+
line-height: line-height.$loose;
3536
text-size-adjust: none; /* 1 */
3637
word-wrap: break-word; /* 2 */
3738

src/components/calendar-date/calendar-date.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use "../../compiled/tokens/scss/color";
22
@use "../../compiled/tokens/scss/font-weight";
3+
@use "../../compiled/tokens/scss/line-height";
34
@use "../../compiled/tokens/scss/size";
45
@use '../../mixins/ms';
56
@use '../../mixins/theme';
@@ -25,7 +26,7 @@ $radius: size.$border-radius-medium;
2526
flex-direction: column;
2627
font-weight: font-weight.$medium;
2728
height: $size;
28-
line-height: ms.step(1, 1);
29+
line-height: line-height.$tight;
2930
text-align: center;
3031
user-select: none;
3132
width: $size;
@@ -108,7 +109,7 @@ $radius: size.$border-radius-medium;
108109
*/
109110

110111
.c-calendar-date__note {
111-
font-size: ms.step(-1);
112+
font-size: size.$font-small;
112113
overflow: hidden; /* 1 */
113114
padding: 0 size.$spacing-control-text-inset;
114115
text-overflow: ellipsis; /* 1 */

src/components/ground-nav/ground-nav.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ $_ground-nav-border-color: color.$base-gray-light;
128128

129129
.c-ground-nav__kudos,
130130
.c-ground-nav__legal {
131-
font-size: ms.step(-1);
131+
font-size: size.$font-small;
132132
}
133133

134134
/**

0 commit comments

Comments
 (0)