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

Commit dca174b

Browse files
committed
Merge branch 'upkeep/9524' of github.com:Sidsector9/woocommerce-blocks into upkeep/9524
2 parents 4b48aca + 7da0883 commit dca174b

Some content is hidden

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

46 files changed

+608
-353
lines changed

.github/workflows/unit-tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,38 @@ jobs:
8080
##
8181
- name: Set up PHP
8282
uses: shivammathur/setup-php@v2
83+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
84+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
8385
with:
8486
php-version: '${{ matrix.php }}'
8587
ini-file: development
8688
coverage: none
8789

8890
# Ensure that Composer installs the correct versions of packages.
8991
- name: Override PHP version in composer.json
92+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
93+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
9094
run: |
9195
composer config platform.php ${{ matrix.php }}
9296
composer update
9397
9498
- name: Install npm dependencies
99+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
100+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
95101
run: |
96102
npm ci
97103
npm run build
98104
99105
- name: Docker debug information
106+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
107+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
100108
run: |
101109
docker -v
102110
docker-compose -v
103111
104112
- name: General debug information
113+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
114+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
105115
run: |
106116
npm --version
107117
node --version
@@ -111,12 +121,18 @@ jobs:
111121
locale -a
112122
113123
- name: Start Docker environment
124+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
125+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
114126
run: npm run wp-env start --update
115127

116128
- name: Log running Docker containers
129+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
130+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
117131
run: docker ps -a
118132

119133
- name: Docker container debug information
134+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
135+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
120136
run: |
121137
npm run wp-env run tests-mysql mysql -- --version
122138
npm run wp-env run tests-wordpress "php --version"
@@ -125,4 +141,6 @@ jobs:
125141
npm run wp-env run tests-wordpress "locale -a"
126142
127143
- name: Run PHPUnit tests
144+
# 8.1 and 8.2 are temporarily disabled as docker-images for those cause the errors when pipeline is running
145+
if: ${{ matrix.php == '7.4' || matrix.php == '8.0' }}
128146
run: npm run test:php

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[![View](https://img.shields.io/badge/Project%20Components-brightgreen.svg?style=flat)](https://woocommerce.github.io/woocommerce-blocks/)
55
![JavaScript and CSS Linting](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/JavaScript%20and%20CSS%20Linting/badge.svg?branch=trunk)
66
![PHP Coding Standards](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/PHP%20Coding%20Standards/badge.svg?branch=trunk)
7-
![Automated tests](https://github.com/woocommerce/woocommerce-gutenberg-products-block/workflows/Automated%20tests/badge.svg?branch=trunk)
7+
![Unit Tests](https://github.com/woocommerce/woocommerce-blocks/workflows/E2E%20tests/badge.svg?branch=trunk)
8+
![E2E Tests](https://github.com/woocommerce/woocommerce-blocks/workflows/Unit%20Tests/badge.svg?branch=trunk)
89

910
This is the feature plugin for WooCommerce + Gutenberg. This plugin serves as a space to iterate and explore new Blocks and updates to existing blocks for WooCommerce, and how WooCommerce might work with the block editor.
1011

assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const ShippingAddress = ( {
4848
) : (
4949
<ShippingLocation formattedLocation={ formattedLocation } />
5050
) }
51-
{ showCalculator && ! prefersCollection ? (
51+
{ showCalculator && (
5252
<CalculatorButton
5353
label={ __(
5454
'Change address',
@@ -57,7 +57,7 @@ export const ShippingAddress = ( {
5757
isShippingCalculatorOpen={ isShippingCalculatorOpen }
5858
setIsShippingCalculatorOpen={ setIsShippingCalculatorOpen }
5959
/>
60-
) : null }
60+
) }
6161
</>
6262
);
6363
};

assets/js/blocks/active-filters/block.tsx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useQueryStateByKey } from '@woocommerce/base-context/hooks';
66
import { getSetting, getSettingWithCoercion } from '@woocommerce/settings';
77
import { useMemo, useEffect, useState } from '@wordpress/element';
88
import classnames from 'classnames';
9-
import PropTypes from 'prop-types';
109
import Label from '@woocommerce/base-components/label';
1110
import {
1211
isAttributeQueryCollection,
@@ -18,6 +17,7 @@ import {
1817
import { getUrlParameter } from '@woocommerce/utils';
1918
import FilterTitlePlaceholder from '@woocommerce/base-components/filter-placeholder';
2019
import { useIsMounted } from '@woocommerce/base-hooks';
20+
import type { BlockAttributes } from '@wordpress/blocks';
2121

2222
/**
2323
* Internal dependencies
@@ -34,23 +34,26 @@ import {
3434
} from './utils';
3535
import ActiveAttributeFilters from './active-attribute-filters';
3636
import FilterPlaceholders from './filter-placeholders';
37-
import { Attributes } from './types';
3837
import { useSetWraperVisibility } from '../filter-wrapper/context';
3938

39+
interface ActiveFiltersBlockProps {
40+
/**
41+
* The attributes for this block.
42+
*/
43+
attributes: BlockAttributes;
44+
/**
45+
* Whether it's in the editor or frontend display.
46+
*/
47+
isEditor: boolean;
48+
}
49+
4050
/**
4151
* Component displaying active filters.
42-
*
43-
* @param {Object} props Incoming props for the component.
44-
* @param {Object} props.attributes Incoming attributes for the block.
45-
* @param {boolean} props.isEditor Whether or not in the editor context.
4652
*/
4753
const ActiveFiltersBlock = ( {
4854
attributes: blockAttributes,
4955
isEditor = false,
50-
}: {
51-
attributes: Attributes;
52-
isEditor?: boolean;
53-
} ) => {
56+
}: ActiveFiltersBlockProps ) => {
5457
const setWrapperVisibility = useSetWraperVisibility();
5558
const isMounted = useIsMounted();
5659
const componentHasMounted = isMounted();
@@ -413,15 +416,4 @@ const ActiveFiltersBlock = ( {
413416
);
414417
};
415418

416-
ActiveFiltersBlock.propTypes = {
417-
/**
418-
* The attributes for this block.
419-
*/
420-
attributes: PropTypes.object.isRequired,
421-
/**
422-
* Whether it's in the editor or frontend display.
423-
*/
424-
isEditor: PropTypes.bool,
425-
};
426-
427419
export default ActiveFiltersBlock;

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import classnames from 'classnames';
3434
/**
3535
* Internal dependencies
3636
*/
37+
import type { BlockAttributes } from './types';
3738
import QuantityBadge from './quantity-badge';
3839
import { MiniCartContentsBlock } from './mini-cart-contents/block';
3940
import './style.scss';
@@ -42,14 +43,7 @@ import {
4243
attributes as miniCartContentsAttributes,
4344
} from './mini-cart-contents/attributes';
4445

45-
interface Props {
46-
isInitiallyOpen?: boolean;
47-
colorClassNames?: string;
48-
style?: Record< string, Record< string, string > >;
49-
contents: string;
50-
addToCartBehaviour: string;
51-
hasHiddenPrice: boolean;
52-
}
46+
type Props = BlockAttributes;
5347

5448
function getScrollbarWidth() {
5549
return window.innerWidth - document.documentElement.clientWidth;
@@ -61,6 +55,7 @@ const MiniCartBlock = ( attributes: Props ): JSX.Element => {
6155
colorClassNames,
6256
style,
6357
contents = '',
58+
miniCartIcon,
6459
addToCartBehaviour = 'none',
6560
hasHiddenPrice = false,
6661
} = attributes;
@@ -269,7 +264,7 @@ const MiniCartBlock = ( attributes: Props ): JSX.Element => {
269264
{ taxLabel }
270265
</small>
271266
) }
272-
<QuantityBadge count={ cartItemsCount } />
267+
<QuantityBadge count={ cartItemsCount } icon={ miniCartIcon } />
273268
</button>
274269
<Drawer
275270
className={ classnames(

assets/js/blocks/mini-cart/component-frontend.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const renderMiniCartFrontend = () => {
4141
isInitiallyOpen: el.dataset.isInitiallyOpen === 'true',
4242
colorClassNames,
4343
style: el.dataset.style ? JSON.parse( el.dataset.style ) : {},
44+
miniCartIcon: el.dataset.miniCartIcon,
4445
addToCartBehaviour: el.dataset.addToCartBehaviour || 'none',
4546
hasHiddenPrice: el.dataset.hasHiddenPrice,
4647
contents:

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

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import Noninteractive from '@woocommerce/base-components/noninteractive';
1717
import { isSiteEditorPage } from '@woocommerce/utils';
1818
import type { ReactElement } from 'react';
1919
import { select } from '@wordpress/data';
20+
import { cartOutline, bag, bagAlt } from '@woocommerce/icons';
21+
import { Icon } from '@wordpress/icons';
2022

2123
/**
2224
* Internal dependencies
@@ -25,6 +27,7 @@ import QuantityBadge from './quantity-badge';
2527
import './editor.scss';
2628

2729
interface Attributes {
30+
miniCartIcon: 'cart' | 'bag' | 'bag-alt';
2831
addToCartBehaviour: string;
2932
hasHiddenPrice: boolean;
3033
cartAndCheckoutRenderStyle: boolean;
@@ -36,8 +39,12 @@ interface Props {
3639
}
3740

3841
const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
39-
const { addToCartBehaviour, hasHiddenPrice, cartAndCheckoutRenderStyle } =
40-
attributes;
42+
const {
43+
miniCartIcon,
44+
addToCartBehaviour,
45+
hasHiddenPrice,
46+
cartAndCheckoutRenderStyle,
47+
} = attributes;
4148
const blockProps = useBlockProps( {
4249
className: `wc-block-mini-cart`,
4350
} );
@@ -58,22 +65,57 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
5865
<PanelBody
5966
title={ __( 'Settings', 'woo-gutenberg-products-block' ) }
6067
>
61-
<ToggleControl
68+
<ToggleGroupControl
69+
className="wc-block-editor-mini-cart__cart-icon-toggle"
70+
isBlock={ true }
6271
label={ __(
63-
'Display total price',
72+
'Cart Icon',
6473
'woo-gutenberg-products-block'
6574
) }
66-
help={ __(
67-
'Toggle to display the total price of products in the shopping cart. If no products have been added, the price will not display.',
75+
value={ miniCartIcon }
76+
onChange={ ( value ) => {
77+
setAttributes( {
78+
miniCartIcon: value,
79+
} );
80+
} }
81+
>
82+
<ToggleGroupControlOption
83+
value={ 'cart' }
84+
label={ <Icon size={ 32 } icon={ cartOutline } /> }
85+
/>
86+
<ToggleGroupControlOption
87+
value={ 'bag' }
88+
label={ <Icon size={ 32 } icon={ bag } /> }
89+
/>
90+
<ToggleGroupControlOption
91+
value={ 'bag-alt' }
92+
label={ <Icon size={ 32 } icon={ bagAlt } /> }
93+
/>
94+
</ToggleGroupControl>
95+
<BaseControl
96+
id="wc-block-mini-cart__display-toggle"
97+
label={ __(
98+
'Display',
6899
'woo-gutenberg-products-block'
69100
) }
70-
checked={ ! hasHiddenPrice }
71-
onChange={ () =>
72-
setAttributes( {
73-
hasHiddenPrice: ! hasHiddenPrice,
74-
} )
75-
}
76-
/>
101+
>
102+
<ToggleControl
103+
label={ __(
104+
'Display total price',
105+
'woo-gutenberg-products-block'
106+
) }
107+
help={ __(
108+
'Toggle to display the total price of products in the shopping cart. If no products have been added, the price will not display.',
109+
'woo-gutenberg-products-block'
110+
) }
111+
checked={ ! hasHiddenPrice }
112+
onChange={ () =>
113+
setAttributes( {
114+
hasHiddenPrice: ! hasHiddenPrice,
115+
} )
116+
}
117+
/>
118+
</BaseControl>
77119
{ isSiteEditor && (
78120
<ToggleGroupControl
79121
className="wc-block-editor-mini-cart__render-in-cart-and-checkout-toggle"
@@ -177,7 +219,10 @@ const Edit = ( { attributes, setAttributes }: Props ): ReactElement => {
177219
{ formatPrice( productTotal ) }
178220
</span>
179221
) }
180-
<QuantityBadge count={ productCount } />
222+
<QuantityBadge
223+
count={ productCount }
224+
icon={ miniCartIcon }
225+
/>
181226
</button>
182227
</Noninteractive>
183228
</div>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const settings: BlockConfiguration = {
5353
type: 'boolean',
5454
default: false,
5555
},
56+
miniCartIcon: {
57+
type: 'string',
58+
default: 'cart',
59+
},
5660
addToCartBehaviour: {
5761
type: 'string',
5862
default: 'none',

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
/**
22
* External dependencies
33
*/
4-
import { miniCart } from '@woocommerce/icons';
4+
import { cartOutline, bag, bagAlt } from '@woocommerce/icons';
55
import { Icon } from '@wordpress/icons';
66

77
/**
88
* Internal dependencies
99
*/
1010
import './style.scss';
11+
import { IconType } from '.././types';
1112

1213
interface Props {
1314
count: number;
1415
colorClassNames?: string;
16+
icon?: IconType;
1517
}
1618

17-
const QuantityBadge = ( { count }: Props ): JSX.Element => {
19+
const QuantityBadge = ( { count, icon }: Props ): JSX.Element => {
20+
function getIcon( iconName?: 'cart' | 'bag' | 'bag-alt' ) {
21+
switch ( iconName ) {
22+
case 'cart':
23+
return cartOutline;
24+
case 'bag':
25+
return bag;
26+
case 'bag-alt':
27+
return bagAlt;
28+
default:
29+
return cartOutline;
30+
}
31+
}
32+
1833
return (
1934
<span className="wc-block-mini-cart__quantity-badge">
2035
<Icon
2136
className="wc-block-mini-cart__icon"
22-
size={ 20 }
23-
icon={ miniCart }
37+
size={ 32 }
38+
icon={ getIcon( icon ) }
2439
/>
2540
<span className="wc-block-mini-cart__badge">
2641
{ count > 0 ? count : '' }

assets/js/blocks/mini-cart/quantity-badge/style.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535

3636
.wc-block-mini-cart__icon {
3737
display: block;
38-
height: em(24px);
39-
width: em(24px);
38+
height: em(32px);
39+
width: em(32px);
40+
margin: -0.25em;
4041

4142
html[dir="rtl"] & {
4243
transform: scaleX(-1);

0 commit comments

Comments
 (0)