WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.5k stars 4.2k forks source link

Fluid Typography: Derived clamp() calculation for min font size should be based on layout contentSize but instead seems hardcoded against 320px #52706

Closed porg closed 1 year ago

porg commented 1 year ago

Description

As I understood it, the fluid typography feature in theme.json allows one to just set a min and a max per each fluid enabled font size definition at settingstypographyfontSizes , and the system derives/calculates the necessary clamp() function by correlating the min/max values against: settings → layout: contentSize + wideSize.

https://css-tricks.com/fluid-typography-wordpress-block-themes/#aa-declaring-fluid-type-in-a-wordpress-block-theme


I checked the calculated font size at different viewports both in Safari, Chrome:

Step-by-step reproduction instructions

theme.json

Derived CSS

var(--wp--preset--font-size--medium): 
clamp(1rem, 1rem + ((1vw - 0.2rem) * 0.227), 1.125rem);

Screenshots, screen recording, code snippet

Spreadsheet calculations/observations: fluid-typography.xlsx

Fluid Typo min for clamp calculation seems hardcoded

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

t-hamano commented 1 year ago

Hi @porg,

At the time you reported this issue, the wideSize was indeed taken into account in the fluid typography calculation, but I believe the small viewport width was a fixed value.

However, #53081 would allow you to define minimum and maximum viewport widths. This should be included in Gutenberg plugin 16.5, so please give it a try when that version is released.

I would like to close this issue, but if I have missed something, please comment.

porg commented 1 year ago

Yes the linked PR fixes the main aspects of my issue.

I also left a comment there on my remaining open concern that:

it should be possible that minViewportWidth and maxViewportWidth can take variable values like contentSize and wideSize or the defined breakpoint variables to have a synchronized design experience with no need to manually update numerical values in multiple places.

Please tune into that last open discussion point there. Thanks.