Skip to content
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: add font size constraints #44957

Closed
ramonjd opened this issue Oct 14, 2022 · 7 comments · Fixed by #44993
Closed

Fluid typography: add font size constraints #44957

ramonjd opened this issue Oct 14, 2022 · 7 comments · Fixed by #44993
Assignees
Labels
[Feature] Typography Font and typography-related issues and PRs [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended

Comments

@ramonjd
Copy link
Member

ramonjd commented Oct 14, 2022

Parent issue:

What problem does this address?

Where fluid typography is enabled, minimum and maximum font sizes in presets can be calculated according to defined min and max values, e.g.,

{
    "size": "2rem",
    "fluid": {
        "min": "2rem",
        "max": "2.5rem"
    },
    "slug": "medium",
     "name": "Medium"
 },

For the above preset, the font size, regardless of the viewport, will not be larger than 2.5rem and it will not be smaller than 2rem.

Where min and max values are not supplied, either in theme.json font size presets or as a custom font size in styles, the min and max values are calculated from the size itself, e.g., minFontSize * DEFAULT_MINIMUM_FONT_SIZE_FACTOR.

Where the size is itself very large or very small, this could lead to readability issues in certain viewports.

2022-10-14.12.49.49.mp4

The use of em for example might also cause issues if the relative parent's font size is set very small.

What is your proposed solution?

Add default minimum (and maximum?) font size limits so that text does not become smaller than n1 or bigger than n2.

Proposed minimum font size is 14px/0.875rem/0.875em.

The default limits can be configurable to allow themers more control and added in conjunction with:

❗ What do we do with font sizes < 14px?

Users may define font-sizes that are smaller than 14px. IThe user-defined font size could be the minimum in a clamped value. For example if a user defines 9px for a block, then the minimum font size for that block will be 9px and a clamped value will be generated.

OR

Where users define font-sizes that are smaller than 14px in the editor or theme.json, and there is no specified minimum the value is not clamped (no fluidity).

cc @jasmussen @jffng

@ramonjd ramonjd added the [Feature] Typography Font and typography-related issues and PRs label Oct 14, 2022
@jasmussen
Copy link
Contributor

Oh yes, good issue. Let's get this bug fixed asap, it makes no sense to not have a size-floor for the default boolean fluid toggle, and the ability to customize this floor on a per-preset basis strikes a great balance.

@jasmussen jasmussen added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention labels Oct 14, 2022
@annezazu
Copy link
Contributor

Added to the Core Editor triage board and noted in the 6.1 release leads channel.

@ramonjd
Copy link
Member Author

ramonjd commented Oct 14, 2022

Just to be clear, and to properly plan this task, do folks think this fix should be shipped with WordPress 6.1 or a follow up minor release, e.g., 6.1.1?

Thanks!

@annezazu
Copy link
Contributor

I think 6.1 if we can make it :) I don't see a reason not to since it's definitely a bug.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 15, 2022
@ramonjd ramonjd added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Oct 16, 2022
@ndiego
Copy link
Member

ndiego commented Oct 17, 2022

Yeah, I second a 6.1 inclusion if possible. Personally, I feel that Fluid Typography is a banner feature for 6.1 and it would be good to get it as polished as possible.

@ramonjd
Copy link
Member Author

ramonjd commented Oct 17, 2022

Interested to hear opinions on how we deal with user-defined font sizes that are smaller than the prescribed minimum. Discussion over on the PR: #44993 (comment)

cc @mtias

@ramonjd
Copy link
Member Author

ramonjd commented Oct 19, 2022

Hi folks!

I have a Core backport here: WordPress/wordpress-develop#3489

Any assistance you can provide to usher it along would be greatly appreciated. 🙇

@annezazu annezazu added the Backport to WP Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 19, 2022
@priethor priethor removed Backport to WP Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Status] In Progress Tracking issues with work in progress labels Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants