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 218
/
index.js
75 lines (70 loc) · 1.43 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { Icon, review } from '@woocommerce/icons';
/**
* Internal dependencies
*/
import Editor from './edit';
import sharedAttributes from '../attributes';
import save from '../save.js';
import { example } from '../example';
const attributes = {
...sharedAttributes,
/**
* The ids of the categories to load reviews for.
*/
categoryIds: {
type: 'array',
default: [],
},
/**
* Show the product name.
*/
showProductName: {
type: 'boolean',
default: true,
},
};
/**
* Register and run the "Reviews by category" block.
*/
registerBlockType( 'woocommerce/reviews-by-category', {
title: __( 'Reviews by Category', 'woo-gutenberg-products-block' ),
icon: {
src: <Icon srcElement={ review } />,
foreground: '#96588a',
},
category: 'woocommerce',
keywords: [ __( 'WooCommerce', 'woo-gutenberg-products-block' ) ],
description: __(
'Show product reviews from specific categories.',
'woo-gutenberg-products-block'
),
supports: {
html: false,
},
example: {
...example,
attributes: {
...example.attributes,
categoryIds: [ 1 ],
showProductName: true,
},
},
attributes,
/**
* Renders and manages the block.
*
* @param {Object} props Props to pass to block.
*/
edit( props ) {
return <Editor { ...props } />;
},
/**
* Save the props to post content.
*/
save,
} );