PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.2.0
GenerateBlocks v2.2.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / shape / components / BlockSettings.jsx
generateblocks / src / blocks / shape / components Last commit date
BlockSettings.jsx 7 months ago ShapeDividerControls.jsx 1 year ago
BlockSettings.jsx
142 lines
1 import { __ } from '@wordpress/i18n';
2 import { applyFilters } from '@wordpress/hooks';
3 import { Flex, FlexBlock } from '@wordpress/components';
4
5 import { OpenPanel, IconControl } from '@edge22/components';
6 import { UnitControl } from '@edge22/styles-builder';
7
8 import {
9 ApplyFilters,
10 ColorPickerControls,
11 } from '@components/index.js';
12 import { moreDesignOptions } from '@utils';
13 import { useBlockStyles } from '@hooks/useBlockStyles';
14 import { ShapeDividerControls } from './ShapeDividerControls';
15
16 export const shapeColorControls = [
17 {
18 label: 'Color',
19 id: 'shape-color',
20 items: [
21 {
22 tooltip: 'Color',
23 value: 'color',
24 selector: 'svg',
25 },
26 ],
27 },
28 ];
29
30 export function BlockSettings( {
31 getStyleValue,
32 onStyleChange,
33 name,
34 attributes,
35 setAttributes,
36 } ) {
37 const {
38 html,
39 className,
40 } = attributes;
41
42 const {
43 atRule,
44 } = useBlockStyles();
45
46 const panelProps = {
47 name,
48 attributes,
49 setAttributes,
50 getStyleValue,
51 onStyleChange,
52 };
53
54 const iconType = className?.includes( 'gb-shape--divider' ) ? 'divider' : 'icon';
55
56 let icons = applyFilters(
57 'generateblocks.editor.iconSVGSets',
58 {},
59 { attributes }
60 );
61
62 if ( 'divider' === iconType ) {
63 icons = generateBlocksInfo.svgShapes;
64 }
65
66 return (
67 <ApplyFilters
68 name="generateblocks.editor.blockControls"
69 blockName={ name }
70 getStyleValue={ getStyleValue }
71 onStyleChange={ onStyleChange }
72 currentAtRule={ atRule }
73 attributes={ attributes }
74 setAttributes={ setAttributes }
75 >
76 <OpenPanel
77 { ...panelProps }
78 panelId="shape"
79 >
80 { '' === atRule && (
81 <IconControl
82 label={ __( 'Shape', 'generateblocks' ) }
83 value={ html }
84 onChange={ ( value ) => setAttributes( { html: value } ) }
85 onClear={ () => setAttributes( { html: '' } ) }
86 icons={ icons }
87 iconType={ iconType }
88 clearLabel={ __( 'Clear', 'generateblocks' ) }
89 openLabel={ __( 'Open Library', 'generateblocks' ) }
90 modalTitle={ __( 'Shape Library', 'generateblocks' ) }
91 />
92 ) }
93
94 <ShapeDividerControls
95 onStyleChange={ onStyleChange }
96 getStyleValue={ getStyleValue }
97 />
98 </OpenPanel>
99
100 <OpenPanel
101 { ...panelProps }
102 dropdownOptions={ [
103 moreDesignOptions,
104 ] }
105 panelId="design"
106 >
107 <Flex>
108 <FlexBlock>
109 <UnitControl
110 id="width"
111 label={ __( 'Width', 'generateblocks' ) }
112 value={ getStyleValue( 'width', atRule, 'svg' ) }
113 onChange={ ( value ) => onStyleChange( 'width', value, atRule, 'svg' ) }
114 />
115 </FlexBlock>
116
117 <FlexBlock>
118 <UnitControl
119 id="height"
120 label={ __( 'Height', 'generateblocks' ) }
121 value={ getStyleValue( 'height', atRule, 'svg' ) }
122 onChange={ ( value ) => onStyleChange( 'height', value, atRule, 'svg' ) }
123 />
124 </FlexBlock>
125 </Flex>
126
127 <ColorPickerControls
128 items={ shapeColorControls }
129 getStyleValue={ getStyleValue }
130 onStyleChange={ onStyleChange }
131 currentAtRule={ atRule }
132 />
133 </OpenPanel>
134
135 <OpenPanel
136 { ...panelProps }
137 panelId="settings"
138 />
139 </ApplyFilters>
140 );
141 }
142