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

Update global padding CSS Custom Properties to adhere to established theme.json patterns #49809

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

aurooba
Copy link
Member

@aurooba aurooba commented Apr 13, 2023

What?

This PR updates the way styles.spacing.padding properties are parsed from theme.json into CSS Custom Properties so that they adhere to the established rules on how CSS Custom Properties are generated from theme.json.

Why?

The process to set padding values in the styles.spacing section of theme.json is as follows:

  "styles": {
    "spacing": {
      "padding": {
        "top": "1rem",
        "right": "1rem",
        "bottom": "1rem",
        "left": "1rem"
      }
    }
  },

This outputs the following CSS Custom Properties:

    --wp--style--root--padding-top: 1rem;
    --wp--style--root--padding-right: 1rem;
    --wp--style--root--padding-bottom: 1rem;
    --wp--style--root--padding-left: 1rem;

However, according to the established pattern which is also documented in the Block Editor Handbook, what should actually have been generated is:

    --wp--style--root--padding--top: 1rem;
    --wp--style--root--padding--right: 1rem;
    --wp--style--root--padding--bottom: 1rem;
    --wp--style--root--padding--left: 1rem;

Because top, right, bottom, and left are keys inside the padding object. Padding effectively is the category here (to use the language of the Block Editor Handbook), and while in CSS, we are used to padding-right, padding-left etc, theme.json should adhere to its own conventions first for consistency, predictability, and a better developer experience.

How?

This is to close #49801, if accepted as the right proposal. Right now the Global Padding variables don't follow the rules set out for how the rest of theme.json properties are converted into CSS Custom Properties. This fixes that by adding a -- between padding and the key after.

Testing Instructions

  1. Go to the front-end of a WordPress website
  2. Inspect the CSS Code
  3. See that in body the following properties are outputted:
    --wp--style--root--padding--top
    --wp--style--root--padding--right
    --wp--style--root--padding--bottom
    --wp--style--root--padding--left

Testing Instructions for Keyboard

Not applicable

Screenshots or screencast

@aurooba aurooba changed the title Uupdate root-padding css properties to adhere to theme.json pattern Update root-padding css properties to adhere to theme.json pattern Apr 13, 2023
@aurooba aurooba changed the title Update root-padding css properties to adhere to theme.json pattern Update global padding CSS Custom Properties to adhere to established theme.json patterns Apr 13, 2023
@skorasaurus skorasaurus added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Nov 3, 2023
Copy link

github-actions bot commented Nov 3, 2023

Warning: Type of PR label error

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: CSS Styling.

Read more about Type labels in Gutenberg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Root Padding CSS Properties should follow the established pattern
2 participants