2022-12-22 15:01:01 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2023-03-03 14:44:34 +00:00
|
|
|
import { registerBlockType, registerBlockVariation } from '@wordpress/blocks';
|
2022-12-22 15:01:01 +00:00
|
|
|
import { Icon } from '@wordpress/icons';
|
|
|
|
import { customerAccount } from '@woocommerce/icons';
|
2023-03-03 14:44:34 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2022-12-22 15:01:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import metadata from './block.json';
|
|
|
|
import edit from './edit';
|
2023-07-04 11:06:48 +00:00
|
|
|
import './style.scss';
|
2022-12-22 15:01:01 +00:00
|
|
|
|
|
|
|
registerBlockType( metadata, {
|
|
|
|
icon: {
|
|
|
|
src: (
|
|
|
|
<Icon
|
|
|
|
icon={ customerAccount }
|
|
|
|
className="wc-block-editor-components-block-icon"
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
attributes: {
|
|
|
|
...metadata.attributes,
|
|
|
|
},
|
|
|
|
edit,
|
|
|
|
save() {
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
} );
|
2023-03-03 14:44:34 +00:00
|
|
|
|
|
|
|
// We needed to change the size of the icon without affecting already existing blocks.
|
|
|
|
// This is why we are registering a new variation with a different icon class instead of changing directly the icon
|
|
|
|
// size in the css. By giving it the same name and making it default we are making sure that new blocks will use the
|
|
|
|
// new icon size and existing blocks will keep using the old one after updating the plugin.
|
|
|
|
// For more context, see https://github.com/woocommerce/woocommerce-blocks/pull/8594
|
|
|
|
registerBlockVariation( 'woocommerce/customer-account', {
|
|
|
|
name: 'woocommerce/customer-account',
|
2023-12-12 22:12:36 +00:00
|
|
|
title: __( 'Customer account', 'woocommerce' ),
|
2023-03-03 14:44:34 +00:00
|
|
|
isDefault: true,
|
|
|
|
attributes: {
|
|
|
|
...metadata.attributes,
|
|
|
|
displayStyle: 'icon_and_text',
|
|
|
|
iconStyle: 'default',
|
|
|
|
iconClass: 'wc-block-customer-account__account-icon',
|
|
|
|
},
|
|
|
|
} );
|