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

Commit c7c1e4b

Browse files
authored
Update Mini-Cart block editor sidebar (#9420)
* Update Mini-Cart block editor sidebar * Rename Mini Cart block to Mini-Cart * Update Mini-Cart block editor sidebar (II) * Update two instances of mini-cart to uppercase
1 parent 8ee64d5 commit c7c1e4b

41 files changed

Lines changed: 198 additions & 152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/js/blocks/mini-cart/edit.tsx

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useSelect } from '@wordpress/data';
2121
* Internal dependencies
2222
*/
2323
import QuantityBadge from './quantity-badge';
24+
import './editor.scss';
2425

2526
interface Attributes {
2627
addToCartBehaviour: string;
@@ -54,47 +55,18 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
5455
<div { ...blockProps }>
5556
<InspectorControls>
5657
<PanelBody
57-
title={ __(
58-
'Mini Cart Settings',
59-
'woo-gutenberg-products-block'
60-
) }
58+
title={ __( 'Settings', 'woo-gutenberg-products-block' ) }
6159
>
62-
<BaseControl
63-
id="wc-block-mini-cart__add-to-cart-behaviour-toggle"
64-
label={ __(
65-
'Add-to-Cart behaviour',
66-
'woo-gutenberg-products-block'
67-
) }
68-
>
69-
<ToggleControl
70-
label={ __(
71-
'Open cart in a drawer',
72-
'woo-gutenberg-products-block'
73-
) }
74-
onChange={ ( value ) => {
75-
setAttributes( {
76-
addToCartBehaviour: value
77-
? 'open_drawer'
78-
: 'none',
79-
} );
80-
} }
81-
help={ __(
82-
'Select what happens when a customer adds a product to the cart.',
83-
'woo-gutenberg-products-block'
84-
) }
85-
checked={ addToCartBehaviour === 'open_drawer' }
86-
/>
87-
</BaseControl>
8860
<ToggleControl
8961
label={ __(
90-
'Hide Cart Price',
62+
'Display total price',
9163
'woo-gutenberg-products-block'
9264
) }
9365
help={ __(
94-
'Toggles the visibility of the Mini Cart price.',
66+
'Toggle to display the total price of products in the shopping cart. If no products have been added, the price will not display.',
9567
'woo-gutenberg-products-block'
9668
) }
97-
checked={ hasHiddenPrice }
69+
checked={ ! hasHiddenPrice }
9870
onChange={ () =>
9971
setAttributes( {
10072
hasHiddenPrice: ! hasHiddenPrice,
@@ -103,9 +75,9 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
10375
/>
10476
{ isSiteEditor && (
10577
<ToggleGroupControl
106-
className="wc-block-mini-cart__render-in-cart-and-checkout-toggle"
78+
className="wc-block-editor-mini-cart__render-in-cart-and-checkout-toggle"
10779
label={ __(
108-
'Mini Cart in cart and checkout pages',
80+
'Mini-Cart in cart and checkout pages',
10981
'woo-gutenberg-products-block'
11082
) }
11183
value={ cartAndCheckoutRenderStyle }
@@ -115,7 +87,7 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
11587
} );
11688
} }
11789
help={ __(
118-
'Select how the Mini Cart behaves in the Cart and Checkout pages. This might affect the header layout.',
90+
'Select how the Mini-Cart behaves in the Cart and Checkout pages. This might affect the header layout.',
11991
'woo-gutenberg-products-block'
12092
) }
12193
>
@@ -136,27 +108,62 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
136108
</ToggleGroupControl>
137109
) }
138110
</PanelBody>
139-
{ templatePartEditUri && (
140-
<PanelBody
141-
title={ __(
142-
'Template settings',
111+
<PanelBody
112+
title={ __(
113+
'Cart Drawer',
114+
'woo-gutenberg-products-block'
115+
) }
116+
>
117+
{ templatePartEditUri && (
118+
<>
119+
<img
120+
className="wc-block-editor-mini-cart__drawer-image"
121+
src="/wp-content/plugins/woocommerce-blocks/images/blocks/mini-cart/cart-drawer.svg"
122+
alt=""
123+
/>
124+
<p>
125+
{ __(
126+
'When opened, the Mini-Cart drawer gives shoppers quick access to view their selected products and checkout.',
127+
'woo-gutenberg-products-block'
128+
) }
129+
</p>
130+
<p className="wc-block-editor-mini-cart__drawer-link">
131+
<ExternalLink href={ templatePartEditUri }>
132+
{ __(
133+
'Edit Mini-Cart Drawer template',
134+
'woo-gutenberg-products-block'
135+
) }
136+
</ExternalLink>
137+
</p>
138+
</>
139+
) }
140+
<BaseControl
141+
id="wc-block-mini-cart__add-to-cart-behaviour-toggle"
142+
label={ __(
143+
'Behavior',
143144
'woo-gutenberg-products-block'
144145
) }
145146
>
146-
<p>
147-
{ __(
148-
'Edit the appearance of the Mini Cart.',
147+
<ToggleControl
148+
label={ __(
149+
'Open drawer when adding',
149150
'woo-gutenberg-products-block'
150151
) }
151-
</p>
152-
<ExternalLink href={ templatePartEditUri }>
153-
{ __(
154-
'Edit Mini Cart template part',
152+
onChange={ ( value ) => {
153+
setAttributes( {
154+
addToCartBehaviour: value
155+
? 'open_drawer'
156+
: 'none',
157+
} );
158+
} }
159+
help={ __(
160+
'Toggle to open the Mini-Cart drawer when a shopper adds a product to their cart.',
155161
'woo-gutenberg-products-block'
156162
) }
157-
</ExternalLink>
158-
</PanelBody>
159-
) }
163+
checked={ addToCartBehaviour === 'open_drawer' }
164+
/>
165+
</BaseControl>
166+
</PanelBody>
160167
</InspectorControls>
161168
<Noninteractive>
162169
<button className="wc-block-mini-cart__button">
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.wc-block-editor-mini-cart__render-in-cart-and-checkout-toggle {
2+
width: 100%;
3+
}
4+
5+
.wc-block-editor-mini-cart__drawer-image {
6+
margin-bottom: 6px;
7+
}
8+
9+
.wc-block-editor-mini-cart__drawer-link {
10+
margin-bottom: 24px;
11+
}

assets/js/blocks/mini-cart/frontend.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ window.addEventListener( 'load', () => {
155155
? openDrawerWithRefresh
156156
: loadContentsWithRefresh;
157157

158-
// There might be more than one Mini Cart block in the page. Make sure
158+
// There might be more than one Mini-Cart block in the page. Make sure
159159
// only one opens when adding a product to the cart.
160160
if ( i === 0 ) {
161161
document.body.addEventListener(
@@ -171,7 +171,7 @@ window.addEventListener( 'load', () => {
171171

172172
/**
173173
* Get the background color of the body then set it as the background color
174-
* of the Mini Cart Contents block. We use :where here to make customized
174+
* of the Mini-Cart Contents block. We use :where here to make customized
175175
* background color alway have higher priority.
176176
*
177177
* We only set the background color, instead of the whole background. As

assets/js/blocks/mini-cart/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import edit from './edit';
1515

1616
const settings: BlockConfiguration = {
1717
apiVersion: 2,
18-
title: __( 'Mini Cart', 'woo-gutenberg-products-block' ),
18+
title: __( 'Mini-Cart', 'woo-gutenberg-products-block' ),
1919
icon: {
2020
src: (
2121
<Icon
@@ -27,7 +27,7 @@ const settings: BlockConfiguration = {
2727
category: 'woocommerce',
2828
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
2929
description: __(
30-
'Display a mini cart widget.',
30+
'Display a button for shoppers to quickly view their cart.',
3131
'woo-gutenberg-products-block'
3232
),
3333
supports: {

assets/js/blocks/mini-cart/mini-cart-contents/attributes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export const attributes = {
2929
default: [
3030
{
3131
view: 'woocommerce/filled-mini-cart-contents-block',
32-
label: __( 'Filled Mini Cart', 'woo-gutenberg-products-block' ),
32+
label: __( 'Filled Mini-Cart', 'woo-gutenberg-products-block' ),
3333
icon: <Icon icon={ filledCart } />,
3434
},
3535
{
3636
view: 'woocommerce/empty-mini-cart-contents-block',
37-
label: __( 'Empty Mini Cart', 'woo-gutenberg-products-block' ),
37+
label: __( 'Empty Mini-Cart', 'woo-gutenberg-products-block' ),
3838
icon: <Icon icon={ removeCart } />,
3939
},
4040
],

assets/js/blocks/mini-cart/mini-cart-contents/edit.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const Edit = ( {
5050
const blockProps = useBlockProps( {
5151
/**
5252
* This is a workaround for the Site Editor to calculate the
53-
* correct height of the Mini Cart template part on the first load.
53+
* correct height of the Mini-Cart template part on the first load.
5454
*
5555
* @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/5825
5656
*/
@@ -73,7 +73,7 @@ const Edit = ( {
7373

7474
/**
7575
* This is a workaround for the Site Editor to set the correct
76-
* background color of the Mini Cart Contents block base on
76+
* background color of the Mini-Cart Contents block base on
7777
* the main background color set by the theme.
7878
*/
7979
useEffect( () => {

assets/js/blocks/mini-cart/mini-cart-contents/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import './inner-blocks';
1717

1818
const settings: BlockConfiguration = {
1919
apiVersion: 2,
20-
title: __( 'Mini Cart Contents', 'woo-gutenberg-products-block' ),
20+
title: __( 'Mini-Cart Contents', 'woo-gutenberg-products-block' ),
2121
icon: {
2222
src: (
2323
<Icon
@@ -29,7 +29,7 @@ const settings: BlockConfiguration = {
2929
category: 'woocommerce',
3030
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
3131
description: __(
32-
'Display a mini cart widget.',
32+
'Display a Mini-Cart widget.',
3333
'woo-gutenberg-products-block'
3434
),
3535
supports: {

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks-style.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/**
22
* This is a workaround to style inner blocks using the color
3-
* settings of the Mini Cart Contents block. It's possible to get
4-
* the Mini Cart Contents block's attributes inside the inner blocks
3+
* settings of the Mini-Cart Contents block. It's possible to get
4+
* the Mini-Cart Contents block's attributes inside the inner blocks
55
* components, but we have 4 out of 7 inner blocks that inherit
6-
* style from the Mini Cart Contents block, so we need to apply the
6+
* style from the Mini-Cart Contents block, so we need to apply the
77
* styles here to avoid duplication.
88
*
99
* We only use this hack for the Site Editor. On the frontend, we

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/block.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "woocommerce/empty-mini-cart-contents-block",
33
"version": "1.0.0",
4-
"title": "Empty Mini Cart view",
5-
"description": "Blocks that are displayed when the Mini Cart is empty.",
4+
"title": "Empty Mini-Cart view",
5+
"description": "Blocks that are displayed when the Mini-Cart is empty.",
66
"category": "woocommerce",
77
"supports": {
88
"align": false,

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/block.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "woocommerce/filled-mini-cart-contents-block",
33
"version": "1.0.0",
4-
"title": "Filled Mini Cart view",
5-
"description": "Contains blocks that display the content of the Mini Cart.",
4+
"title": "Filled Mini-Cart view",
5+
"description": "Contains blocks that display the content of the Mini-Cart.",
66
"category": "woocommerce",
77
"supports": {
88
"align": false,

0 commit comments

Comments
 (0)