-
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
Unset inherited backgrounds on social icons. #37940
Conversation
Size Change: +37 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
@@ -6,6 +6,11 @@ | |||
// Some themes give all <ul> default margin instead of padding. | |||
margin-left: 0; | |||
|
|||
// Unset background colors that can be inherited from Global Styles with extra specificity. | |||
&.wp-block-social-links { | |||
background: none; |
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.
Can we lower this to be just a single .wp-block-social-links
selector like the rules above? I don't think that it makes a big difference tbh but it's nice in case anyone does want to target it directly.
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.
I'm fairly sure that when I tried, that didn't have enough specificity. Let me just verify that.
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.
On investigation, in the editor it gets specificity to override this rule:
.editor-styles-wrapper ol, .editor-styles-wrapper ul {
background-color: var(--wp--preset--color--vivid-green-cyan);
}
On the frontend, it need only override this rule:
ol, ul {
background-color: var(--wp--preset--color--vivid-green-cyan);
}
I can change it so we have a low-specificity reset in style.scss, and higher specificity in editor.scss, sound good?
As a separate or alternative, we could look at how to reduce how editor styles are output, perhaps :where(.editor-styles-wrapper) ul
, etc.?
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.
I have similar thoughts as to #37941 (review)
00406fc
to
14e4306
Compare
I rebased this one, and per feedback moved the extra specific rule to editor.scss only, so the frontend can maintain low specificity. Let me know if this is preferred over the single rule. Editor: In both of the above screenshots, a green background is inherited, but unset. |
This sounds good: a theme will need to wrap its styles with |
Cool, I'll land this, and I'll take a look at some adjacent Navigation block issues when I have a moment! |
This is great to have been merged. Thanks! However, I do think it's important to point out that the underlying issue also impacts every third-party block that uses list markup. For example, I will now need to apply this "patch" to my Social Sharing Block., which is a fork of the core Social Icons block. Not a huge deal, but important for block developers to be aware of. |
The original issue is intentionally not closed. As I've noted I personally think the underlying issue is sufficiently addressed, it'd be good to keep it open until we get a feel for this solution, and whether it lets us reach some consensus or not. It'll also let other ideas keep trickling in 👍 👍 |
Description
If you set the List block to have a specific background color in global styles, the
ul
block is targetted, making that color bleed into the Social Icons block:As an alternative approach to #37528, this PR unsets any inherited background colors in the social icons block, stopping the cascade:
How has this been tested?
Change the background color of the List block in global styles. Then insert a Social Icons block, it should still have a transparent background.
Checklist:
*.native.js
files for terms that need renaming or removal).