woocommerce/packages/woocommerce-blocks/assets/js/blocks/product-top-rated/index.js
2021-12-10 12:03:04 +00:00

68 lines
1.3 KiB
JavaScript

/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createBlock, registerBlockType } from '@wordpress/blocks';
import { Icon, thumbUp } from '@woocommerce/icons';
import { without } from 'lodash';
/**
* Internal dependencies
*/
import Block from './block';
import sharedAttributes, {
sharedAttributeBlockTypes,
} from '../../utils/shared-attributes';
const blockTypeName = 'woocommerce/product-top-rated';
registerBlockType( blockTypeName, {
title: __( 'Top Rated Products', 'woocommerce' ),
icon: {
src: <Icon srcElement={ thumbUp } />,
foreground: '#96588a',
},
category: 'woocommerce',
keywords: [ __( 'WooCommerce', 'woocommerce' ) ],
description: __(
'Display a grid of your top rated products.',
'woocommerce'
),
supports: {
align: [ 'wide', 'full' ],
html: false,
},
example: {
attributes: {
isPreview: true,
},
},
attributes: {
...sharedAttributes,
},
transforms: {
from: [
{
type: 'block',
blocks: without( sharedAttributeBlockTypes, blockTypeName ),
transform: ( attributes ) =>
createBlock( 'woocommerce/product-top-rated', attributes ),
},
],
},
/**
* Renders and manages the block.
*
* @param {Object} props Props to pass to block.
*/
edit( props ) {
return <Block { ...props } />;
},
save() {
return null;
},
} );