PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.6.0
GenerateBlocks v1.6.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 / button / components / InspectorControls.js
generateblocks / src / blocks / button / components Last commit date
BlockControls.js 4 years ago ButtonContentRenderer.js 4 years ago ComponentCSS.js 4 years ago ConditionalColors.js 4 years ago InspectorAdvancedControls.js 4 years ago InspectorControls.js 4 years ago
InspectorControls.js
278 lines
1 import PanelArea from '../../../components/panel-area';
2 import { __ } from '@wordpress/i18n';
3 import getIcon from '../../../utils/get-icon';
4 import { Fragment } from '@wordpress/element';
5 import TypographyControls from '../../../components/typography';
6 import { applyFilters } from '@wordpress/hooks';
7 import DimensionsControl from '../../../components/dimensions';
8 import DimensionsGroup from '../../../components/dimensions-group';
9 import ColorGroup from '../../../components/color-group';
10 import GradientControl from '../../../components/gradient';
11 import IconPicker from '../../../components/icon-picker';
12 import { InspectorControls } from '@wordpress/block-editor';
13 import NumberControl from '../../../components/number-control';
14 import './ConditionalColors';
15
16 export default ( props ) => {
17 const {
18 attributes,
19 deviceType,
20 state,
21 blockDefaults,
22 computedStyles,
23 } = props;
24
25 const {
26 icon,
27 removeText,
28 iconSizeUnit,
29 } = attributes;
30
31 return (
32 <InspectorControls>
33 <PanelArea
34 { ...props }
35 title={ __( 'Typography', 'generateblocks' ) }
36 initialOpen={ false }
37 icon={ getIcon( 'typography' ) }
38 className={ 'gblocks-panel-label' }
39 id={ 'buttonTypography' }
40 state={ state }
41 showPanel={ ! removeText || false }
42 >
43 <TypographyControls
44 { ...props }
45 deviceType={ deviceType }
46 options={ [ 'fontWeight', 'textTransform', 'fontSize', 'letterSpacing', 'fontFamily' ] }
47 computedStyles={ computedStyles }
48 />
49
50 { applyFilters( 'generateblocks.editor.controls', '', 'buttonTypography', props, state ) }
51 </PanelArea>
52
53 <PanelArea
54 { ...props }
55 title={ __( 'Spacing', 'generateblocks' ) }
56 initialOpen={ false }
57 icon={ getIcon( 'spacing' ) }
58 className={ 'gblocks-panel-label' }
59 id={ 'buttonSpacing' }
60 state={ state }
61 >
62 <DimensionsGroup
63 { ...props }
64 deviceType={ deviceType }
65 dimensions={
66 [
67 {
68 type: 'padding',
69 label: __( 'Padding', 'generateblocks' ),
70 units: [ 'px', 'em', '%' ],
71 },
72 {
73 type: 'margin',
74 label: __( 'Margin', 'generateblocks' ),
75 units: [ 'px', 'em', '%' ],
76 },
77 {
78 type: 'borderSize',
79 label: __( 'Border Size', 'generateblocks' ),
80 units: [ 'px' ],
81 },
82 {
83 type: 'borderRadius',
84 label: __( 'Border Radius', 'generateblocks' ),
85 units: [ 'px', 'em', '%' ],
86 },
87 ]
88 }
89 />
90
91 { applyFilters( 'generateblocks.editor.controls', '', 'buttonSpacing', props, state ) }
92 </PanelArea>
93
94 <PanelArea
95 { ...props }
96 title={ __( 'Colors', 'generateblocks' ) }
97 initialOpen={ false }
98 icon={ getIcon( 'colors' ) }
99 className={ 'gblocks-panel-label' }
100 id={ 'buttonColors' }
101 state={ state }
102 >
103 { 'Desktop' === deviceType &&
104 <ColorGroup
105 { ...props }
106 colors={
107 [
108 {
109 group: 'background',
110 label: __( 'Background', 'generateblocks' ),
111 items: [
112 {
113 attribute: 'backgroundColor',
114 alpha: true,
115 },
116 {
117 tooltip: __( 'Hover', 'generateblocks' ),
118 attribute: 'backgroundColorHover',
119 alpha: true,
120 },
121 ],
122 },
123 {
124 group: 'text',
125 label: __( 'Text', 'generateblocks' ),
126 items: [
127 {
128 attribute: 'textColor',
129 },
130 {
131 tooltip: __( 'Hover', 'generateblocks' ),
132 attribute: 'textColorHover',
133 },
134 ],
135 },
136 {
137 group: 'border',
138 label: __( 'Border', 'generateblocks' ),
139 items: [
140 {
141 attribute: 'borderColor',
142 alpha: true,
143 },
144 {
145 tooltip: __( 'Hover', 'generateblocks' ),
146 attribute: 'borderColorHover',
147 alpha: true,
148 },
149 ],
150 },
151 ]
152 }
153 />
154 }
155
156 { applyFilters( 'generateblocks.editor.controls', '', 'buttonColors', props, state ) }
157 </PanelArea>
158
159 <PanelArea
160 { ...props }
161 title={ __( 'Background Gradient', 'generateblocks' ) }
162 initialOpen={ false }
163 icon={ getIcon( 'gradients' ) }
164 className={ 'gblocks-panel-label' }
165 id={ 'buttonBackgroundGradient' }
166 state={ state }
167 >
168 { 'Desktop' === deviceType &&
169 <GradientControl
170 { ...props }
171 attrGradient={ 'gradient' }
172 attrGradientDirection={ 'gradientDirection' }
173 attrGradientColorOne={ 'gradientColorOne' }
174 attrGradientColorOneOpacity={ 'gradientColorOneOpacity' }
175 attrGradientColorStopOne={ 'gradientColorStopOne' }
176 attrGradientColorTwo={ 'gradientColorTwo' }
177 attrGradientColorTwoOpacity={ 'gradientColorTwoOpacity' }
178 attrGradientColorStopTwo={ 'gradientColorStopTwo' }
179 defaultColorOne={ blockDefaults.gradientColorOne }
180 defaultColorTwo={ blockDefaults.gradientColorTwo }
181 />
182 }
183
184 { applyFilters( 'generateblocks.editor.controls', '', 'buttonBackgroundGradient', props, state ) }
185 </PanelArea>
186
187 <PanelArea
188 { ...props }
189 title={ __( 'Icon', 'generateblocks' ) }
190 initialOpen={ false }
191 icon={ getIcon( 'icons' ) }
192 className={ 'gblocks-panel-label' }
193 id={ 'buttonIcon' }
194 state={ state }
195 showPanel={ 'Desktop' === deviceType || !! icon ? true : false }
196 >
197
198 { 'Desktop' === deviceType &&
199 <IconPicker
200 { ...props }
201 attrIcon={ 'icon' }
202 attrIconLocation={ 'iconLocation' }
203 attrRemoveText={ 'removeText' }
204 locationOptions={ [
205 { label: __( 'Left', 'generateblocks' ), value: 'left' },
206 { label: __( 'Right', 'generateblocks' ), value: 'right' },
207 ] }
208 />
209 }
210
211 { 'Desktop' === deviceType && !! icon && (
212 <Fragment>
213 { ! removeText &&
214 <DimensionsControl
215 { ...props }
216 device={ deviceType }
217 type={ 'iconPadding' }
218 label={ __( 'Padding', 'generateblocks' ) }
219 units={ [ 'px', 'em', '%' ] }
220 />
221 }
222 </Fragment>
223 ) }
224
225 { 'Tablet' === deviceType && !! icon &&
226 <Fragment>
227 { ! removeText &&
228 <DimensionsControl
229 { ...props }
230 device={ deviceType }
231 type={ 'iconPadding' }
232 label={ __( 'Padding', 'generateblocks' ) }
233 units={ [ 'px', 'em', '%' ] }
234 />
235 }
236 </Fragment>
237 }
238
239 { 'Mobile' === deviceType && !! icon && (
240 <Fragment>
241 { ! removeText &&
242 <DimensionsControl
243 { ...props }
244 device={ deviceType }
245 type={ 'iconPadding' }
246 label={ __( 'Padding', 'generateblocks' ) }
247 units={ [ 'px', 'em', '%' ] }
248 />
249 }
250 </Fragment>
251 ) }
252
253 { !! icon &&
254 <NumberControl
255 { ...props }
256 label={ __( 'Icon Size', 'generateblocks' ) }
257 attributeName="iconSize"
258 units={ [ 'px', 'em' ] }
259 device={ deviceType }
260 presets={
261 [
262 {
263 unit: 'em',
264 data: [ 0.7, 1, 1.5, 2 ],
265 },
266 ]
267 }
268 min="1"
269 step={ 'em' === iconSizeUnit ? .1 : 1 }
270 />
271 }
272
273 { applyFilters( 'generateblocks.editor.controls', '', 'buttonIcon', props, state ) }
274 </PanelArea>
275 </InspectorControls>
276 );
277 };
278