-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix for classic themes using default presets #2233
Fix for classic themes using default presets #2233
Conversation
Using If there are multiple ways to set a value that are conflicting and cause CSS specificity issues, then those need to become united so they can be resolved and reduce the bloat being output to the screen. If I am understanding correctly, the example you provided here:
The real problem seems to be that |
What about responsive typography styles? Should existing themes suffer due to |
That being said, I realize this is a PR for doing a quick fix for https://core.trac.wordpress.org/ticket/54782 and WordPress/gutenberg#38252 The issue of |
While the PR is working fine for all my tests (twentytwentytwo, twentytwenty, twentynineteen, storefront), I'm struggling to understand how to make the PHP unit tests pass. This is what I have:
There were 9 errors:
There were 4 failures: |
It sounds like the test environment is not deterministic (was set up in some jobs but not for others), and that's why there were inconsistencies in the tests. Setting the theme dir in the class makes all the tests that fail to fail for the same reasons. There's still some that pass, but this is progress. It narrows down the issues. |
This is now ready, tests have been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 The change looks good and worked well on my tests!
Committed at b7aa3a0. |
Should this PR be tagged Backport to WP Minor Release so it makes it in 5.9.1? The original issue WordPress/gutenberg#38252 has the tag but not the PR. |
@billerickson Unlike the gutenberg repository, this one doesn't use tags, everything happens in trac. See the corresponding ticket were this PR was discussed https://core.trac.wordpress.org/ticket/54782 This was ported to the 5.9 branch at https://core.trac.wordpress.org/changeset/52678 |
Fixes https://core.trac.wordpress.org/ticket/54782
Alternative to #2140 #2158 and #2154
What this PR does
This PR proposes that the presets provided by the theme via
add_theme_support
always create CSS Custom Properties, whether or not the theme has atheme.json
file.The end result is that, for a theme like TwentyTwenty, these are the changes:
Note how the existing defaults provided by the theme are set to the theme value plus there are new CSS Custom Properties for the presets defined by the theme but not by core.
Context
WordPress 5.9 introduced a change for themes with no
theme.json
that redefined the default presets provided by WordPress. Before, the default presets were:In WordPress 5.9 they are:
The rationale for this change was to fix the following issue: some blocks (and theme) selectors can have higher specificity than user styles attached to blocks.
For example,
.wp-block-post-title h1
has higher specificity than.has-small-font-size
. However, we want user styles applied to a block to prevail at all times over any other style. We considered alternatives but none were satisfactory. It was also discussed in this thread.Other options considered
The current approach to this issue has been: communication (e.g.: WordPress 5.9 devnote in addition to sharing it previously in GitHub/Slack/forums/etc). Eventually, themes that want to redefine the default presets provided by WordPress and don't use
theme.json
would need to be updated.This PR takes a different approach: can WordPress set the CSS Custom Properties for these themes automatically?
How to test
Test this both using WordPress 5.9 and the TwentyTwenty theme (can use any other theme that doesn't have a
theme.json
and redefines the default presets provided by core).Font sizes
small
to the 1st paragraph,normal
to the 2nd, nothing to the third,large
to the 4th, andlarger
to the 5th.The expected result is that the font size for each paragraph has the assigned value, both in the editor and front-end.
Colors
has-white-background-color has-black-color
into the "Additional classes" text field of the "Advanced" section of the block sidebar.has-black-background-color has-white-color
into the "Additional classes" text field of the "Advanced" section of the block sidebar.Via the browser devtools make sure that the first paragraph's color is
rgb(0,0,0)
and its background isrgb(255,255,255)
. The second paragraph should be the opposite.