PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.1.1
GenerateBlocks v2.1.1
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 1 year ago ShapeDividerControls.jsx 1 year ago
BlockSettings.jsx
153 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 generalSvgs from '@components/icon-picker/svgs-general';
15 import socialSvgs from '@components/icon-picker/svgs-social';
16 import { ShapeDividerControls } from './ShapeDividerControls';
17
18 export const shapeColorControls = [
19 {
20 label: 'Color',
21 id: 'shape-color',
22 items: [
23 {
24 tooltip: 'Color',
25 value: 'color',
26 selector: 'svg',
27 },
28 ],
29 },
30 ];
31
32 export function BlockSettings( {
33 getStyleValue,
34 onStyleChange,
35 name,
36 attributes,
37 setAttributes,
38 } ) {
39 const {
40 html,
41 className,
42 } = attributes;
43
44 const {
45 atRule,
46 } = useBlockStyles();
47
48 const panelProps = {
49 name,
50 attributes,
51 setAttributes,
52 getStyleValue,
53 onStyleChange,
54 };
55
56 const iconType = className?.includes( 'gb-shape--divider' ) ? 'divider' : 'icon';
57
58 let icons = applyFilters(
59 'generateblocks.editor.iconSVGSets',
60 {
61 general: {
62 group: __( 'General', 'generateblocks' ),
63 svgs: generalSvgs,
64 },
65 social: {
66 group: __( 'Social', 'generateblocks' ),
67 svgs: socialSvgs,
68 },
69 },
70 { attributes }
71 );
72
73 if ( 'divider' === iconType ) {
74 icons = generateBlocksInfo.svgShapes;
75 }
76
77 return (
78 <ApplyFilters
79 name="generateblocks.editor.blockControls"
80 blockName={ name }
81 getStyleValue={ getStyleValue }
82 onStyleChange={ onStyleChange }
83 currentAtRule={ atRule }
84 attributes={ attributes }
85 setAttributes={ setAttributes }
86 >
87 <OpenPanel
88 { ...panelProps }
89 panelId="shape"
90 >
91 { '' === atRule && (
92 <IconControl
93 label={ __( 'Shape', 'generateblocks' ) }
94 value={ html }
95 onChange={ ( value ) => setAttributes( { html: value } ) }
96 onClear={ () => setAttributes( { html: '' } ) }
97 icons={ icons }
98 iconType={ iconType }
99 clearLabel={ __( 'Clear', 'generateblocks' ) }
100 openLabel={ __( 'Open Library', 'generateblocks' ) }
101 modalTitle={ __( 'Shape Library', 'generateblocks' ) }
102 />
103 ) }
104
105 <ShapeDividerControls
106 onStyleChange={ onStyleChange }
107 getStyleValue={ getStyleValue }
108 />
109 </OpenPanel>
110
111 <OpenPanel
112 { ...panelProps }
113 dropdownOptions={ [
114 moreDesignOptions,
115 ] }
116 panelId="design"
117 >
118 <Flex>
119 <FlexBlock>
120 <UnitControl
121 id="width"
122 label={ __( 'Width', 'generateblocks' ) }
123 value={ getStyleValue( 'width', atRule, 'svg' ) }
124 onChange={ ( value ) => onStyleChange( 'width', value, atRule, 'svg' ) }
125 />
126 </FlexBlock>
127
128 <FlexBlock>
129 <UnitControl
130 id="height"
131 label={ __( 'Height', 'generateblocks' ) }
132 value={ getStyleValue( 'height', atRule, 'svg' ) }
133 onChange={ ( value ) => onStyleChange( 'height', value, atRule, 'svg' ) }
134 />
135 </FlexBlock>
136 </Flex>
137
138 <ColorPickerControls
139 items={ shapeColorControls }
140 getStyleValue={ getStyleValue }
141 onStyleChange={ onStyleChange }
142 currentAtRule={ atRule }
143 />
144 </OpenPanel>
145
146 <OpenPanel
147 { ...panelProps }
148 panelId="settings"
149 />
150 </ApplyFilters>
151 );
152 }
153