-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global styles: convert preset font size values to CSS vars #44967
Global styles: convert preset font size values to CSS vars #44967
Conversation
6ca7f1d
to
1b8469c
Compare
Size Change: +310 B (0%) Total Size: 1.29 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing pretty well for me @ramonjd! Just left a couple of comments, one nit, and one question about whether we should also allow this behaviour on themes that haven't opted-in to fluid typography.
Also, since this updates the font size picker in the components package, shall we add a changelog entry, too?
I'll just CC @ciampo and @mirka in case they have input about the update to the signature of the onChange
callback, too 🙂
Thanks for the follow-up, it'll be great to store the var:
form of fluid values in particular, rather than the clamp()
value, and it'll be really good to have this in there for when we eventually allow custom control over the fluid typography rules, too 👍
packages/edit-site/src/components/global-styles/typography-panel.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/global-styles/typography-panel.js
Outdated
Show resolved
Hide resolved
Thank you for the ping! Regarding the
Yes! On top of that, I think it would be great if we could coordinate with @noisysocks and his PR adding more better unit tests so that we can add good test coverage for this change too. Another preference is to try and keep changes to |
af9a739
to
5839acd
Compare
Thanks for the reminder about the changelog, folks! I had intended to get unit tests done, but might wait until #45298 is merged until I do. 🙇 |
#45298 is merged! The test coverage for |
5839acd
to
0f991ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FontSizePicker
's code changes are looking good! I'll let @noisysocks give the final blessing ✨
e2da9f7
to
3a574fd
Compare
@noisysocks Could you give this one a sanity check? Also pass your eye on the fix for the issue highlighted in #44966 (comment) Thank you, sir! |
…d of the clamp value in global styles.
…nd values. Ensure that we allow presets for all font size preset, not only while fluid typography is activated
…tSize object argument.
…d to pass the immediate, currently-selected font size object containing preset slug information to the consuming parent component. Updated tests. General post-rebase chicanery
…o clampify incoming values for the site editor font size picker
bf85ece
to
09692b7
Compare
packages/edit-site/src/components/global-styles/typography-panel.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FontSizePicker
code changes look good. I gave it a spin and see var()
values that point to clamp()
values when selecting a preset and clamp()
values when inputting a custom font size.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, this is testing well for me @ramonjd!
✅ Tested that setting existing preset values for Typography in global styles prior to applying this PR results in those preset values still showing up as selected after applying this PR
✅ Tested that with this PR applied, setting Typography based on presets works as expected, the CSS var is applied rather than the raw clampified value, and after a reload the selected values display as they should.
LGTM, and I like the suggestion from @noisysocks to potentially rename the hook, too 👍
Parent issue: #44888
Context: #44752 (comment)
What?
This PR converts font size presets to
var:preset|font-size|${slug}
values so that they can be parsed bygetValueFromVariable
and converted tovar(--wp--preset--font-size--${slug}
) values.Why?
Why not?
At the moment we're saving the raw value. When fluid is turned on this means we're saving the
clamp()
value.CSS vars are there. Why not use them?
Testing
In the site editor, apply a font size preset to an element/block in global styles (not block styles)
Check that we're using the preset CSS variable, and not the raw font size value.