diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.json b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.json index ad20847e016..e60f5426239 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.json +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.json @@ -24,6 +24,17 @@ } } }, + "styles": [ + { + "name": "fill", + "label": "Fill" + }, + { + "name": "outline", + "label": "Outline", + "isDefault": true + } + ], "parent": [ "woocommerce/mini-cart-footer-block" ], "textdomain": "woo-gutenberg-products-block", "apiVersion": 2 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 56ed78ce4a7..0a2fd3e2fdc 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; @@ -37,7 +38,7 @@ const Block = ( { ) } style={ { ...colorProps.style } } href={ CART_URL } - variant="outlined" + variant={ getVariant( className, 'outlined' ) } > { cartButtonLabel || defaultCartButtonLabel } 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 271badd7df2..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, @@ -25,7 +26,7 @@ export const Edit = ( { { diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.json b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.json index e630a23bd23..e22ffa65f23 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.json +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.json @@ -24,7 +24,20 @@ } } }, - "parent": [ "woocommerce/mini-cart-footer-block" ], + "styles": [ + { + "name": "fill", + "label": "Fill", + "isDefault": true + }, + { + "name": "outline", + "label": "Outline" + } + ], + "parent": [ + "woocommerce/mini-cart-footer-block" + ], "textdomain": "woo-gutenberg-products-block", "apiVersion": 2 } 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 35e05a6284c..839a093adce 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; @@ -35,6 +36,7 @@ const Block = ( { colorProps.className, 'wc-block-mini-cart__footer-checkout' ) } + variant={ getVariant( className, 'contained' ) } style={ { ...colorProps.style } } href={ CHECKOUT_URL } > diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/edit.tsx index dff86ba1e4c..c6a6e96eba4 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/edit.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/edit.tsx @@ -3,11 +3,13 @@ */ import { useBlockProps } from '@wordpress/block-editor'; import EditableButton from '@woocommerce/editor-components/editable-button'; +import classNames from 'classnames'; /** * Internal dependencies */ import { defaultCheckoutButtonLabel } from './constants'; +import { getVariant } from '../utils'; export const Edit = ( { attributes, @@ -24,7 +26,11 @@ export const Edit = ( { return ( { diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.json b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.json index 4f3e75c6979..fe2938cbce9 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.json +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.json @@ -24,6 +24,17 @@ } } }, + "styles": [ + { + "name": "fill", + "label": "Fill", + "isDefault": true + }, + { + "name": "outline", + "label": "Outline" + } + ], "parent": [ "woocommerce/empty-mini-cart-contents-block" ], "textdomain": "woo-gutenberg-products-block", "apiVersion": 2 diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.tsx index cb3d88922f8..91806e64d85 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.tsx @@ -9,6 +9,7 @@ import classNames from 'classnames'; * Internal dependencies */ import { defaultStartShoppingButtonLabel } from './constants'; +import { getVariant } from '../utils'; type MiniCartShoppingButtonBlockProps = { className: string; @@ -30,6 +31,7 @@ const Block = ( { className, 'wc-block-mini-cart__shopping-button' ) } + variant={ getVariant( className, 'contained' ) } href={ SHOP_URL } > { startShoppingButtonLabel || defaultStartShoppingButtonLabel } diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx index d4bb89af179..f8af7f0d6fb 100644 --- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx @@ -8,6 +8,7 @@ import EditableButton from '@woocommerce/editor-components/editable-button'; * Internal dependencies */ import { defaultStartShoppingButtonLabel } from './constants'; +import { getVariant } from '../utils'; export const Edit = ( { attributes, @@ -33,6 +34,7 @@ export const Edit = ( { startShoppingButtonLabel: content, } ); } } + variant={ getVariant( blockProps.className, 'contained' ) } /> ); diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/utils.ts b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/utils.ts new file mode 100644 index 00000000000..12c49c23c61 --- /dev/null +++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/utils.ts @@ -0,0 +1,16 @@ +type Variant = 'text' | 'contained' | 'outlined'; + +export const getVariant = ( + className = '', + defaultVariant: Variant +): Variant => { + if ( className.includes( 'is-style-outline' ) ) { + return 'outlined'; + } + + if ( className.includes( 'is-style-fill' ) ) { + return 'contained'; + } + + return defaultVariant; +};