woocommerce/plugins/woocommerce-blocks/assets/js/blocks/product-on-sale/index.js

73 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createBlock, registerBlockType } from '@wordpress/blocks';
import { Icon, percent } from '@wordpress/icons';
/**
* Internal dependencies
*/
import Block from './block';
import './editor.scss';
import sharedAttributes, {
sharedAttributeBlockTypes,
} from '../../utils/shared-attributes';
registerBlockType( 'woocommerce/product-on-sale', {
title: __( 'On Sale Products', 'woo-gutenberg-products-block' ),
icon: {
src: (
<Icon
icon={ percent }
className="wc-block-editor-components-block-icon"
/>
),
},
category: 'woocommerce',
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
description: __(
'Display a grid of products currently on sale.',
'woo-gutenberg-products-block'
),
supports: {
align: [ 'wide', 'full' ],
html: false,
},
attributes: {
...sharedAttributes,
/**
* How to order the products: 'date', 'popularity', 'price_asc', 'price_desc' 'rating', 'title'.
*/
orderby: {
type: 'string',
default: 'date',
},
},
transforms: {
from: [
{
type: 'block',
2023-04-28 10:29:45 +00:00
blocks: sharedAttributeBlockTypes.filter(
( value ) => value !== 'woocommerce/product-on-sale'
),
transform: ( attributes ) =>
createBlock( 'woocommerce/product-on-sale', attributes ),
},
],
},
/**
* Renders and manages the block.
*
* @param {Object} props Props to pass to block.
*/
edit( props ) {
return <Block { ...props } />;
},
save() {
return null;
},
} );