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

Commit

Permalink
Product Elements: Fix block settings (#7914)
Browse files Browse the repository at this point in the history
* Product Elements: Fix block settings

* Rating: Fix inactive star color

* Product Rating: Fix color inheritance
  • Loading branch information
danieldudzic authored Dec 12, 2022
1 parent 4d45864 commit 96c68b4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
2 changes: 0 additions & 2 deletions assets/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@

.wc-block-grid__product-rating {
display: block;
color: #000;

.wc-block-grid__product-rating__stars,
.star-rating {
Expand All @@ -118,7 +117,6 @@
right: 0;
position: absolute;
opacity: 0.5;
color: #aaa;
white-space: nowrap;
}
span {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/atomic/blocks/product-elements/price/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const blockConfig = {
...( isFeaturePluginBuild() && {
color: {
text: true,
background: false,
background: true,
link: false,
__experimentalSkipSerialization: true,
},
Expand Down
1 change: 1 addition & 0 deletions assets/js/base/hooks/use-typography-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const useTypographyProps = ( attributes: unknown ): WithStyle => {
: typography.fontSize,
lineHeight: typography.lineHeight,
fontWeight: typography.fontWeight,
fontStyle: typography.fontStyle,
textTransform: typography.textTransform,
fontFamily: attributesObject.fontFamily,
},
Expand Down
2 changes: 1 addition & 1 deletion src/BlockTypes/ProductButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function render( $attributes, $content, $block ) {
if ( $product ) {
$cart_redirect_after_add = get_option( 'woocommerce_cart_redirect_after_add' ) === 'yes';
$html_element = ( ! $product->has_options() && $product->is_purchasable() && $product->is_in_stock() && ! $cart_redirect_after_add ) ? 'button' : 'a';
$styles_and_classes = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array( 'border_radius', 'font_size', 'text_color' ) );
$styles_and_classes = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array( 'border_radius', 'font_size', 'font_weight', 'padding', 'text_color' ) );
$text_align_styles_and_classes = StyleAttributesUtils::get_text_align_class_and_style( $attributes );

return apply_filters(
Expand Down
11 changes: 7 additions & 4 deletions src/BlockTypes/ProductPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ protected function render( $attributes, $content, $block ) {
$product = wc_get_product( $post_id );

if ( $product ) {
$classes_and_styles = StyleAttributesUtils::get_text_align_class_and_style( $attributes );
$styles_and_classes = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array( 'font_size', 'font_weight', 'font_style', 'text_color', 'background_color' ) );
$text_align_styles_and_classes = StyleAttributesUtils::get_text_align_class_and_style( $attributes );

return sprintf(
'<div class="wc-block-components-product-price wc-block-grid__product-price %1$s">
%2$s
'<div class="wc-block-components-product-price wc-block-grid__product-price %1$s %2$s" style="%3$s">
%4$s
</div>',
esc_attr( $classes_and_styles['class'] ?? '' ),
esc_attr( $text_align_styles_and_classes['class'] ?? '' ),
esc_attr( $styles_and_classes['classes'] ),
esc_attr( $styles_and_classes['styles'] ?? '' ),
$product->get_price_html()
);
}
Expand Down
11 changes: 7 additions & 4 deletions src/BlockTypes/ProductRating.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,16 @@ protected function render( $attributes, $content, $block ) {
);

if ( $product ) {
$classes_and_styles = StyleAttributesUtils::get_text_align_class_and_style( $attributes );
$styles_and_classes = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array( 'font_size', 'margin', 'text_color' ) );
$text_align_styles_and_classes = StyleAttributesUtils::get_text_align_class_and_style( $attributes );

return sprintf(
'<div class="wc-block-components-product-rating wc-block-grid__product-rating %s">
%s
'<div class="wc-block-components-product-rating wc-block-grid__product-rating %1$s %2$s" style="%3$s">
%4$s
</div>',
esc_attr( $classes_and_styles['class'] ?? '' ),
esc_attr( $text_align_styles_and_classes['class'] ?? '' ),
esc_attr( $styles_and_classes['classes'] ),
esc_attr( $styles_and_classes['styles'] ?? '' ),
wc_get_rating_html( $product->get_average_rating() )
);
}
Expand Down

0 comments on commit 96c68b4

Please sign in to comment.