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 (#7515)
Browse files Browse the repository at this point in the history
* Fix Mini Cart Block global styles #7379

Fix Mini Cart Block global styles

* add font_size
  • Loading branch information
gigitux committed Oct 31, 2022
1 parent f601de4 commit 938c7c2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
8 changes: 1 addition & 7 deletions assets/js/blocks/mini-cart/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { renderParentBlock } from '@woocommerce/atomic-utils';
import Drawer from '@woocommerce/base-components/drawer';
import { useStoreCart } from '@woocommerce/base-context/hooks';
import { useTypographyProps } from '@woocommerce/base-hooks';
import { translateJQueryEventToNative } from '@woocommerce/base-utils';
import { getRegisteredBlockComponents } from '@woocommerce/blocks-registry';
import {
Expand Down Expand Up @@ -205,8 +204,6 @@ const MiniCartBlock = ( attributes: Props ): JSX.Element => {
color: style?.color?.text,
};

const typographyProps = useTypographyProps( attributes );

return (
<>
<button
Expand All @@ -221,10 +218,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
8 changes: 1 addition & 7 deletions assets/js/blocks/mini-cart/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import { getSetting } from '@woocommerce/settings';
import { __ } from '@wordpress/i18n';
import Noninteractive from '@woocommerce/base-components/noninteractive';
import { useTypographyProps } from '@woocommerce/base-hooks';

/**
* Internal dependencies
Expand Down Expand Up @@ -44,8 +43,6 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
const productCount = 0;
const productTotal = 0;

const typographyProps = useTypographyProps( attributes );

return (
<div { ...blockProps }>
<InspectorControls>
Expand Down Expand Up @@ -127,10 +124,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
5 changes: 3 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 @@ -29,7 +29,8 @@
@media screen and (min-width: 768px) {
.wc-block-mini-cart__amount {
display: initial;
font-weight: 600;
font-size: inherit;
font-weight: inherit;
margin-right: $gap-smaller;
}
}
Expand Down
6 changes: 2 additions & 4 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 Expand Up @@ -358,7 +356,7 @@ protected function get_markup( $attributes ) {
$cart_contents_total += $cart->get_subtotal_tax();
}

$classes_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array( 'text_color', 'background_color', 'font_size', 'font_family' ) );
$classes_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array( 'text_color', 'background_color', 'font_size', 'font_weight', 'font_family' ) );
$wrapper_classes = sprintf( 'wc-block-mini-cart wp-block-woocommerce-mini-cart %s', $classes_styles['classes'] );
if ( ! empty( $attributes['className'] ) ) {
$wrapper_classes .= ' ' . $attributes['className'];
Expand Down

0 comments on commit 938c7c2

Please sign in to comment.