This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
143 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
assets/js/atomic/blocks/product-elements/product-meta/block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "woocommerce/product-meta", | ||
"version": "1.0.0", | ||
"title": "Product Meta", | ||
"icon": "product", | ||
"description": "Display Product Meta", | ||
"category": "woocommerce", | ||
"supports": { | ||
"align": true, | ||
"reusable": false | ||
}, | ||
"keywords": [ "WooCommerce" ], | ||
"usesContext": [ "postId", "postType", "queryId" ], | ||
"textdomain": "woo-gutenberg-products-block", | ||
"apiVersion": 2, | ||
"$schema": "https://schemas.wp.org/trunk/block.json" | ||
} |
50 changes: 50 additions & 0 deletions
50
assets/js/atomic/blocks/product-elements/product-meta/edit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; | ||
import { InnerBlockTemplate } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './editor.scss'; | ||
|
||
const Edit = () => { | ||
const TEMPLATE: InnerBlockTemplate[] = [ | ||
[ | ||
'core/group', | ||
{ layout: { type: 'flex', flexWrap: 'nowrap' } }, | ||
[ | ||
[ | ||
'woocommerce/product-sku', | ||
{ | ||
isDescendentOfSingleProductTemplate: true, | ||
}, | ||
], | ||
[ | ||
'core/post-terms', | ||
{ | ||
prefix: 'Category: ', | ||
term: 'product_cat', | ||
}, | ||
], | ||
[ | ||
'core/post-terms', | ||
{ | ||
prefix: 'Tags: ', | ||
term: 'product_tag', | ||
}, | ||
], | ||
], | ||
], | ||
]; | ||
const blockProps = useBlockProps(); | ||
|
||
return ( | ||
<div { ...blockProps }> | ||
<InnerBlocks template={ TEMPLATE } /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Edit; |
4 changes: 4 additions & 0 deletions
4
assets/js/atomic/blocks/product-elements/product-meta/editor.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.wc-block-editor-related-products__notice { | ||
margin: 10px auto; | ||
max-width: max-content; | ||
} |
28 changes: 28 additions & 0 deletions
28
assets/js/atomic/blocks/product-elements/product-meta/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { box as icon } from '@wordpress/icons'; | ||
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks'; | ||
import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import edit from './edit'; | ||
import save from './save'; | ||
import metadata from './block.json'; | ||
|
||
registerBlockSingleProductTemplate( { | ||
registerBlockFn: () => { | ||
// @ts-expect-error: `registerBlockType` is a function that is typed in WordPress core. | ||
registerBlockType( metadata, { | ||
icon, | ||
edit, | ||
save, | ||
} ); | ||
}, | ||
unregisterBlockFn: () => { | ||
unregisterBlockType( metadata.name ); | ||
}, | ||
blockName: metadata.name, | ||
} ); |
17 changes: 17 additions & 0 deletions
17
assets/js/atomic/blocks/product-elements/product-meta/save.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor'; | ||
|
||
const Save = () => { | ||
const blockProps = useBlockProps.save(); | ||
|
||
return ( | ||
<div { ...blockProps }> | ||
{ /* @ts-expect-error: `InnerBlocks.Content` is a component that is typed in WordPress core*/ } | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Save; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.