-
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
Use a var for user presets to avoid having to use ! important to enforce them #40335
Changes from all commits
eac7bbd
a85b9bb
aa5d11f
4094d69
d001b4d
c0e0c9f
33cc9c4
f30a53c
2606b2d
874cc1e
40cf176
38a5047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* Load the user preset styles separately with lower priority to they will be more | ||
* likely to load after any theme css that they need to override. | ||
*/ | ||
|
||
function gutenberg_enqueue_user_preset_styles() { | ||
$presets_stylesheet = gutenberg_get_global_stylesheet( array( 'presets' ) ); | ||
|
||
wp_register_style( 'use-preset-styles', false, array(), true, true ); | ||
wp_add_inline_style( 'use-preset-styles', $presets_stylesheet ); | ||
wp_enqueue_style( 'use-preset-styles' ); | ||
} | ||
add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_user_preset_styles', 100 ); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,10 @@ | |
background-color: $black; | ||
} | ||
|
||
[class*="-background-color"] { | ||
background-color: var(--wp--user--preset--background-color); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why we do this if the cover block doesn't have any block supports related to this (color, background)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a side effect of the potentially premature optimisation of |
||
} | ||
|
||
.has-background-dim.has-background-gradient { | ||
background-color: transparent; | ||
} | ||
|
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.
If the goal is to prevent overriding the preset classes defined by a theme (if they enqueue any), why do we try to load the core preset classes after?
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.
It's so they come later in the cascade and win specificity over any previous styles without using
!important
or an ID selector. This is common practice for using utility-style CSS alongside traditional styles: Bootstrap, ITCSS