From dd2e1a97f14d8be84efba65c587570c4a2b47bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alba=20Rinc=C3=B3n?= Date: Thu, 23 Mar 2023 12:16:26 +0100 Subject: [PATCH] Refactor variants --- .../mini-cart-cart-button-block/block.tsx | 7 ++----- .../mini-cart-cart-button-block/edit.tsx | 7 ++----- .../mini-cart-checkout-button-block/block.tsx | 7 ++----- .../mini-cart-checkout-button-block/edit.tsx | 7 ++----- .../mini-cart-shopping-button-block/block.tsx | 7 ++----- .../mini-cart-shopping-button-block/edit.tsx | 7 ++----- .../mini-cart-contents/inner-blocks/utils.ts | 16 ++++++++++++++++ 7 files changed, 28 insertions(+), 30 deletions(-) create mode 100644 assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/utils.ts diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx index 4038780d0ee..d00afbfa8b4 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.tsx @@ -10,6 +10,7 @@ import { useColorProps } from '@woocommerce/base-hooks'; * Internal dependencies */ import { defaultCartButtonLabel } from './constants'; +import { getVariant } from '../utils'; type MiniCartCartButtonBlockProps = { cartButtonLabel: string; @@ -28,10 +29,6 @@ const Block = ( { return null; } - const variant = className.includes( 'is-style-fill' ) - ? 'contained' - : 'outlined'; - return ( diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/edit.tsx index 33cd4d64b56..e85e93a2bf3 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/edit.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/edit.tsx @@ -8,6 +8,7 @@ import EditableButton from '@woocommerce/editor-components/editable-button'; * Internal dependencies */ import { defaultCartButtonLabel } from './constants'; +import { getVariant } from '../utils'; export const Edit = ( { attributes, @@ -21,15 +22,11 @@ export const Edit = ( { const blockProps = useBlockProps(); const { cartButtonLabel } = attributes; - const variant = blockProps.className.includes( 'is-style-fill' ) - ? 'contained' - : 'outlined'; - return ( { diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx index 564ec15b7dc..251bbef6bc8 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.tsx @@ -10,6 +10,7 @@ import { useColorProps } from '@woocommerce/base-hooks'; * Internal dependencies */ import { defaultCheckoutButtonLabel } from './constants'; +import { getVariant } from '../utils'; type MiniCartCheckoutButtonBlockProps = { checkoutButtonLabel: string; @@ -28,10 +29,6 @@ const Block = ( { return null; } - const variant = className.includes( 'is-style-outline' ) - ? 'outlined' - : 'contained'; - return (