Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Featured Items: Remove inline style defaults for color options #7036

Merged
merged 2 commits into from
Sep 9, 2022

Conversation

danielwrobert
Copy link
Contributor

@danielwrobert danielwrobert commented Sep 1, 2022

This replaces the inline style in the Featured Product and Featured Category blocks with an editor-specific styling that has a bit more specificity - but not too much to where it overrides the Site Editor styles.

Fixes #7042

Screenshots

Before After
CleanShot 2022-09-01 at 14 31 05 CleanShot 2022-09-01 at 14 35 45

Testing

  1. Ensure you have a block theme active (i.e., Twenty Twenty-Two).
  2. Go to Appearance > Editor (Beta).
  3. Click on the Global Styles panel and select the Blocks section.
  4. Scroll down to the Featured Product or Featured Category block and edit the text and the background Global Styles.
  5. Confirm that both the text and background colors reflect the changes from the sidebar controls.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Changelog

Featured Item Blocks: remove inline default color so that custom colors from Global Styles are applied correctly.

@danielwrobert danielwrobert added needs feedback focus: global styles Issues that involve styles/css/layout structure. labels Sep 1, 2022
@danielwrobert danielwrobert self-assigned this Sep 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2022

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-7036.zip

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2022

Size Change: -35 B (0%)

Total Size: 875 kB

Filename Size Change
build/featured-category.js 13.2 kB -17 B (0%)
build/featured-product.js 13.5 kB -18 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 7.65 kB
build/active-filters.js 8.3 kB
build/all-products-frontend.js 18.1 kB
build/all-products.js 33.9 kB
build/all-reviews.js 7.8 kB
build/attribute-filter-frontend.js 22.3 kB
build/attribute-filter.js 13.3 kB
build/blocks-checkout.js 17.4 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.16 kB
build/cart-blocks/cart-express-payment-frontend.js 5.09 kB
build/cart-blocks/cart-items-frontend.js 299 B
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.25 kB
build/cart-blocks/cart-line-items-frontend.js 429 B
build/cart-blocks/cart-order-summary-frontend.js 1.11 kB
build/cart-blocks/cart-totals-frontend.js 322 B
build/cart-blocks/empty-cart-frontend.js 346 B
build/cart-blocks/filled-cart-frontend.js 783 B
build/cart-blocks/order-summary-coupon-form-frontend.js 2.64 kB
build/cart-blocks/order-summary-discount-frontend.js 2.15 kB
build/cart-blocks/order-summary-fee-frontend.js 274 B
build/cart-blocks/order-summary-heading-frontend.js 454 B
build/cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping-frontend.js 6.37 kB
build/cart-blocks/order-summary-shipping-frontend.js 428 B
build/cart-blocks/order-summary-subtotal-frontend.js 274 B
build/cart-blocks/order-summary-taxes-frontend.js 435 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.15 kB
build/cart-frontend.js 47.1 kB
build/cart.js 41.8 kB
build/checkout-blocks/actions-frontend.js 1.42 kB
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.12 kB
build/checkout-blocks/billing-address-frontend.js 892 B
build/checkout-blocks/contact-information-frontend.js 2.84 kB
build/checkout-blocks/express-payment-frontend.js 5.39 kB
build/checkout-blocks/fields-frontend.js 344 B
build/checkout-blocks/order-note-frontend.js 1.08 kB
build/checkout-blocks/order-summary-cart-items-frontend.js 3.64 kB
build/checkout-blocks/order-summary-coupon-form-frontend.js 2.79 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.27 kB
build/checkout-blocks/order-summary-fee-frontend.js 276 B
build/checkout-blocks/order-summary-frontend.js 1.11 kB
build/checkout-blocks/order-summary-shipping-frontend.js 602 B
build/checkout-blocks/order-summary-subtotal-frontend.js 274 B
build/checkout-blocks/order-summary-taxes-frontend.js 434 B
build/checkout-blocks/payment-frontend.js 7.7 kB
build/checkout-blocks/shipping-address-frontend.js 1.03 kB
build/checkout-blocks/shipping-methods-frontend.js 4.74 kB
build/checkout-blocks/terms-frontend.js 1.23 kB
build/checkout-blocks/totals-frontend.js 326 B
build/checkout-frontend.js 49.2 kB
build/checkout.js 43.2 kB
build/general-style-rtl.css 1.29 kB
build/general-style.css 1.29 kB
build/handpicked-products.js 7.37 kB
build/legacy-template.js 2.86 kB
build/mini-cart-component-frontend.js 16.8 kB
build/mini-cart-contents-block/empty-cart-frontend.js 366 B
build/mini-cart-contents-block/filled-cart-frontend.js 230 B
build/mini-cart-contents-block/footer--mini-cart-contents-block/products-table-frontend.js 4.69 kB
build/mini-cart-contents-block/footer-frontend.js 6.98 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 290 B
build/mini-cart-contents-block/shopping-button-frontend.js 288 B
build/mini-cart-contents-block/title-frontend.js 368 B
build/mini-cart-contents.js 22.8 kB
build/mini-cart-frontend.js 1.72 kB
build/mini-cart.js 4.58 kB
build/price-filter-frontend.js 13.4 kB
build/price-filter.js 9.32 kB
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 223 B
build/product-add-to-cart--product-button--product-image--product-title.js 2.66 kB
build/product-add-to-cart-frontend.js 6.95 kB
build/product-add-to-cart.js 6.88 kB
build/product-best-sellers.js 7.71 kB
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 435 B
build/product-button--product-image--product-rating--product-sale-badge--product-title.js 300 B
build/product-button-frontend.js 1.87 kB
build/product-button.js 1.57 kB
build/product-categories.js 2.41 kB
build/product-category-list-frontend.js 883 B
build/product-category-list.js 502 B
build/product-category.js 8.69 kB
build/product-image-frontend.js 1.88 kB
build/product-image.js 1.59 kB
build/product-new.js 7.71 kB
build/product-on-sale.js 8.02 kB
build/product-price-frontend.js 1.9 kB
build/product-price.js 1.51 kB
build/product-query.js 648 B
build/product-rating-frontend.js 1.17 kB
build/product-rating.js 739 B
build/product-sale-badge-frontend.js 1.13 kB
build/product-sale-badge.js 801 B
build/product-search.js 2.65 kB
build/product-sku-frontend.js 380 B
build/product-sku.js 379 B
build/product-stock-indicator-frontend.js 996 B
build/product-stock-indicator.js 623 B
build/product-summary-frontend.js 1.29 kB
build/product-summary.js 920 B
build/product-tag-list-frontend.js 876 B
build/product-tag-list.js 497 B
build/product-tag.js 8.09 kB
build/product-title-frontend.js 1.31 kB
build/product-title.js 921 B
build/product-top-rated.js 7.95 kB
build/products-by-attribute.js 8.63 kB
build/reviews-by-category.js 11.2 kB
build/reviews-by-product.js 12.3 kB
build/reviews-frontend.js 7.02 kB
build/single-product-frontend.js 21.4 kB
build/single-product.js 10 kB
build/stock-filter-frontend.js 7.62 kB
build/stock-filter.js 7.55 kB
build/vendors--cart-blocks/cart-line-items--cart-blocks/cart-order-summary--cart-blocks/order-summary-shi--c02aad66-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js 4.85 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js 19.1 kB
build/vendors--mini-cart-contents-block/footer-frontend.js 6.86 kB
build/vendors--product-add-to-cart-frontend.js 7.53 kB
build/wc-blocks-data.js 9.87 kB
build/wc-blocks-editor-style-rtl.css 5.1 kB
build/wc-blocks-editor-style.css 5.1 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 931 B
build/wc-blocks-registry.js 2.7 kB
build/wc-blocks-shared-context.js 1.53 kB
build/wc-blocks-shared-hocs.js 1.71 kB
build/wc-blocks-style-rtl.css 23.8 kB
build/wc-blocks-style.css 23.7 kB
build/wc-blocks-vendors-style-rtl.css 1.95 kB
build/wc-blocks-vendors-style.css 1.95 kB
build/wc-blocks-vendors.js 54.5 kB
build/wc-blocks.js 2.63 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB

compressed-size-action

@danielwrobert danielwrobert changed the title Remove Featured Items inline style defaults for color options Featured Items: Remove inline style defaults for color options Sep 1, 2022
@danielwrobert danielwrobert added block: featured category Issues related to the Featured Category block, block: featured product Issues related to the Featured Product block. type: bug The issue/PR concerns a confirmed bug. and removed needs feedback labels Sep 1, 2022
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your research in this tricky issue, @danielwrobert! I took an initial look at this PR, but it seems like the global style changes (made in the site editor) aren't reflected in the frontend. Can you reproduce as well?

Editor Frontend
imatge imatge

@danielwrobert
Copy link
Contributor Author

danielwrobert commented Sep 2, 2022

@Aljullu no I can not reproduce what you're seeing. I'm getting the expected result:

Editor Frontend
CleanShot 2022-09-01 at 14 35 45 Screen Shot 2022-09-02 at 8 42 42 AM

Do you happen to have the Gutenberg feature plugin active? That is a separate issue where the latest version seems to prevent Woo and Jetpack blocks from properly rendering Global Styles to the frontend.

@danielwrobert danielwrobert force-pushed the update/feat-item-color-defaults branch 2 times, most recently from 4a03834 to 1ff3c6b Compare September 2, 2022 22:30
@danielwrobert danielwrobert marked this pull request as ready for review September 2, 2022 22:30
@rubikuserbot rubikuserbot requested review from a team and Aljullu and removed request for a team September 2, 2022 22:31
Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad, you are right. The issue was from Gutenberg (for reference, it's this one: WordPress/gutenberg#40808). Disabling GB fixes it.

Confirming this PR fixes the issue.

Comment on lines 8 to 10
.editor-styles-wrapper .wp-block-woocommerce-featured-category {
@extend %wp-block-featured-item;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the purpose of this ruleset is only intended to fix #6489, I wonder if we should make it explicit in some way (maybe with a comment?).

Also, not blocking but wondering if instead of implementing this work-around here, we could update Storefront to avoid causing this issue. The problem seems to be that this ruleset has too much specificity and messes up the Featured Product/Category blocks, right? Maybe we could refactor that code from Storefront in some way? (I didn't really investigate that, just thinking out loud in case you have an idea, @danielwrobert 🙂 )

Copy link
Contributor Author

@danielwrobert danielwrobert Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the purpose of this ruleset is only intended to fix #6489, I wonder if we should make it explicit in some way (maybe with a comment?).

@Aljullu this still really doesn't fix #6489 on Storefront's side of things. I really only added this ruleset in to add a little bit more specificity to the styles in the editor, more generally, but it should still work the same way without this.

Thinking about it more, I'll go ahead and remove this ruleset from the editor stylesheet because it's not really consistent with everything else and this styling is intended for both the frontend and admin.

Also, not blocking but wondering if instead of implementing this work-around here, we could update Storefront to avoid causing this issue.

Yes, that's 100% my thinking. IMO, the theme styles should be responsible to ensure they are not unintentionally overriding global (or other) settings. I noted this on the #7042 but should have reiterated my point here.

So next steps: I'll go ahead and remove the editor styles from this PR, as they're not really necessary, and merge. Then I'll make a note on #6489 (for posterity) and open a new issue on Storefront to address the problem you noted with the overly specific ruleset there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused, this PR seems to reintroduce #6489. It's not clear to me if that's a known issue or not.

imatge

So next steps: I'll go ahead and remove the editor styles from this PR, as they're not really necessary, and merge. Then I'll make a note on #6489 (for posterity) and open a new issue on Storefront to address the problem you noted with the overly specific ruleset there.

It sounds good to me, but wondering if we should prioritize this fix in Storefront. Otherwise that would be a regression. 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused, this PR seems to reintroduce #6489. It's not clear to me if that's a known issue or not.

@Aljullu that's correct. The issue is that the way the initial fix for #6489 was handled (via inline style attributes) prevents the global styles from being applied in the editor - which can be more confusing for users, IMO.

The idea here is to revert back to the original color rules and then handle the issue in #6489 on the Storefront side. Generally, it seems better to handle theme-specific issues from the theme side, since we won't be able to account for what different themes do that may override our plugin styles.

I agree that this should be prioritized in Storefront. I am planning on getting that going today so it doesn't get put on the back-burner and the regression gets rolled out to our users.

I can even hold off on merging this until the Storefront PR is further along, if you think that'd be better?

Additionally, @sunyatasattva suggested a broader conversation on P2 around how we prioritize styles overall, which I plan to post as a follow-up as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your explanation makes sense, sorry if I misunderstood it before. Your next steps look good to me.

I can even hold off on merging this until the Storefront PR is further along, if you think that'd be better?

I will leave this up to you. Storefront has a shorter release process, so I think we are good if we merge this PR as-is and work on a fix in SF afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks for the follow-up! I've created an Issue on Storefront and assigned myself to address ASAP.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea just to chime in here as well, I think it is unclear what is the expected hierarchy between styles, and who should be concerned of being compatibile with what. Should themes make sure they are compatible with plugins or viceversa? I think we should probably come up with a scalable solution for these cases in general. 🤔

Copy link
Contributor Author

@danielwrobert danielwrobert Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunyatasattva I agree! I'll kick off a broader P2 discussion around this today.

For this particular PR, the default color styles preventing the Global Styles from working seems a bit more confusing for a user, as opposed to allowing a theme's defaults to override and impact the color contrast of the Featured Items blocks.

I'm totally open to being convinced otherwise and I'm also not opposed to closing this PR out if it doesn't seem like a good way to go!

Overall, it's a bit of a tricky situation where we want the Global Styles to function as expected while also preventing themes from overriding the default colors with poor contrast.

I'm actually wondering if it's acceptable to move forward with removing this default and not worry about the overriding color contrast issue in Storefront? In that scenario the user still has control to adjust the text color and the background overlay, as needed.

Alternatively, we could also remove the dark background overlay default as well and leave all of the color adjustments to the user when they are using the block. I'm not certain this is a good option, just throwing it out there. I'd love to hear your thoughts!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 100% with you: definitely default color preventing Global Styles is a mistake. Not providing a sensible default… I'd be against that. How all these variables interact with each other… that's where it gets really tricky and it's definitely a philosophical question at this point :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 100% with you: definitely default color preventing Global Styles is a mistake.

Since this seems to be the general consensus, I will go ahead and merge this PR to resolve that problem.

We can then continue to explore the best route forward for the text overriding issue with Storefront in this discussion.

This replaces the inline style with an added editor-specific styling
with slightly more specificity - but not too much to where it overrides
the Site Editor.
These styles are meant to apply to both the frontend and the editor. The
ruleset was originally added to the editor stylesheet to add an
additional layer of specificity but it was decided that this is
unnecessary.
@danielwrobert danielwrobert force-pushed the update/feat-item-color-defaults branch from 800daad to fd7b463 Compare September 9, 2022 15:40
@danielwrobert danielwrobert merged commit f27456d into trunk Sep 9, 2022
@danielwrobert danielwrobert deleted the update/feat-item-color-defaults branch September 9, 2022 17:15
@gigitux gigitux added the type: enhancement The issue is a request for an enhancement. label Sep 12, 2022
senadir pushed a commit to senadir/woocommerce-blocks that referenced this pull request Nov 12, 2022
…mmerce#7036)

* Remove inline style defaults for color options.

This replaces the inline style with an added editor-specific styling
with slightly more specificity - but not too much to where it overrides
the Site Editor.

* Remove additional styles from editor stylesheet.

These styles are meant to apply to both the frontend and the editor. The
ruleset was originally added to the editor stylesheet to add an
additional layer of specificity but it was decided that this is
unnecessary.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: featured category Issues related to the Featured Category block, block: featured product Issues related to the Featured Product block. focus: global styles Issues that involve styles/css/layout structure. type: bug The issue/PR concerns a confirmed bug. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Featured Items: Inline style color defaults override Global Styles
4 participants