2019-12-10 15:41:57 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
|
|
|
import { InnerBlocks } from '@wordpress/block-editor';
|
|
|
|
import { SHOP_URL } from '@woocommerce/block-settings';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import iconDataUri from './icon-data-uri.js';
|
|
|
|
import './style.scss';
|
|
|
|
|
2021-02-17 15:17:54 +00:00
|
|
|
const templateItemBrowseStore = SHOP_URL
|
|
|
|
? [
|
|
|
|
'core/paragraph',
|
|
|
|
{
|
|
|
|
align: 'center',
|
|
|
|
content: sprintf(
|
2021-02-19 11:58:44 +00:00
|
|
|
/* translators: %s is the link to the store product directory. */
|
2021-02-17 15:17:54 +00:00
|
|
|
__(
|
|
|
|
'<a href="%s">Browse store</a>.',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
),
|
|
|
|
SHOP_URL
|
|
|
|
),
|
|
|
|
dropCap: false,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: null;
|
|
|
|
|
|
|
|
const templateItems = [
|
|
|
|
[
|
|
|
|
'core/image',
|
|
|
|
{
|
|
|
|
align: 'center',
|
|
|
|
url: iconDataUri,
|
|
|
|
sizeSlug: 'small',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'core/heading',
|
|
|
|
{
|
2021-04-08 06:48:59 +00:00
|
|
|
textAlign: 'center',
|
2021-02-17 15:17:54 +00:00
|
|
|
content: __(
|
|
|
|
'Your cart is currently empty!',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
),
|
|
|
|
level: 2,
|
|
|
|
className: 'wc-block-cart__empty-cart__title',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
templateItemBrowseStore,
|
|
|
|
[
|
|
|
|
'core/separator',
|
|
|
|
{
|
|
|
|
className: 'is-style-dots',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'core/heading',
|
|
|
|
{
|
2021-04-08 06:48:59 +00:00
|
|
|
textAlign: 'center',
|
2021-02-17 15:17:54 +00:00
|
|
|
content: __( 'New in store', 'woo-gutenberg-products-block' ),
|
|
|
|
level: 2,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'woocommerce/product-new',
|
|
|
|
{
|
|
|
|
columns: 3,
|
|
|
|
rows: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
].filter( Boolean );
|
|
|
|
|
2019-12-10 15:41:57 +00:00
|
|
|
/**
|
|
|
|
* Component to handle edit mode for the Cart block when cart is empty.
|
2020-09-20 23:54:08 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props Incoming props for the component.
|
|
|
|
* @param {boolean} props.hidden Whether this component is hidden or not.
|
2019-12-10 15:41:57 +00:00
|
|
|
*/
|
2020-05-01 09:33:55 +00:00
|
|
|
const EmptyCartEdit = ( { hidden = false } ) => {
|
2019-12-10 15:41:57 +00:00
|
|
|
return (
|
|
|
|
<div hidden={ hidden }>
|
|
|
|
<InnerBlocks
|
2020-01-17 12:23:33 +00:00
|
|
|
templateInsertUpdatesSelection={ false }
|
2021-02-17 15:17:54 +00:00
|
|
|
template={ templateItems }
|
2019-12-10 15:41:57 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-04-08 15:03:39 +00:00
|
|
|
EmptyCartEdit.propTypes = {
|
2019-12-10 15:41:57 +00:00
|
|
|
hidden: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
2020-04-08 15:03:39 +00:00
|
|
|
export default EmptyCartEdit;
|