Skip to content

Commit 92a9bbd

Browse files
authored
Correct Gutenberg font size utility names (#1335)
1 parent 791563d commit 92a9bbd

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

.changeset/rare-lobsters-try.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 missing dashes in some Gutenberg font size utility class names

src/mixins/_ms.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
@return math.pow($ratio, $step) * $base;
66
}
77

8-
@function step-class-segment($step) {
8+
@function step-class-segment($step, $negative-prefix: 'n') {
99
$result: math.abs($step);
1010

1111
@if $step < 0 {
12-
$result: 'n#{$result}';
12+
$result: $negative-prefix + $result;
1313
}
1414

1515
@return $result;

src/vendor/wordpress/styles/_utilities.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ $color-map: meta.module-variables('color-base');
7070
}
7171

7272
@for $level from -2 through 3 {
73-
$level-segment: ms.step-class-segment($level);
73+
// WordPress treats numbers as separate segments in slugs, so we must add an
74+
// extra dash to negative number class segment prefixes
75+
$level-segment: ms.step-class-segment($level, 'n-');
7476

7577
.has-heading-#{$level-segment}-font-size {
7678
@include headings.level($level, false);

src/vendor/wordpress/utilities.stories.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const fontSizeControlConfig = {
1919
'',
2020
'big',
2121
'small',
22-
'heading-n2',
23-
'heading-n1',
22+
'heading-n-2',
23+
'heading-n-1',
2424
'heading-0',
2525
'heading-1',
2626
'heading-2',
@@ -63,7 +63,7 @@ When a background color is chosen, rounded corners and padding may be added (dep
6363

6464
## Font Size
6565

66-
We include `has-{font-size}-font-size` classes for our `big`, `small` and heading level [size tokens](/docs/design-tokens-size--page) to support [the `editor-font-sizes` feature](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#block-font-sizes).
66+
We include `has-{font-size}-font-size` classes for our `big`, `small` and heading level [size tokens](/docs/design-tokens-size--page) to support [the `editor-font-sizes` feature](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#block-font-sizes). Note that negative number class segments include an extra dash (`n-1` instead of `n1`) due to WordPress's kebab-case formatting of slugs.
6767

6868
<Canvas>
6969
<Story

0 commit comments

Comments
 (0)