You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[WP 6.1] Global Styles: Heading elements UI doesn't output fluid font size #44752
Verifying that I can also see a non-fluid size on the front end when I set the XXL, large or medium sizes via Styles > Typography > Heading, with Gutenberg deactivated. These all have fluid min and max values defined in theme.json.
I believe #44761 may fix this issue. I've just tested the above with this PR and I'm seeing fluid sizes.
The reason there's a discrepancy between the clamp value added in global styles, and the one generated for the preset --wp--preset--font-size--xx-large is that the preset defined extra parameters, such as the max and min fluid sizes.
This works insofar that it ensures that the clamp values are the same.
The caveat is that if the value is a custom font size (not a preset) and there's a matching preset size, the custom value will be converted to a clamp value using the preset's min and max values.
There's no way, at least for me, to know whether an incoming value is a custom value or a preset value.
This seems to me to be inconsistent, but perhaps an acceptable compromise?
Unless we want to be strict about this and dictate that all custom font size values should be treated differently, even custom font sizes that match possible preset font size values. If that's the case, I'm beginning to believe that it might be best to convert global font-size values before we save them, or, maybe save presets as var(--wp--preset--font-size--xx-large) 🤷
Activity
mikachan commentedon Oct 7, 2022
Verifying that I can also see a non-fluid size on the front end when I set the XXL, large or medium sizes via Styles > Typography > Heading, with Gutenberg deactivated. These all have fluid min and max values defined in theme.json.
I believe #44761 may fix this issue. I've just tested the above with this PR and I'm seeing fluid sizes.
mikachan commentedon Oct 7, 2022
Actually, I don't think the above PR does fix this issue 100%. I'm seeing fluid font sizes, but they're not the ones set in theme.json.
@andrewserong @ramonjd, pinging you in case you haven't seen this issue.
ramonjd commentedon Oct 8, 2022
I can confirm that #44761 partially fixes this.
@mikachan is right: the values are not the same.
The reason there's a discrepancy between the clamp value added in global styles, and the one generated for the preset --wp--preset--font-size--xx-large is that the preset defined extra parameters, such as the max and min fluid sizes.
Incoming from preset:
Output:
https://github.com/WordPress/gutenberg/pull/44761/files#diff-f28aa79997745a4a51f917012b45a809c9b45d55134b55379a718f5c751dddf4R1052 as it stands does not do this yet, so the clamp value is estimated:
Incoming from font size picker:
Output:
There is an unrelated UI bug as well. See "UNDEFINED"
ramonjd commentedon Oct 8, 2022
So, we could check the incoming custom value against the
fontSizespresets to grab any fluid parameters, e.g.,This works insofar that it ensures that the clamp values are the same.
The caveat is that if the value is a custom font size (not a preset) and there's a matching preset size, the custom value will be converted to a clamp value using the preset's min and max values.
There's no way, at least for me, to know whether an incoming value is a custom value or a preset value.
This seems to me to be inconsistent, but perhaps an acceptable compromise?
Unless we want to be strict about this and dictate that all custom font size values should be treated differently, even custom font sizes that match possible preset font size values. If that's the case, I'm beginning to believe that it might be best to convert global font-size values before we save them, or, maybe save presets as
var(--wp--preset--font-size--xx-large)🤷What do you reckon @andrewserong / @noisysocks ?
ramonjd commentedon Oct 8, 2022
I think I have a fix for all this over at #44791
Still testing...I think it works!
ya123123 commentedon Oct 13, 2022
The fluid font size now works in 6.1-RC1-54506. Thank you!
The output is
h1 {font-size: clamp(4rem, 4rem + ((1vw - 0.48rem) * 30.769), 20rem);}
I hope this value will be var() in the future.
ramonjd commentedon Oct 13, 2022
This is a good point, thanks! I'll add it as a follow up in:
ramonjd commentedon Oct 13, 2022
Resolved by: #44761