-
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
Fluid typography: migrate fluid typography algorithm to JS for site editor #42688
Fluid typography: migrate fluid typography algorithm to JS for site editor #42688
Conversation
…_typography_font_size_value` to JS. We have to do this because the site editor is contained within an iframe and cannot, therefore, access the global CSS presets in the parent window.
Size Change: +713 B (0%) Total Size: 1.26 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.
Nice one, thanks for putting this up @ramonjd. I ran out of time to give this a proper review today, but just a drive by comment to say I think the failing Puppeteer test catches a change (or small regression?) in global styles.
With TwentyTwentyTwo active, and the fluid
size not opted-into, prior to this PR under Typography in global styles it shows Medium
as the default size. After this PR it shows Default
:
Before | After |
---|---|
Is that intentional?
Happy to test further tomorrow!
I'm able to confirm that I see the fluid typography size in the template editor as expected 👍 . |
Thank you @andrewserong and @matiasbenedetto for checking this branch out! 🙇 The code is a direct port from the PHP version. They have to be identical (at least as far as output is concerned) so I didn't put much refactoring effort into it. I was pleasantly surprised when it worked first time. 😆
Interesting. Thanks for catching. I'll take a looksy. |
… that the site editor can fetch values from the preset objects. Most notably these operations takes place in getValueFromPresetVariable() and getValueFromVariable()
I found the problem. To quote the commit message:
|
Ah, nice one! I'll take this for another spin shortly 👍 |
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 nicely @ramonjd!
✅ From reading the code, it looks like a faithful JS reproduction of the PHP logic to me 👍
✅ Medium (default) font size is still working correctly in the site editor in TwentyTwentyTwo, along with changing to existing font sizes.
✅ Emptytheme without fluid
still works the same as on trunk
.
✅ Emptytheme with fluid
sets the fluid values correctly in the site editor.
Values with fluid set to false |
Values with fluid set to true |
---|---|
LGTM! I left a tiny comment about a typo in a comment, but feel free to ignore it if there aren't any other things you want to change, so that you can merge without having to re-run the e2e tests 🙂
packages/edit-site/src/components/global-styles/typography-utils.js
Outdated
Show resolved
Hide resolved
…ls.js My blod is typo Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Fixes #42680
Follow up to
What?
Migrate fluid typography algorithm from PHP version of
gutenberg_get_typography_font_size_value
to JS.Why?
We have to do this because the site editor is contained within an iframe and cannot, therefore, access the global CSS presets in the parent window.
How?
Adding a value_func callback called
getTypographyFontSizeValue()
Testing Instructions
Enable fluid font sizes. Here is some test theme.json (I'm testing using empty theme).
Example theme.json
Head over to the site editor and add a post title, post author and post navigation link blocks.
The value of
--wp--preset--font-size--colossal
in the editor should match the frontend.