This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Rating Product block: Add support for global style #5521
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e9d7c30
Product title: add support global style #4965
gigitux 517f80a
add specific type
gigitux 48709c7
add custom save function
gigitux c5c65b4
Merge branch 'add/4965-product-title' of github.com:woocommerce/wooco…
gigitux 70bb739
Rating Product block: add support for global style #4965
gigitux 9b8fadf
add feature flag
gigitux e3dd2c5
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
gigitux 23f9587
fix import after merge
gigitux da5c7a5
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
gigitux 33b6b61
fix global style css generation
gigitux 98416dc
restore css for classic product rating html element
gigitux 00c6648
Merge branch 'trunk' of github.com:woocommerce/woocommerce-gutenberg-…
gigitux eebfd45
don't apply the global style to PHP blocks
gigitux e1091ab
remove registration
gigitux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,6 @@ | |
left: 0; | ||
right: 0; | ||
position: absolute; | ||
color: #000; | ||
white-space: nowrap; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
import classnames from 'classnames'; | ||
|
||
type Props = { | ||
attributes: Record< string, unknown > & { | ||
className?: string; | ||
}; | ||
}; | ||
|
||
export const Save = ( { attributes }: Props ): JSX.Element => { | ||
return ( | ||
<div | ||
{ ...useBlockProps.save( { | ||
className: classnames( 'is-loading', attributes.className ), | ||
} ) } | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
assets/js/atomic/blocks/product-elements/rating/support.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { isFeaturePluginBuild } from '@woocommerce/block-settings'; | ||
|
||
export const supports = { | ||
...( isFeaturePluginBuild() && { | ||
color: { | ||
text: true, | ||
background: false, | ||
link: false, | ||
}, | ||
} ), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace Automattic\WooCommerce\Blocks\BlockTypes; | ||
|
||
/** | ||
* ProductRating class. | ||
*/ | ||
class ProductRating extends AbstractBlock { | ||
|
||
/** | ||
* Block name. | ||
* | ||
* @var string | ||
*/ | ||
protected $block_name = 'product-rating'; | ||
|
||
/** | ||
* API version name. | ||
* | ||
* @var string | ||
*/ | ||
protected $api_version = '2'; | ||
|
||
/** | ||
* Get the editor script handle for this block type. | ||
* | ||
* @param string $key Data to get, or default to everything. | ||
* @return array|string; | ||
*/ | ||
protected function get_block_type_editor_script( $key = null ) { | ||
$script = [ | ||
'handle' => 'wc-' . $this->block_name . '-block', | ||
'path' => $this->asset_api->get_block_asset_build_path( 'atomic-block-components/rating' ), | ||
'dependencies' => [ 'wc-blocks' ], | ||
]; | ||
return $key ? $script[ $key ] : $script; | ||
} | ||
|
||
/** | ||
* Get block supports. Shared with the frontend. | ||
* IMPORTANT: If you change anything here, make sure to update the JS file too. | ||
* | ||
* @return array | ||
*/ | ||
protected function get_block_type_supports() { | ||
return array( | ||
'color' => | ||
array( | ||
'text' => true, | ||
'background' => false, | ||
'link' => false, | ||
), | ||
'__experimentalSelector' => '.wc-block-components-product-rating', | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,6 +178,7 @@ protected function get_block_types() { | |
'ProductTitle', | ||
'ProductSummary', | ||
'ProductStockIndicator', | ||
'ProductRating', | ||
]; | ||
|
||
if ( Package::feature()->is_feature_plugin_build() ) { | ||
|
@@ -222,7 +223,6 @@ 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 commentThe 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-sku', | ||
'product-category-list', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Removing this line changes the color of the stars in product grid blocks.
All Products block without styles applied:
Top Rated Products block:
Do you think there is any way to keep this declaration while getting global styles to work?
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.