-
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: adjust font size min and max rules #45536
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: -38 B (0%) Total Size: 1.29 MB
ℹ️ View Unchanged
|
257dc09
to
f6dcac0
Compare
Hi, @ramonjd I just wanted to check the status of this PR. Do you think it will be ready for the next minor release? The WP 6.1.1 RC is scheduled for this Friday. |
Hi @Mamaduka, Thanks for checking in. I cannot honestly say. As it stands, this PR is ready to test, and will need thorough testing to ensure it meets folks' expectations. If it turns out that things are working well, then I see no impediment for the minor release. It all depends on the feedback, and the work needed to implement the feedback. |
70ce728
to
2684da7
Compare
@@ -461,7 +461,6 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty | |||
$default_maximum_viewport_width = '1600px'; | |||
$default_minimum_viewport_width = '768px'; | |||
$default_minimum_font_size_factor = 0.75; | |||
$default_maximum_font_size_factor = 1.5; |
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.
Removed since we never need to compute the max size. We fallback to the incoming "size" or single/custom value. See issue: #45504
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.
Thanks for the ping, and working on this @ramonjd! Just gave this a quick skim and manual test, and it seems to be working nicely! Left a couple of tiny nits about comments, but nothing major there 🙂
One thing that might be good to get feedback from designers on is whether the scaling multiplier still reduces font sizes enough across viewport sizes. The effect seems a little subtle to me now when setting quite a large font size for the largest viewport size. Whereas before I think because we had the max value scaling up from the desired font-size, there was a greater variance between the computed min and max sizes. To put it simply: now that the selected font size is set for max
instead of the middle value, is 0.75
the right multiplier to use, or should it be a smaller fraction?
This is a good question, and I'm not sure what the right fallback min font size multiplier should be. The motivation behind this PR was to give more meaning to the value a user enters, in other words, so that what they see on the screen has a closer relationship with the value they entered. Given that, how much smaller could we get away with in relation to the min font size multiplier without contradicting this principle? So I agree that feedback from themers/designers is crucial here. For those with the time and inclination to test this particular aspect, the default min font size factor (how we auto-generate min font sizes in the absence of an explicit value) can be tweaked:
There's another PR #42489 in the works that will allow the min font size multiplier to be configurable via theme.json. |
Thanks for the update, @ramonjd! Let's ping the @WordPress/block-themers group for more feedback. |
Why did we choose |
Took this for a spin, works well, and feels totally safe to me as a point release improvement, mainly in that it fixes the main headache around using custom font sizes. I set a custom font size to 36px, and it clamps between 27 and 36.
No strong opinion, and happy to defer. As an addendum: even with 16px as the minimum clampable value, it will always be possible for themes to create presets smaller than this, and users to likewise set custom font sizes at nigh unreadable sizes. I like to think we have an opportunity to educate rather than predicate, for example by showing either clarifying help-text, or a contrast-like warning, in the custom font size control. Not something that I think need block this PR. |
Thanks @aristath and @jasmussen
I just tested with Example, when I select Should I bump it to cc @tellthemachines for thoughts |
6e89b81
to
863d9ae
Compare
154e3ba
to
01fc69f
Compare
Do folks think this one is good to merge, based on the feedback in the issue? |
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 code looks good to me, and happy to approve it based on the gathered feedback 👍
@ramonjd, will you be able to create the Core backport patch for this?
- Where no fluid max values are set (e.g., single or custom font size values), the "size" value will act as the maximum value in a clamp() function. - Do not clamp value if a font size is lower than 14px - Always honor a supplied fluid.min value, the lower bound of 14px notwidthstanding
Thank you @Mamaduka !!! I have prepped the PHP backport patch over here: WordPress/wordpress-develop#3602 |
- Where no fluid max values are set (e.g., single or custom font size values), the "size" value will act as the maximum value in a clamp() function. - Do not clamp value if a font size is lower than 14px - Always honor a supplied fluid.min value, the lower bound of 14px notwidthstanding
Just checking, is there a 6.1.1 release branch or somewhere we need to cherry pick the JS changes into? I see there are few PRs with the "Backport to WP Minor Release" label. |
I will cherry-pick the change on the Gutenberg repo, not a problem :) |
* Initial commit. No tests. * Update PHP unit tests * Updating JS tests Harmonizing test descriptions across PHP and JS Updated CHANGELOG.md and README.md * Updating global styles JS tests * Update typography props JS units tests to reflect new max value * Aligning comments acrossing PHP and JS and making sure they're clearer. Bumping the lower bound from 14px to 16px Updating tests * Updating global styles tests * Revert "Updating global styles tests" This reverts commit 72d4a38. * Revert "Aligning comments acrossing PHP and JS and making sure they're clearer." This reverts commit 863d9ae.
* Initial commit. No tests. * Update PHP unit tests * Updating JS tests Harmonizing test descriptions across PHP and JS Updated CHANGELOG.md and README.md * Updating global styles JS tests * Update typography props JS units tests to reflect new max value * Aligning comments acrossing PHP and JS and making sure they're clearer. Bumping the lower bound from 14px to 16px Updating tests * Updating global styles tests * Revert "Updating global styles tests" This reverts commit 72d4a38. * Revert "Aligning comments acrossing PHP and JS and making sure they're clearer." This reverts commit 863d9ae.
What?
Part of
Resolves #45504
>16px
. This applies to custom values from the editor or single-value theme.json styles. Font sizes below this will not be clamped.fluid.min
value has been specified, the lower bound rule of>16px
won't be enforced on this value. Presets with a fluid object therefore, give precedence to theme author's values.fluid.max
but there isfluid.min
, use the incoming"size"
value as the max.fluid.min
but there is afluid.max
, usesize * min_size_factor
as the min. Here we do enforce the lower bound rule of>16px
, because Gutenberg is computing the min value. This is consistent with the way we calculate minimum sizes for single or custom values.Testing Instructions
Example theme.json
Add some text blocks to the editor, apply presets and custom sizes, and ensure they:
Please test by playing around with: