Make WordPress Core

Opened 7 weeks ago

Closed 7 weeks ago

Last modified 7 weeks ago

#61932 closed enhancement (fixed)

Fluid typography: allow individual preset overrides

Reported by: ramonopoly's profile ramonopoly Owned by: ramonopoly's profile ramonopoly
Milestone: 6.7 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch has-unit-tests gutenberg-merge
Focuses: css Cc:

Description

Individual font sizes may opt out of fluid typography if it is turned on globally.

Individual font size presets should also be able to opt in to fluid typography if it is not turned on globally.

See the original Gutenberg issue:

https://github.com/WordPress/gutenberg/issues/64766

Change History (4)

This ticket was mentioned in PR #7247 on WordPress/wordpress-develop by @ramonopoly.


7 weeks ago
#1

This PR syncs the following Gutenberg PR:

## What?

This PR allows individual font preset overrides.

So, if fluid typography is disabled or not active but an individual font preset does enable it, calculate the clamp value for that individual preset.

## Why?

Individual font sizes may opt out of fluid typography if it is turned on globally.

This PR does the opposite: individual font size presets can opt in to fluid typography if it is not turned on globally.

## How?

Check if fluid settings on individual font size presets are present.

## Testing Instructions

  1. In a theme's theme.json, enable fluid typography for some individual font size presets by adding "fluid": true to the preset object. See the below example theme.json.
  2. Make sure fluid typography is not enabled globally in the general "settings.typography" settings.
  3. In the editor, apply some of your presets.
  4. The presets that have fluid settings should have fluid font sizes in the editor and the frontend.
  5. The presets that have no fluid settings should behave as static font sizes.

[!NOTE]
This only affects the frontend site, not the editor.

<details>

<summary>Here is some test theme.json</summary>

{
        "$schema": "https://schemas.wp.org/trunk/theme.json",
        "version": 3,
        "settings": {
                "typography": {
                        "fontSizes": [
                                {
                                        "name": "Big bill",
                                        "size": "59px",
                                        "slug": "big-bill"
                                },
                                {
                                        "name": "Medium Matt",
                                        "size": "30px",
                                        "slug": "med-matt",
                                        "fluid": true
                                },
                                {
                                        "name": "Small Ted",
                                        "size": "1rem",
                                        "slug": "small-ted",
                                        "fluid": {
                                                "max": "60px",
                                                "min": "30px"
                                        }
                                }
                        ]
                }
        }
}

</details>

Trac ticket: https://core.trac.wordpress.org/ticket/61932

@ramonopoly commented on PR #7247:


7 weeks ago
#2

Thanks for testing! I'll update those small things.

I'm assuming it's just a copy pasta from the Gutenberg PR.

You assume correctly 😄 I'll update.

#3 @ramonopoly
7 weeks ago

  • Owner set to ramonopoly
  • Resolution set to fixed
  • Status changed from new to closed

In 58950:

Fluid typography: allow individual preset overrides

In theme.json, individual font sizes may opt out of fluid typography if it is turned on globally.

This commit ensures that individual font size presets can also opt in to fluid typography if it is not turned on globally.

Props aaronrobertshaw, mmaattiiaass, ramonopoly, wildworks.

Fixes #61932.

Note: See TracTickets for help on using tickets.