woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-best-sellers/index.tsx

59 lines
1.0 KiB
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { without } from 'lodash';
import { Icon, trendingUp } from '@wordpress/icons';
import { createBlock, registerBlockType } from '@wordpress/blocks';
/**
* Internal dependencies
*/
import metadata from './block.json';
import { Edit } from './edit';
import sharedAttributes, {
sharedAttributeBlockTypes,
} from '../../utils/shared-attributes';
registerBlockType( metadata, {
icon: {
src: (
<Icon
icon={ trendingUp }
className="wc-block-editor-components-block-icon"
/>
),
},
attributes: {
...sharedAttributes,
...metadata.attributes,
},
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: Edit,
save: () => {
return null;
},
} );