Remove more duplication in product element definitions

This commit is contained in:
Karol Manijak 2024-08-23 15:07:35 +02:00
parent 385303ac92
commit 10ed8f4f90
6 changed files with 17 additions and 51 deletions

View File

@ -4,13 +4,8 @@
*/
import { __experimentalGetSpacingClassesAndStyles } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import sharedConfig from '../shared/config';
export const supports = {
...sharedConfig.supports,
html: false,
color: {
text: true,
background: true,

View File

@ -1,9 +1,9 @@
{
"name": "woocommerce/product-rating",
"version": "1.0.0",
"icon": "info",
"title": "Product Rating",
"description": "Display the average rating of a product.",
"category": "woocommerce-product-elements",
"attributes": {
"productId": {
"type": "number",
@ -26,18 +26,15 @@
"default": false
}
},
"usesContext": [
"query",
"queryId",
"postId"
"ancestor": [
"woocommerce/all-products",
"woocommerce/single-product",
"woocommerce/product-template",
"core/post-template"
],
"keywords": [
"WooCommerce"
],
"supports": {
"align": true
},
"usesContext": [ "query", "queryId", "postId" ],
"keywords": [ "WooCommerce" ],
"textdomain": "woocommerce",
"apiVersion": 3,
"$schema": "https://schemas.wp.org/trunk/block.json"
}
}

View File

@ -1,28 +1,23 @@
/**
* External dependencies
*/
import type { BlockConfiguration } from '@wordpress/blocks';
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils';
/**
* Internal dependencies
*/
import sharedConfig from '../shared/config';
import edit from './edit';
import { BLOCK_ICON as icon } from './constants';
import metadata from './block.json';
import { supports } from './support';
const blockConfig: BlockConfiguration = {
...sharedConfig,
icon: { src: icon },
supports,
edit,
};
registerBlockSingleProductTemplate( {
blockName: 'woocommerce/product-rating',
blockMetadata: metadata,
blockSettings: blockConfig,
blockSettings: {
icon: { src: icon },
supports,
edit,
},
isAvailableOnPostEditor: true,
} );

View File

@ -17,18 +17,7 @@ import save from '../save';
const sharedConfig: Omit< BlockConfiguration, 'attributes' | 'title' > = {
category: 'woocommerce-product-elements',
keywords: [ __( 'WooCommerce', 'woocommerce' ) ],
icon: {
src: (
<Icon
icon={ grid }
className="wc-block-editor-components-block-icon"
/>
),
},
apiVersion: 3,
supports: {
html: false,
},
ancestor: [
'woocommerce/all-products',
'woocommerce/single-product',

View File

@ -7,13 +7,8 @@ import {
__experimentalGetSpacingClassesAndStyles,
} from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import sharedConfig from '../shared/config';
export const supports = {
...sharedConfig.supports,
html: false,
color: {
text: true,
background: true,

View File

@ -7,13 +7,8 @@ import {
__experimentalGetSpacingClassesAndStyles,
} from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import sharedConfig from '../shared/config';
export const supports = {
...sharedConfig.supports,
html: false,
color: {
text: true,
background: true,