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

Commit

Permalink
fix global style css generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Feb 7, 2022
1 parent da5c7a5 commit 33b6b61
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
1 change: 0 additions & 1 deletion assets/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
left: 0;
right: 0;
position: absolute;
color: #000;
white-space: nowrap;
}
}
Expand Down
4 changes: 3 additions & 1 deletion assets/js/atomic/blocks/product-elements/rating/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ const Block = ( props ) => {
<div
className={ classnames(
className,
colorProps.className,
'wc-block-components-product-rating',
{
[ `${ parentClassName }__product-rating` ]: parentClassName,
}
) }
style={ colorProps.style }
>
<div
className={ classnames(
Expand All @@ -78,7 +80,7 @@ const Block = ( props ) => {
aria-label={ ratingText }
>
<span
style={ { ...starStyle, ...colorProps.style } }
style={ starStyle }
dangerouslySetInnerHTML={ ratingHTML }
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion assets/js/atomic/blocks/product-elements/rating/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
right: 0;
position: absolute;
opacity: 0.5;
color: #aaa;
color: inherit;
white-space: nowrap;
}
span {
Expand All @@ -32,6 +32,7 @@
left: 0;
right: 0;
position: absolute;
color: inherit;
padding-top: 1.5em;
}
span::before {
Expand Down
56 changes: 56 additions & 0 deletions src/BlockTypes/ProductRating.php
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',
);
}

}
2 changes: 1 addition & 1 deletion src/BlockTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ protected function get_block_types() {
'ProductTitle',
'ProductSummary',
'ProductStockIndicator',
'ProductRating',
];

if ( Package::feature()->is_feature_plugin_build() ) {
Expand Down Expand Up @@ -222,7 +223,6 @@ protected function get_atomic_blocks() {
'product-button',
'product-image',
'product-price',
'product-rating',
'product-sale-badge',
'product-sku',
'product-category-list',
Expand Down

0 comments on commit 33b6b61

Please sign in to comment.