Skip to content

Commit 9f47287

Browse files
Fix for WordPress "small" utility conflict (#2183)
Co-authored-by: Scott Vandehey <[email protected]>
1 parent b9b210b commit 9f47287

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.changeset/dirty-deers-turn.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+
Prevent WordPress from overriding the "small" font size utility styles.

src/mixins/_font-size.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
/// To prevent small text from impairing readability (most importantly) and our
1818
/// Core Web Vitals (secondarily), we only apply the small font size if it isn't
1919
/// smaller than 16 pixels.
20-
@mixin small {
21-
font-size: max(16px, size.$font-small);
20+
///
21+
/// @param {Boolean} $important - Whether or not to output the rule with an
22+
/// `!important` flag. Added to satisfy WordPress 5.9+.
23+
/// @link https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/
24+
@mixin small($important: false) {
25+
@if $important {
26+
font-size: max(16px, size.$font-small) !important;
27+
} @else {
28+
font-size: max(16px, size.$font-small);
29+
}
2230
}

src/vendor/wordpress/styles/_utilities.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,15 @@ $color-map: meta.module-variables('color-base');
8282
@include font-size.big;
8383
}
8484

85+
/// We need to use `!important` because otherwise WordPress will override this
86+
/// size as of version 5.9. We could get around this by setting the font size
87+
/// via `theme.json`, but that would make this an outlier among our other sizes,
88+
/// so for now we'll just use `!important`.
89+
///
90+
/// @link https://make.wordpress.org/core/2022/01/08/updates-for-settings-styles-and-theme-json/
91+
8592
.has-small-font-size {
86-
@include font-size.small;
93+
@include font-size.small($important: true);
8794
}
8895

8996
@for $level from -2 through 3 {

0 commit comments

Comments
 (0)