This repository was archived by the owner on Feb 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 10 files changed +69
-4
lines changed
assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks
mini-cart-cart-button-block
mini-cart-checkout-button-block
mini-cart-shopping-button-block Expand file tree Collapse file tree 10 files changed +69
-4
lines changed Original file line number Diff line number Diff line change 2424 }
2525 }
2626 },
27+ "styles" : [
28+ {
29+ "name" : " fill" ,
30+ "label" : " Fill"
31+ },
32+ {
33+ "name" : " outline" ,
34+ "label" : " Outline" ,
35+ "isDefault" : true
36+ }
37+ ],
2738 "parent" : [ " woocommerce/mini-cart-footer-block" ],
2839 "textdomain" : " woo-gutenberg-products-block" ,
2940 "apiVersion" : 2
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { useColorProps } from '@woocommerce/base-hooks';
1010 * Internal dependencies
1111 */
1212import { defaultCartButtonLabel } from './constants' ;
13+ import { getVariant } from '../utils' ;
1314
1415type MiniCartCartButtonBlockProps = {
1516 cartButtonLabel ?: string ;
@@ -37,7 +38,7 @@ const Block = ( {
3738 ) }
3839 style = { { ...colorProps . style } }
3940 href = { CART_URL }
40- variant = " outlined"
41+ variant = { getVariant ( className , ' outlined' ) }
4142 >
4243 { cartButtonLabel || defaultCartButtonLabel }
4344 </ Button >
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import EditableButton from '@woocommerce/editor-components/editable-button';
88 * Internal dependencies
99 */
1010import { defaultCartButtonLabel } from './constants' ;
11+ import { getVariant } from '../utils' ;
1112
1213export const Edit = ( {
1314 attributes,
@@ -25,7 +26,7 @@ export const Edit = ( {
2526 < EditableButton
2627 { ...blockProps }
2728 className = "wc-block-mini-cart__footer-cart"
28- variant = " outlined"
29+ variant = { getVariant ( blockProps . className , ' outlined' ) }
2930 value = { cartButtonLabel }
3031 placeholder = { defaultCartButtonLabel }
3132 onChange = { ( content ) => {
Original file line number Diff line number Diff line change 2424 }
2525 }
2626 },
27- "parent" : [ " woocommerce/mini-cart-footer-block" ],
27+ "styles" : [
28+ {
29+ "name" : " fill" ,
30+ "label" : " Fill" ,
31+ "isDefault" : true
32+ },
33+ {
34+ "name" : " outline" ,
35+ "label" : " Outline"
36+ }
37+ ],
38+ "parent" : [
39+ " woocommerce/mini-cart-footer-block"
40+ ],
2841 "textdomain" : " woo-gutenberg-products-block" ,
2942 "apiVersion" : 2
3043}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { useColorProps } from '@woocommerce/base-hooks';
1010 * Internal dependencies
1111 */
1212import { defaultCheckoutButtonLabel } from './constants' ;
13+ import { getVariant } from '../utils' ;
1314
1415type MiniCartCheckoutButtonBlockProps = {
1516 checkoutButtonLabel ?: string ;
@@ -35,6 +36,7 @@ const Block = ( {
3536 colorProps . className ,
3637 'wc-block-mini-cart__footer-checkout'
3738 ) }
39+ variant = { getVariant ( className , 'contained' ) }
3840 style = { { ...colorProps . style } }
3941 href = { CHECKOUT_URL }
4042 >
Original file line number Diff line number Diff line change 33 */
44import { useBlockProps } from '@wordpress/block-editor' ;
55import EditableButton from '@woocommerce/editor-components/editable-button' ;
6+ import classNames from 'classnames' ;
67
78/**
89 * Internal dependencies
910 */
1011import { defaultCheckoutButtonLabel } from './constants' ;
12+ import { getVariant } from '../utils' ;
1113
1214export const Edit = ( {
1315 attributes,
@@ -24,7 +26,11 @@ export const Edit = ( {
2426 return (
2527 < EditableButton
2628 { ...blockProps }
27- className = "wc-block-mini-cart__footer-checkout"
29+ className = { classNames (
30+ 'wc-block-mini-cart__footer-checkout' ,
31+ blockProps . className
32+ ) }
33+ variant = { getVariant ( blockProps . className , 'contained' ) }
2834 value = { checkoutButtonLabel }
2935 placeholder = { defaultCheckoutButtonLabel }
3036 onChange = { ( content ) => {
Original file line number Diff line number Diff line change 2424 }
2525 }
2626 },
27+ "styles" : [
28+ {
29+ "name" : " fill" ,
30+ "label" : " Fill" ,
31+ "isDefault" : true
32+ },
33+ {
34+ "name" : " outline" ,
35+ "label" : " Outline"
36+ }
37+ ],
2738 "parent" : [ " woocommerce/empty-mini-cart-contents-block" ],
2839 "textdomain" : " woo-gutenberg-products-block" ,
2940 "apiVersion" : 2
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import classNames from 'classnames';
99 * Internal dependencies
1010 */
1111import { defaultStartShoppingButtonLabel } from './constants' ;
12+ import { getVariant } from '../utils' ;
1213
1314type MiniCartShoppingButtonBlockProps = {
1415 className : string ;
@@ -30,6 +31,7 @@ const Block = ( {
3031 className ,
3132 'wc-block-mini-cart__shopping-button'
3233 ) }
34+ variant = { getVariant ( className , 'contained' ) }
3335 href = { SHOP_URL }
3436 >
3537 { startShoppingButtonLabel || defaultStartShoppingButtonLabel }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import EditableButton from '@woocommerce/editor-components/editable-button';
88 * Internal dependencies
99 */
1010import { defaultStartShoppingButtonLabel } from './constants' ;
11+ import { getVariant } from '../utils' ;
1112
1213export const Edit = ( {
1314 attributes,
@@ -33,6 +34,7 @@ export const Edit = ( {
3334 startShoppingButtonLabel : content ,
3435 } ) ;
3536 } }
37+ variant = { getVariant ( blockProps . className , 'contained' ) }
3638 />
3739 </ div >
3840 ) ;
Original file line number Diff line number Diff line change 1+ type Variant = 'text' | 'contained' | 'outlined' ;
2+
3+ export const getVariant = (
4+ className = '' ,
5+ defaultVariant : Variant
6+ ) : Variant => {
7+ if ( className . includes ( 'is-style-outline' ) ) {
8+ return 'outlined' ;
9+ }
10+
11+ if ( className . includes ( 'is-style-fill' ) ) {
12+ return 'contained' ;
13+ }
14+
15+ return defaultVariant ;
16+ } ;
You can’t perform that action at this time.
0 commit comments