76 lines
1.4 KiB
JavaScript
76 lines
1.4 KiB
JavaScript
/**
|
|
* External dependencies
|
|
*/
|
|
import { __ } from '@wordpress/i18n';
|
|
import { without } from 'lodash';
|
|
import { Icon, trendingUp } from '@wordpress/icons';
|
|
import { createBlock, registerBlockType } from '@wordpress/blocks';
|
|
|
|
/**
|
|
* Internal dependencies
|
|
*/
|
|
import Block from './block';
|
|
import sharedAttributes, {
|
|
sharedAttributeBlockTypes,
|
|
} from '../../utils/shared-attributes';
|
|
|
|
registerBlockType( 'woocommerce/product-best-sellers', {
|
|
title: __( 'Best Selling Products', 'woo-gutenberg-products-block' ),
|
|
icon: {
|
|
src: (
|
|
<Icon
|
|
icon={ trendingUp }
|
|
className="wc-block-editor-components-block-icon"
|
|
/>
|
|
),
|
|
},
|
|
category: 'woocommerce',
|
|
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
|
description: __(
|
|
'Display a grid of your all-time best selling products.',
|
|
'woo-gutenberg-products-block'
|
|
),
|
|
supports: {
|
|
align: [ 'wide', 'full' ],
|
|
html: false,
|
|
},
|
|
example: {
|
|
attributes: {
|
|
isPreview: true,
|
|
},
|
|
},
|
|
attributes: {
|
|
...sharedAttributes,
|
|
},
|
|
|
|
transforms: {
|
|
from: [
|
|
{
|
|
type: 'block',
|
|
blocks: without(
|
|
sharedAttributeBlockTypes,
|
|
'woocommerce/product-best-sellers'
|
|
),
|
|
transform: ( attributes ) =>
|
|
createBlock(
|
|
'woocommerce/product-best-sellers',
|
|
attributes
|
|
),
|
|
},
|
|
],
|
|
},
|
|
|
|
/**
|
|
* Renders and manages the block.
|
|
*
|
|
* @param {Object} props Props to pass to block.
|
|
*/
|
|
edit( props ) {
|
|
return <Block { ...props } />;
|
|
},
|
|
|
|
save() {
|
|
return null;
|
|
},
|
|
} );
|