Skip to content

Commit

Permalink
Stop theme defaults from overriding the Featured Item blocks text col…
Browse files Browse the repository at this point in the history
…or (#2039)

* Add docblocks to hooks used in customizer class.

This resolves PHP linting errors.

* Omit feat items blocks from txt color selector

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.

* Refactor to use :has() selector.

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`.

* Remove/resolve items from merge conflict.
  • Loading branch information
danielwrobert committed Sep 14, 2022
1 parent 7c32db4 commit a21262e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion inc/customizer/class-storefront-customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1246,9 +1246,15 @@ 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(:has(div.has-background-dim)) {
color: ' . $storefront_theme_mods['text_color'] . ';
}
/* This following ruleset is a fallback for browsers that do not support the :has() selector. It can be removed once support reaches our requirements. */
@supports not (selector(:has(*))) {
.editor-styles-wrapper .block-editor-block-list__block:not(.wp-block-woocommerce-featured-product, .wp-block-woocommerce-featured-category) {
color: ' . $storefront_theme_mods['text_color'] . ';
}
}
.editor-styles-wrapper a,
.wp-block-freeform.block-library-rich-text__tinymce a {
Expand Down

0 comments on commit a21262e

Please sign in to comment.