-
Notifications
You must be signed in to change notification settings - Fork 219
Rating Product block: Add support for global style #5521
Conversation
…mmerce-gutenberg-products-block into add/4965-rating-product
Rating Product block: add support for global style
Size Change: +454 B (0%) Total Size: 816 kB
ℹ️ View Unchanged
|
…products-block into add/4965-rating-product
b901166
to
23f9587
Compare
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 is working great, and I really like the style hooks you created and how clean the code looks. 👏
The only issue I found is that when using the Product Rating block inside the All Products block, the color doesn't seem to be applied. What's weird is that Product title styles do work, so the issue is only in the Product Rating block:
Any idea what might be going on?
…products-block into add/4965-rating-product
It is fixed now! |
f82aa78
to
33b6b61
Compare
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 for updating this PR, @gigitux! Confirming it's working now. I just left one last comment regarding the color of the stars having changed in blocks without global styles. 👇
@@ -143,7 +143,6 @@ | |||
left: 0; | |||
right: 0; | |||
position: absolute; | |||
color: #000; |
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.
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 for catching this!
I restored the previous CSS with 84f00de commit.
I forgot that we have some components that display product ratings on the PHP side (as ´Top Rated Products` block). Now the global style will be applied on PHP side blocks too (but as default the color will be black)
I'm not sure about the screenshot that you shared.
I checked the trunk and I see always black stars. Can you check again?
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.
Ah, not sure what I did to get that color. 😅 It was in Storefront but I checked it again and it's dark-gray as the other blocks.
84f00de
to
98416dc
Compare
@@ -562,7 +562,7 @@ protected function get_rating_html( $product ) { | |||
|
|||
if ( $rating_count > 0 ) { | |||
return sprintf( | |||
'<div class="wc-block-grid__product-rating">%s</div>', | |||
'<div class="wc-block-grid__product-rating wc-block-components-product-rating">%s</div>', |
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 noticed this change makes it so the color is also changed in ratings displayed inside the PHP product grid blocks. IMO Product rating global styles should only change the styles of the Product rating block, but they shouldn't impact any other rating component.
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.
Ok! I will revert this change
@@ -143,7 +143,6 @@ | |||
left: 0; | |||
right: 0; | |||
position: absolute; | |||
color: #000; |
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.
Ah, not sure what I did to get that color. 😅 It was in Storefront but I checked it again and it's dark-gray as the other blocks.
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.
Confirming the issue is fixed now, I still left one additional comment about the selector we use for the styles. I think we should intentionally apply the global styles only to the Product Rating block, instead of applying to any product rating component displayed in any block.
…products-block into add/4965-rating-product
Size Change: +688 B (0%) Total Size: 816 kB
ℹ️ View Unchanged
|
Ok! I just reverted the change on |
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.
LGTM! I left one comment that needs to be addressed, but pre-approving. 👍
src/BlockTypesController.php
Outdated
@@ -234,7 +235,7 @@ protected function get_atomic_blocks() { | |||
'product-button', | |||
'product-image', | |||
'product-price', | |||
'product-rating', | |||
'product-sale-badge', |
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 had to remove this line, otherwise I was getting an error telling me product-sale-badge
was registered twice:
( ! ) Notice: WP_Block_Type_Registry::register was called <strong>incorrectly</strong>. Block type "woocommerce/product-sale-badge" is already registered. Please see <a href="https://wordpress.org/support/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 5.0.0.) in .../Local Sites/latest/app/public/wp-includes/functions.php on line 5768
This PR is blocked by #5515This PR adds support for global style for the
Rating Product
block.Now, the user can edit the style for:
Fixes #4965
Screenshots
without global style
with global style
Testing
Manual Testing
Check out this branch:
WordPress 5.9
, install and enable theGutenberg
plugin.Twenty Twenty-Two
theme.Single Product block
(this block containsRating Product block
) to a post.Rating Product block
.Reset
button from the different sections.Styles
icon on the right-top corner.Rating Product block
is shown under theBlocks
section. Personalize again the block.Changelog