2019-01-10 18:16:37 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2019-02-26 05:31:25 +00:00
|
|
|
import { createBlock, registerBlockType } from '@wordpress/blocks';
|
2022-02-01 16:54:38 +00:00
|
|
|
import { thumbUp } from '@woocommerce/icons';
|
|
|
|
import { Icon } from '@wordpress/icons';
|
2019-01-10 18:16:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-05-26 06:46:13 +00:00
|
|
|
import metadata from './block.json';
|
2019-09-05 15:09:31 +00:00
|
|
|
import sharedAttributes, {
|
|
|
|
sharedAttributeBlockTypes,
|
|
|
|
} from '../../utils/shared-attributes';
|
2023-05-26 06:46:13 +00:00
|
|
|
import { Edit } from './edit';
|
2019-01-10 18:16:37 +00:00
|
|
|
|
2023-05-26 06:46:13 +00:00
|
|
|
registerBlockType( metadata, {
|
2019-05-28 10:18:07 +00:00
|
|
|
icon: {
|
2021-12-10 14:32:44 +00:00
|
|
|
src: (
|
|
|
|
<Icon
|
2022-02-01 16:54:38 +00:00
|
|
|
icon={ thumbUp }
|
2021-12-10 14:32:44 +00:00
|
|
|
className="wc-block-editor-components-block-icon"
|
|
|
|
/>
|
|
|
|
),
|
2019-05-28 10:18:07 +00:00
|
|
|
},
|
2019-01-10 18:16:37 +00:00
|
|
|
category: 'woocommerce',
|
|
|
|
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
|
|
|
|
description: __(
|
|
|
|
'Display a grid of your top rated products.',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
),
|
|
|
|
attributes: {
|
|
|
|
...sharedAttributes,
|
2023-05-26 06:46:13 +00:00
|
|
|
...metadata.attributes,
|
2019-01-10 18:16:37 +00:00
|
|
|
},
|
2019-02-26 05:31:25 +00:00
|
|
|
transforms: {
|
|
|
|
from: [
|
|
|
|
{
|
|
|
|
type: 'block',
|
2023-04-28 10:29:45 +00:00
|
|
|
blocks: sharedAttributeBlockTypes.filter(
|
2023-05-26 06:46:13 +00:00
|
|
|
( value ) => value !== 'woocommerce/product-top-rated'
|
2023-04-28 10:29:45 +00:00
|
|
|
),
|
2019-09-05 15:09:31 +00:00
|
|
|
transform: ( attributes ) =>
|
|
|
|
createBlock( 'woocommerce/product-top-rated', attributes ),
|
2019-02-26 05:31:25 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2019-01-10 18:16:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders and manages the block.
|
2019-12-10 17:17:46 +00:00
|
|
|
*
|
|
|
|
* @param {Object} props Props to pass to block.
|
2019-01-10 18:16:37 +00:00
|
|
|
*/
|
2023-05-26 06:46:13 +00:00
|
|
|
edit: Edit,
|
2019-01-10 18:16:37 +00:00
|
|
|
|
2019-05-28 12:06:12 +00:00
|
|
|
save() {
|
|
|
|
return null;
|
2019-01-10 18:16:37 +00:00
|
|
|
},
|
|
|
|
} );
|