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

Commit

Permalink
Fix Mini Cart Block global styles #7379
Browse files Browse the repository at this point in the history
Fix Mini Cart Block global styles
  • Loading branch information
gigitux committed Oct 28, 2022
1 parent 7717169 commit 76a8193
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
7 changes: 1 addition & 6 deletions assets/js/blocks/mini-cart/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ const MiniCartBlock = ( attributes: Props ): JSX.Element => {
color: style?.color?.text,
};

const typographyProps = useTypographyProps( attributes );

return (
<>
<button
Expand All @@ -221,10 +219,7 @@ const MiniCartBlock = ( attributes: Props ): JSX.Element => {
aria-label={ ariaLabel }
>
{ ! hasHiddenPrice && (
<span
className="wc-block-mini-cart__amount"
style={ typographyProps.style }
>
<span className="wc-block-mini-cart__amount">
{ formatPrice(
subTotal,
getCurrencyFromPriceResponse( cartTotals )
Expand Down
5 changes: 1 addition & 4 deletions assets/js/blocks/mini-cart/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
<Noninteractive>
<button className="wc-block-mini-cart__button">
{ ! hasHiddenPrice && (
<span
className="wc-block-mini-cart__amount"
style={ typographyProps.style }
>
<span className="wc-block-mini-cart__amount">
{ formatPrice( productTotal ) }
</span>
) }
Expand Down
1 change: 0 additions & 1 deletion assets/js/blocks/mini-cart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const settings: BlockConfiguration = {
...( isFeaturePluginBuild() && {
__experimentalFontFamily: true,
__experimentalFontWeight: true,
__experimentalSkipSerialization: true,
} ),
},
},
Expand Down
6 changes: 4 additions & 2 deletions assets/js/blocks/mini-cart/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
display: flex;
font-size: inherit;
font-family: inherit;
font-weight: 400;
font-weight: inherit;
padding: em($gap-small) em($gap-smaller);

&:hover:not([disabled]) {
Expand All @@ -19,6 +19,8 @@
}

.wc-block-mini-cart__amount {
font-size: inherit;
font-weight: inherit;
display: none;
}

Expand All @@ -29,7 +31,7 @@
@media screen and (min-width: 768px) {
.wc-block-mini-cart__amount {
display: initial;
font-weight: 600;
font-weight: inherit;
margin-right: $gap-smaller;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/BlockTypes/MiniCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ protected function get_cart_price_markup( $attributes ) {
$cart_controller = $this->get_cart_controller();
$cart = $cart_controller->get_cart_instance();
$cart_contents_total = $cart->get_subtotal();
$typography_styles = isset( StyleAttributesUtils::get_font_weight_class_and_style( $attributes )['style'] ) ? StyleAttributesUtils::get_font_weight_class_and_style( $attributes )['style'] : null;

return '<span class="wc-block-mini-cart__amount" style="' . esc_attr( $typography_styles ) . '">' . esc_html( wp_strip_all_tags( wc_price( $cart_contents_total ) ) ) . '</span>
return '<span class="wc-block-mini-cart__amount">' . esc_html( wp_strip_all_tags( wc_price( $cart_contents_total ) ) ) . '</span>
' . $this->get_include_tax_label_markup();
}

Expand Down

0 comments on commit 76a8193

Please sign in to comment.