2019-12-03 13:57:56 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-12-10 15:41:57 +00:00
|
|
|
import { InnerBlocks } from '@wordpress/block-editor';
|
2019-12-12 19:46:56 +00:00
|
|
|
import { Disabled } from '@wordpress/components';
|
2019-12-03 13:57:56 +00:00
|
|
|
import { registerBlockType } from '@wordpress/blocks';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2019-12-10 15:41:57 +00:00
|
|
|
import Editor from './edit';
|
2019-12-03 13:57:56 +00:00
|
|
|
import { example } from './example';
|
2019-12-10 15:41:57 +00:00
|
|
|
import './style.scss';
|
2019-12-05 21:08:48 +00:00
|
|
|
|
2019-12-03 13:57:56 +00:00
|
|
|
/**
|
|
|
|
* Register and run the Cart block.
|
|
|
|
*/
|
|
|
|
registerBlockType( 'woocommerce/cart', {
|
|
|
|
title: __( 'Cart', 'woo-gutenberg-products-block' ),
|
|
|
|
icon: {
|
|
|
|
src: 'cart',
|
|
|
|
foreground: '#96588a',
|
|
|
|
},
|
|
|
|
category: 'woocommerce',
|
|
|
|
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
|
|
|
description: __( 'Shopping cart.', 'woo-gutenberg-products-block' ),
|
|
|
|
supports: {
|
|
|
|
align: [ 'wide', 'full' ],
|
|
|
|
html: false,
|
|
|
|
},
|
|
|
|
example,
|
|
|
|
attributes: {},
|
|
|
|
|
|
|
|
/**
|
2019-12-10 17:17:46 +00:00
|
|
|
* Renders the edit view for a block.
|
|
|
|
*
|
|
|
|
* @param {Object} props Props to pass to block.
|
2019-12-03 13:57:56 +00:00
|
|
|
*/
|
|
|
|
edit( props ) {
|
2019-12-12 19:46:56 +00:00
|
|
|
return (
|
|
|
|
<Disabled>
|
|
|
|
<Editor { ...props } />
|
|
|
|
</Disabled>
|
|
|
|
);
|
2019-12-03 13:57:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Block content is rendered in PHP, not via save function.
|
|
|
|
*/
|
|
|
|
save() {
|
2019-12-10 15:41:57 +00:00
|
|
|
return (
|
|
|
|
<div className="is-loading">
|
|
|
|
<InnerBlocks.Content />
|
|
|
|
</div>
|
|
|
|
);
|
2019-12-03 13:57:56 +00:00
|
|
|
},
|
|
|
|
} );
|