-
Notifications
You must be signed in to change notification settings - Fork 471
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
Stop theme defaults from overriding the Featured Item blocks text color #2039
Conversation
Note: The Featured Items blocks are omitted from the customizer styles here via a The way that the blocks are structured, the |
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.
Thank you for adding loads of docs to the filters. I understand that this is a quick patch, but I'm not entirely convinced by this approach. It kinda heavily breaks the separation of concerns. Also, what's the responsibility hierarchy here? Should themes make sure they are playing well with plugins, or should plugins be aware of themes? It seems that we create a weird precedent by excluding certain classes and potentially make it very hard to scale.
Perhaps having a more generic class to be excluded from this style rule? Maybe less specificity?
I'm not sure what's the best solution here, but I also think I am not 100% clear on the hierarchy of all the pieces coming together.
@@ -1067,7 +1246,7 @@ public function block_editor_customizer_css() { | |||
/* WP <=5.3 */ | |||
.editor-styles-wrapper .editor-block-list__block, | |||
/* WP >=5.4 */ | |||
.editor-styles-wrapper .block-editor-block-list__block { | |||
.editor-styles-wrapper .block-editor-block-list__block:not(.wp-block-woocommerce-featured-product):not(.wp-block-woocommerce-featured-category) { |
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.
This also works I believe :)
.editor-styles-wrapper .block-editor-block-list__block:not(.wp-block-woocommerce-featured-product):not(.wp-block-woocommerce-featured-category) { | |
.editor-styles-wrapper .block-editor-block-list__block:not(.wp-block-woocommerce-featured-product, .wp-block-woocommerce-featured-category) { |
@sunyatasattva thanks for your thoughts on this, you raise some very good points! While the
Yes, I really like this thought. Ideally, we’d target the The issue when I looked at this route was that the Perhaps a better way forward is to still target this
I know I owe a post on this to kick off a broader discussion - I’ll do this today. IMO, it makes sense here for the theme to ensure it’s working with plugins. For example, the theme should not output dark text in scenarios where it will lack contrast (i.e., over a dark background. When we tried to prevent this from the plugin side, it caused an issue with Global Styles, which seems more confusing for the user. In this particular instance, even if we did nothing and allowed for the theme to output poorly contrasted text by default for these blocks, it is adjustable via the editor controls in an intuitive way. |
Excellent thoughts, @danielwrobert. Thanks for taking the time to write them down and indulge me on this. I know it's just as easy to approve this small change and swipe it under the rug, but I feel it is important that we share thoughts on such things.
I also thought that class would make more sense. In this way other plugins and blocks can still use the Would it just not work leaving the class where it is currently? Would CSS rules not apply then to what we want to target?
I would tend to agree with this. It's really hard, though, right? Because the point of a theme is that it would give a consistent style and—well…—“theme” to the website. So I understand how conflicts like this can arise. |
@sunyatasattva not without the use of some “cutting-edge” (Level 4) CSS selectors, from what I can tell. The theme applies the color rule to the main block container in the editor. For the theme, we could target the child div with the That's why I noted the
Unfortunately, this isn't currently as supported as we'd need - although it is getting there! To remedy any support concerns, we could include a sensible fallback for the time being by either letting unsupported browsers override the text (essentially ignoring the problem in unsupported browsers until they update) or temporarily add the specific selector for the Featured Items that I set in this PR originally:
OR
Yeah, this seems like it could be a good route if the above options with |
Alright, in that case I think your workaround with the fallback sounds best to me. Eventually, I think we probably will fade out Storefront in favor of a default blocktheme I assume, right? I'd say for now it doesn't make much sense to block you any further. The fallback option works for me. |
I assume so. And as themes continue to head in that direction, I imagine that will make the aforementioned responsibility hierarchy questions a bit more clear. It seems like we're still in a bit of an in-between state with everything. FWIW, I also think we'll see improved support for
Thank you! I haven't super concerned about being blocked - I enjoy thinking all of this through and am more interested in making a good decision. I appreciate the conversation and your thoughts! 🙂 |
This resolves PHP linting errors.
Confirmed that the featured items WooCommerce blocks are the only Woo blocks with a dark overlay. By omiting them from the ruleset that sets the default text color, we allow the block to use it's set default of white text over the background overlay, improving color contrast.
Instead of directly targeting the Featured Items blocks, we can use the `:has()` selector to omit blocks that contain a child div with the `has-background-dim` class in the editor. Since browser support is not to where we need at the time of publishing this, we can also add a temp fallback with `@supports`.
f95234f
to
4fab27f
Compare
7686569
to
5b604f7
Compare
@sunyatasattva I've updated this PR in 4fab27f to use the approach discussed above. Also note that the docblock updates were handled in #2038. I originally branched from that update so I could commit my changes here w/o the linter screaming at me and preventing my commits. After merging that PR and rebasing this one with |
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.
Thanks @danielwrobert for putting up with me and for the clean PR!
I think we can go ahead with this.
Summary
By omitting the Featured Items blocks from the Storefront Customizer ruleset that sets the default text color, we allow the block to use it's set default of white text over the background overlay, improving color contrast. This also allows custom and global styles to be applied correctly, where applicable.
Fixes #2036
Screenshots
How to test the changes in this Pull Request:
Changelog