-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Root Padding CSS Properties should follow the established pattern #49801
Comments
@oandregal, can you share more context behind this decision? |
Unfortunately, I don't have any. However, by looking at the code changes, it sounds like this PR is the first that introduced those variables. I'm tentatively pinging the people involved there in case they have any context @tellthemachines @ramonjd @andrewserong Also they are the spacing/padding/layout masterminds, so, hopefully, they'll know their way around. |
Once we hear back from folks, and if we decide to update this as proposed – if the original code owners don't have the time to address it, I'd be happy to. I come up against this a lot when I'm in the flow of writing my styles and want to reference the generated CSS Custom Properties, and would want to participate in expediting its fix. :) Edit: I connected a tentative PR, anyway. Just in case. |
Thanks for writing up this issue, it's a good discussion to have! From a quick skim here are some other CSS variables that our output or used in Gutenberg and theme.json:
I don't feel too strongly about it, but from a quick glance, it seems that the use of the CSS property name in the existing variables is consistent with the above, where One potential issue with exploring renaming the variables is if there are existing themes already referencing the current property names. |
The other thing to consider is that it is possible to set single-value padding as a shorthand in theme.json, like so:
Although the implementation is inconsistent due to not allowing multi-value shorthand (see #40132) this is another reason for the current format. Regarding back compat, a quick check of WP directory shows some themes are already using these properties, so we'd have to continue supporting the old format even if we changed it. |
@andrewserong, I see what you mean there. Another interpretation: let's take The other variables still follow the established pattern of a
I'm not sure why being able to set a single value would prohibit us from following the established patterns for the variables. Maybe I'm not understanding the point, could you elaborate more, @tellthemachines?
This is true, the same way the |
You mention above that "top, right, bottom, and left are keys inside the padding object" as a reason for the change. I'm pointing out that it's not always the case: padding can also be defined as a string. |
What problem does this address?
The process to set padding values in the
styles.spacing
section oftheme.json
is as follows:This outputs the following CSS Custom Properties:
However, according to the established pattern which is also documented in the Block Editor Handbook, what should actually have been generated is:
Because
top
,right
,bottom
, andleft
are keys inside thepadding
object.Padding
effectively is the category here (to use the language of the Block Editor Handbook), and while in CSS, we are used topadding-right
,padding-left
etc,theme.json
should adhere to its own conventions first for consistency, predictability, and a better developer experience.What is your proposed solution?
Adjust the parser so that the
padding
CSS Custom Properties (and any others that break established convention like this) are output correctly, with categories and their children being separated by--
.The text was updated successfully, but these errors were encountered: