itmar-block-packages 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +489 -0
- package/build/index.asset.php +1 -1
- package/build/index.js +13 -8
- package/img/animation.png +0 -0
- package/img/blockplace.png +0 -0
- package/img/grid.png +0 -0
- package/img/iconControl.png +0 -0
- package/img/pseudo.png +0 -0
- package/img/shadow.png +0 -0
- package/img/typography.png +0 -0
- package/package.json +14 -2
- package/src/AnimationBlock.js +112 -0
- package/src/BlockPlace.js +518 -0
- package/src/DraggableBox.js +88 -0
- package/src/GridControls.js +403 -0
- package/src/IconSelectControl.js +139 -0
- package/src/PseudoElm.js +33 -0
- package/src/ShadowStyle.js +463 -0
- package/src/ToggleElement.js +18 -0
- package/src/TypographyControls.js +113 -0
- package/src/cssPropertes.js +79 -18
- package/src/index.js +46 -17
- package/src/mediaUpload.js +45 -0
- package/src/wordpressApi.js +73 -0
- package/webpack.config.js +1 -19
- package/babel.config.js +0 -16
- package/src/Arrow.js +0 -35
- package/src/ShadowCtrl.js +0 -287
- package/src/ShadowElm.js +0 -235
- package/src/draggingFook.js +0 -88
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
|
|
2
|
+
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import {
|
|
4
|
+
__experimentalPanelColorGradientSettings as PanelColorGradientSettings,
|
|
5
|
+
} from '@wordpress/block-editor';
|
|
6
|
+
import {
|
|
7
|
+
PanelBody,
|
|
8
|
+
PanelRow,
|
|
9
|
+
ToggleControl,
|
|
10
|
+
RangeControl,
|
|
11
|
+
RadioControl
|
|
12
|
+
} from '@wordpress/components';
|
|
13
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
14
|
+
import { dispatch } from '@wordpress/data';
|
|
15
|
+
import { hslToRgb16, HexToRGB, rgb16ToHsl } from './hslToRgb';
|
|
16
|
+
|
|
17
|
+
//方向と距離
|
|
18
|
+
const dirctionDigit = (direction, distance) => {
|
|
19
|
+
let destTopLeft, destTopRight, destBottomLeft, destBottomRight;
|
|
20
|
+
switch (direction) {
|
|
21
|
+
case "top_left":
|
|
22
|
+
destTopLeft = distance;
|
|
23
|
+
destTopRight = distance;
|
|
24
|
+
destBottomLeft = distance * -1;
|
|
25
|
+
destBottomRight = distance * -1;
|
|
26
|
+
break;
|
|
27
|
+
case "top_right":
|
|
28
|
+
destTopLeft = distance * -1;
|
|
29
|
+
destTopRight = distance;
|
|
30
|
+
destBottomLeft = distance;
|
|
31
|
+
destBottomRight = distance * -1;
|
|
32
|
+
break;
|
|
33
|
+
case "bottom_left":
|
|
34
|
+
destTopLeft = distance;
|
|
35
|
+
destTopRight = distance * -1;
|
|
36
|
+
destBottomLeft = distance * -1;
|
|
37
|
+
destBottomRight = distance;
|
|
38
|
+
break;
|
|
39
|
+
case "bottom_right":
|
|
40
|
+
destTopLeft = distance * -1;
|
|
41
|
+
destTopRight = distance * -1;
|
|
42
|
+
destBottomLeft = distance;
|
|
43
|
+
destBottomRight = distance;
|
|
44
|
+
break;
|
|
45
|
+
case "right_bottom":
|
|
46
|
+
destTopLeft = distance;
|
|
47
|
+
destTopRight = distance * -1;
|
|
48
|
+
destBottomLeft = distance * -1;
|
|
49
|
+
destBottomRight = distance;
|
|
50
|
+
break;
|
|
51
|
+
case "top":
|
|
52
|
+
destTopLeft = 0;
|
|
53
|
+
destTopRight = 0;
|
|
54
|
+
destBottomLeft = distance * -1;
|
|
55
|
+
destBottomRight = distance;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
return (
|
|
59
|
+
{
|
|
60
|
+
topLeft: destTopLeft,
|
|
61
|
+
topRight: destTopRight,
|
|
62
|
+
bottomLeft: destBottomLeft,
|
|
63
|
+
bottmRight: destBottomRight
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// グラデーションの色値は通常'linear-gradient'または'radial-gradient'で始まるので、
|
|
69
|
+
// これらのキーワードを探すことでグラデーションかどうかを判断します。
|
|
70
|
+
function isGradient(colorValue) {
|
|
71
|
+
return colorValue.includes('linear-gradient') || colorValue.includes('radial-gradient');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export const ShadowElm = (shadowState) => {
|
|
76
|
+
//let baseColor;
|
|
77
|
+
const {
|
|
78
|
+
shadowType,
|
|
79
|
+
spread,
|
|
80
|
+
lateral,
|
|
81
|
+
longitude,
|
|
82
|
+
nomalBlur,
|
|
83
|
+
shadowColor,
|
|
84
|
+
blur,
|
|
85
|
+
intensity,
|
|
86
|
+
distance,
|
|
87
|
+
newDirection,
|
|
88
|
+
clayDirection,
|
|
89
|
+
embos,
|
|
90
|
+
opacity,
|
|
91
|
+
depth,
|
|
92
|
+
bdBlur,
|
|
93
|
+
expand,
|
|
94
|
+
glassblur,
|
|
95
|
+
glassopa,
|
|
96
|
+
hasOutline,
|
|
97
|
+
baseColor
|
|
98
|
+
} = shadowState;
|
|
99
|
+
|
|
100
|
+
//ノーマル
|
|
101
|
+
if (shadowType === 'nomal') {
|
|
102
|
+
//boxshadowの生成
|
|
103
|
+
const ShadowStyle = embos === 'dent' ? {
|
|
104
|
+
style: {
|
|
105
|
+
boxShadow: `${lateral}px ${longitude}px ${nomalBlur}px ${spread}px transparent, inset ${lateral}px ${longitude}px ${nomalBlur}px ${spread}px ${shadowColor}`
|
|
106
|
+
}
|
|
107
|
+
} : {
|
|
108
|
+
style: {
|
|
109
|
+
boxShadow: `${lateral}px ${longitude}px ${nomalBlur}px ${spread}px ${shadowColor}, inset ${lateral}px ${longitude}px ${nomalBlur}px ${spread}px transparent`
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//Shadowのスタイルを返す
|
|
113
|
+
return ShadowStyle;
|
|
114
|
+
}
|
|
115
|
+
//ニューモフィズム
|
|
116
|
+
else if (shadowType === 'newmor') {
|
|
117
|
+
|
|
118
|
+
//背景がグラデーションのときはセットしない
|
|
119
|
+
if (isGradient(baseColor)) {
|
|
120
|
+
dispatch('core/notices').createNotice(
|
|
121
|
+
'error',
|
|
122
|
+
__('Neumorphism cannot be set when the background color is a gradient. ', 'itmar_guest_contact_block'),
|
|
123
|
+
{ type: 'snackbar', isDismissible: true, }
|
|
124
|
+
);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
//ボタン背景色のHSL値
|
|
128
|
+
const hslValue = rgb16ToHsl(baseColor);
|
|
129
|
+
//影の明るさを変更
|
|
130
|
+
const lightVal = (hslValue.lightness + intensity) < 100 ? hslValue.lightness + intensity : 100;
|
|
131
|
+
const darkVal = (hslValue.lightness - intensity) > 0 ? hslValue.lightness - intensity : 0;
|
|
132
|
+
const lightValue = hslToRgb16(hslValue.hue, hslValue.saturation, lightVal);
|
|
133
|
+
const darkValue = hslToRgb16(hslValue.hue, hslValue.saturation, darkVal);
|
|
134
|
+
//boxshadowの生成
|
|
135
|
+
//立体の方向
|
|
136
|
+
const dircObj = dirctionDigit(newDirection, distance);
|
|
137
|
+
|
|
138
|
+
const baseStyle = {
|
|
139
|
+
style: {
|
|
140
|
+
border: 'none',
|
|
141
|
+
background: baseColor
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const newmorStyle = embos === 'swell' ? {
|
|
146
|
+
style: {
|
|
147
|
+
...baseStyle.style,
|
|
148
|
+
boxShadow: `${dircObj.topLeft}px ${dircObj.topRight}px ${blur}px ${darkValue}, ${dircObj.bottomLeft}px ${dircObj.bottmRight}px ${blur}px ${lightValue}, inset ${dircObj.topLeft}px ${dircObj.topRight}px ${blur}px transparent, inset ${dircObj.bottomLeft}px ${dircObj.bottmRight}px ${blur}px transparent`
|
|
149
|
+
}
|
|
150
|
+
} : {
|
|
151
|
+
style: {
|
|
152
|
+
...baseStyle.style,
|
|
153
|
+
boxShadow: `${dircObj.topLeft}px ${dircObj.topRight}px ${blur}px transparent, ${dircObj.bottomLeft}px ${dircObj.bottmRight}px ${blur}px transparent, inset ${dircObj.topLeft}px ${dircObj.topRight}px ${blur}px ${darkValue}, inset ${dircObj.bottomLeft}px ${dircObj.bottmRight}px ${blur}px ${lightValue}`
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//Shadowのスタイルを返す
|
|
158
|
+
return newmorStyle;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//クレイモーフィズム
|
|
162
|
+
else if (shadowType === 'claymor') {
|
|
163
|
+
//背景がグラデーションのときはセットしない
|
|
164
|
+
if (isGradient(baseColor)) {
|
|
165
|
+
dispatch('core/notices').createNotice(
|
|
166
|
+
'error',
|
|
167
|
+
__('claymorphism cannot be set when the background color is a gradient. ', 'itmar_guest_contact_block'),
|
|
168
|
+
{ type: 'snackbar', isDismissible: true, }
|
|
169
|
+
);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const rgbValue = HexToRGB(baseColor)
|
|
173
|
+
const outsetObj = dirctionDigit(clayDirection, expand)
|
|
174
|
+
const insetObj = dirctionDigit(clayDirection, depth)
|
|
175
|
+
const baseStyle = {
|
|
176
|
+
style: {
|
|
177
|
+
background: `rgba(255, 255, 255, ${opacity})`,
|
|
178
|
+
backdropFilter: `blur(${bdBlur}px)`,
|
|
179
|
+
border: 'none',
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const claymorStyle = {
|
|
183
|
+
...baseStyle,
|
|
184
|
+
style: {
|
|
185
|
+
...baseStyle.style,
|
|
186
|
+
boxShadow: `${outsetObj.topLeft}px ${outsetObj.bottmRight}px ${expand * 2}px 0px rgba(${rgbValue.red}, ${rgbValue.green}, ${rgbValue.blue}, 0.5), inset ${insetObj.topRight}px ${insetObj.bottomLeft}px 16px 0px rgba(${rgbValue.red}, ${rgbValue.green}, ${rgbValue.blue}, 0.6), inset 0px 11px 28px 0px rgb(255, 255, 255)`,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
//attributesに保存
|
|
190
|
+
return claymorStyle;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
//グラスモーフィズム
|
|
194
|
+
else if (shadowType === 'glassmor') {
|
|
195
|
+
|
|
196
|
+
const baseStyle = {
|
|
197
|
+
style: {
|
|
198
|
+
backgroundColor: `rgba(255, 255, 255, ${glassopa})`,
|
|
199
|
+
...hasOutline ? { border: `1px solid rgba(255, 255, 255, 0.4)` } : {},
|
|
200
|
+
borderRightColor: `rgba(255, 255, 255, 0.2)`,
|
|
201
|
+
borderBottomColor: `rgba(255, 255, 255, 0.2)`,
|
|
202
|
+
backdropFilter: `blur( ${glassblur}px )`
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const glassmorStyle = embos === 'swell' ? {
|
|
206
|
+
...baseStyle,
|
|
207
|
+
style: {
|
|
208
|
+
...baseStyle.style,
|
|
209
|
+
boxShadow: `0 8px 12px 0 rgba( 31, 38, 135, 0.37 ), inset 0 8px 12px 0 transparent`
|
|
210
|
+
}
|
|
211
|
+
} : {
|
|
212
|
+
...baseStyle,
|
|
213
|
+
style: {
|
|
214
|
+
...baseStyle.style,
|
|
215
|
+
boxShadow: `0 8px 12px 0 transparent, inset 0 8px 12px 0 rgba( 31, 38, 135, 0.37 )`
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//attributesに保存
|
|
221
|
+
return glassmorStyle;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const ShadowStyle = ({ shadowStyle, onChange }) => {
|
|
226
|
+
const [shadowState, setShadowState] = useState(shadowStyle);
|
|
227
|
+
|
|
228
|
+
const {
|
|
229
|
+
shadowType,
|
|
230
|
+
spread,
|
|
231
|
+
lateral,
|
|
232
|
+
longitude,
|
|
233
|
+
nomalBlur,
|
|
234
|
+
shadowColor,
|
|
235
|
+
blur,
|
|
236
|
+
intensity,
|
|
237
|
+
distance,
|
|
238
|
+
newDirection,
|
|
239
|
+
clayDirection,
|
|
240
|
+
embos,
|
|
241
|
+
opacity,
|
|
242
|
+
depth,
|
|
243
|
+
bdBlur,
|
|
244
|
+
expand,
|
|
245
|
+
glassblur,
|
|
246
|
+
glassopa,
|
|
247
|
+
hasOutline
|
|
248
|
+
} = shadowState;
|
|
249
|
+
|
|
250
|
+
//シャドーのスタイル変更と背景色変更に伴う親コンポーネントの変更
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
const shadowElm = ShadowElm(shadowState);
|
|
253
|
+
if (shadowElm) onChange(shadowElm, shadowState)
|
|
254
|
+
}, [shadowState]);
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<>
|
|
258
|
+
<PanelBody title={__("Shadow Type", 'block-collections')} initialOpen={true}>
|
|
259
|
+
<div className="itmar_shadow_type">
|
|
260
|
+
<RadioControl
|
|
261
|
+
selected={shadowType}
|
|
262
|
+
options={[
|
|
263
|
+
{ label: __("Nomal", 'block-collections'), value: 'nomal' },
|
|
264
|
+
{ label: __("Neumorphism", 'block-collections'), value: 'newmor' },
|
|
265
|
+
{ label: __("Claymorphism", 'block-collections'), value: 'claymor' },
|
|
266
|
+
{ label: __("Grassmophism", 'block-collections'), value: 'glassmor' },
|
|
267
|
+
]}
|
|
268
|
+
onChange={(changeOption) => setShadowState({ ...shadowState, shadowType: changeOption })}
|
|
269
|
+
/>
|
|
270
|
+
</div>
|
|
271
|
+
{(shadowType !== 'claymor') &&
|
|
272
|
+
<div className="embos">
|
|
273
|
+
<RadioControl
|
|
274
|
+
label={__("unevenness", 'block-collections')}
|
|
275
|
+
selected={embos}
|
|
276
|
+
options={[
|
|
277
|
+
{ value: 'swell' },
|
|
278
|
+
{ value: 'dent' },
|
|
279
|
+
|
|
280
|
+
]}
|
|
281
|
+
onChange={(changeOption) => setShadowState({ ...shadowState, embos: changeOption })}
|
|
282
|
+
/>
|
|
283
|
+
</div>
|
|
284
|
+
}
|
|
285
|
+
</PanelBody>
|
|
286
|
+
|
|
287
|
+
{shadowType === 'nomal' &&
|
|
288
|
+
<PanelBody title={__("Nomal settings", 'block-collections')} initialOpen={false}>
|
|
289
|
+
<RangeControl
|
|
290
|
+
value={spread}
|
|
291
|
+
label={__("Spread", 'block-collections')}
|
|
292
|
+
max={50}
|
|
293
|
+
min={0}
|
|
294
|
+
onChange={(val) => setShadowState({ ...shadowState, spread: val })}
|
|
295
|
+
withInputField={false}
|
|
296
|
+
/>
|
|
297
|
+
<RangeControl
|
|
298
|
+
value={lateral}
|
|
299
|
+
label={__("Lateral direction", 'block-collections')}
|
|
300
|
+
max={50}
|
|
301
|
+
min={0}
|
|
302
|
+
onChange={(val) => setShadowState({ ...shadowState, lateral: val })}
|
|
303
|
+
withInputField={false}
|
|
304
|
+
/>
|
|
305
|
+
<RangeControl
|
|
306
|
+
value={longitude}
|
|
307
|
+
label={__("Longitudinal direction", 'block-collections')}
|
|
308
|
+
max={50}
|
|
309
|
+
min={0}
|
|
310
|
+
onChange={(val) => setShadowState({ ...shadowState, longitude: val })}
|
|
311
|
+
withInputField={false}
|
|
312
|
+
/>
|
|
313
|
+
<RangeControl
|
|
314
|
+
value={nomalBlur}
|
|
315
|
+
label={__("Blur", 'block-collections')}
|
|
316
|
+
max={20}
|
|
317
|
+
min={0}
|
|
318
|
+
onChange={(val) => setShadowState({ ...shadowState, nomalBlur: val })}
|
|
319
|
+
withInputField={false}
|
|
320
|
+
/>
|
|
321
|
+
<PanelColorGradientSettings
|
|
322
|
+
title={__("Shadow Color Setting", 'block-collections')}
|
|
323
|
+
settings={[
|
|
324
|
+
{
|
|
325
|
+
colorValue: shadowColor,
|
|
326
|
+
label: __("Choose Shadow color", 'block-collections'),
|
|
327
|
+
onColorChange: (newValue) => setShadowState({ ...shadowState, shadowColor: newValue }),
|
|
328
|
+
},
|
|
329
|
+
]}
|
|
330
|
+
/>
|
|
331
|
+
|
|
332
|
+
</PanelBody>
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
{shadowType === 'newmor' &&
|
|
336
|
+
<PanelBody title={__("Neumorphism settings", 'block-collections')} initialOpen={false}>
|
|
337
|
+
<RangeControl
|
|
338
|
+
value={distance}
|
|
339
|
+
label={__("Distance", 'block-collections')}
|
|
340
|
+
max={50}
|
|
341
|
+
min={0}
|
|
342
|
+
onChange={(val) => setShadowState({ ...shadowState, distance: val })}
|
|
343
|
+
withInputField={false}
|
|
344
|
+
/>
|
|
345
|
+
<RangeControl
|
|
346
|
+
value={intensity}
|
|
347
|
+
label={__("Intensity", 'block-collections')}
|
|
348
|
+
max={100}
|
|
349
|
+
min={0}
|
|
350
|
+
onChange={(val) => setShadowState({ ...shadowState, intensity: val })}
|
|
351
|
+
withInputField={false}
|
|
352
|
+
/>
|
|
353
|
+
<RangeControl
|
|
354
|
+
value={blur}
|
|
355
|
+
label={__("Blur", 'block-collections')}
|
|
356
|
+
max={20}
|
|
357
|
+
min={0}
|
|
358
|
+
onChange={(val) => setShadowState({ ...shadowState, blur: val })}
|
|
359
|
+
withInputField={false}
|
|
360
|
+
/>
|
|
361
|
+
<PanelRow>
|
|
362
|
+
<div className="light_direction">
|
|
363
|
+
<RadioControl
|
|
364
|
+
selected={newDirection}
|
|
365
|
+
options={[
|
|
366
|
+
{ value: 'top_left' },
|
|
367
|
+
{ value: 'top_right' },
|
|
368
|
+
{ value: 'bottom_left' },
|
|
369
|
+
{ value: 'bottom_right' },
|
|
370
|
+
]}
|
|
371
|
+
onChange={(changeOption) => setShadowState({ ...shadowState, newDirection: changeOption })}
|
|
372
|
+
/>
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
</PanelRow>
|
|
376
|
+
|
|
377
|
+
</PanelBody>
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
{shadowType === 'claymor' &&
|
|
381
|
+
|
|
382
|
+
<PanelBody title={__("Claymorphism settings", 'block-collections')} initialOpen={false}>
|
|
383
|
+
<RangeControl
|
|
384
|
+
value={opacity}
|
|
385
|
+
label={__("Opacity", 'block-collections')}
|
|
386
|
+
max={1}
|
|
387
|
+
min={0}
|
|
388
|
+
step={.1}
|
|
389
|
+
onChange={(val) => setShadowState({ ...shadowState, opacity: val })}
|
|
390
|
+
withInputField={false}
|
|
391
|
+
/>
|
|
392
|
+
<RangeControl
|
|
393
|
+
value={depth}
|
|
394
|
+
label="Depth"
|
|
395
|
+
max={20}
|
|
396
|
+
min={0}
|
|
397
|
+
onChange={(val) => setShadowState({ ...shadowState, depth: val })}
|
|
398
|
+
withInputField={false}
|
|
399
|
+
/>
|
|
400
|
+
<RangeControl
|
|
401
|
+
value={expand}
|
|
402
|
+
label="Expand"
|
|
403
|
+
max={50}
|
|
404
|
+
min={0}
|
|
405
|
+
onChange={(val) => setShadowState({ ...shadowState, expand: val })}
|
|
406
|
+
withInputField={false}
|
|
407
|
+
/>
|
|
408
|
+
<RangeControl
|
|
409
|
+
value={bdBlur}
|
|
410
|
+
label="Background Blur"
|
|
411
|
+
max={10}
|
|
412
|
+
min={0}
|
|
413
|
+
onChange={(val) => setShadowState({ ...shadowState, bdBlur: val })}
|
|
414
|
+
withInputField={false}
|
|
415
|
+
/>
|
|
416
|
+
<div className="light_direction claymor">
|
|
417
|
+
<RadioControl
|
|
418
|
+
selected={clayDirection}
|
|
419
|
+
options={[
|
|
420
|
+
{ value: 'right_bottom' },
|
|
421
|
+
{ value: 'top_right' },
|
|
422
|
+
{ value: 'top' },
|
|
423
|
+
]}
|
|
424
|
+
onChange={(changeOption) => setShadowState({ ...shadowState, clayDirection: changeOption })}
|
|
425
|
+
/>
|
|
426
|
+
</div>
|
|
427
|
+
</PanelBody>
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
{shadowType === 'glassmor' &&
|
|
431
|
+
<PanelBody title={__("Grassmophism settings", 'block-collections')} initialOpen={false}>
|
|
432
|
+
<RangeControl
|
|
433
|
+
value={glassblur}
|
|
434
|
+
label={__("Glass blur", 'block-collections')}
|
|
435
|
+
max={20}
|
|
436
|
+
min={0}
|
|
437
|
+
onChange={(val) => setShadowState({ ...shadowState, glassblur: val })}
|
|
438
|
+
withInputField={false}
|
|
439
|
+
/>
|
|
440
|
+
<RangeControl
|
|
441
|
+
value={glassopa}
|
|
442
|
+
label={__("Glass Opacity", 'block-collections')}
|
|
443
|
+
max={1}
|
|
444
|
+
min={0}
|
|
445
|
+
step={.1}
|
|
446
|
+
onChange={(val) => setShadowState({ ...shadowState, glassopa: val })}
|
|
447
|
+
withInputField={false}
|
|
448
|
+
/>
|
|
449
|
+
<fieldset>
|
|
450
|
+
<ToggleControl
|
|
451
|
+
label={__("Show outline", 'block-collections')}
|
|
452
|
+
checked={hasOutline}
|
|
453
|
+
onChange={() => setShadowState({ ...shadowState, hasOutline: !hasOutline })}
|
|
454
|
+
/>
|
|
455
|
+
</fieldset>
|
|
456
|
+
</PanelBody>
|
|
457
|
+
}
|
|
458
|
+
</>
|
|
459
|
+
|
|
460
|
+
);
|
|
461
|
+
};
|
|
462
|
+
export default ShadowStyle;
|
|
463
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
export default function ToggleElement(props) {
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const toggleOpen = () => {
|
|
6
|
+
props.onToggle && props.onToggle(!props.openFlg);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
className={`${props.className} ${props.openFlg ? 'open' : ''}`}
|
|
12
|
+
style={props.style}
|
|
13
|
+
onClick={toggleOpen}
|
|
14
|
+
>
|
|
15
|
+
{props.children}
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PanelBody,
|
|
3
|
+
PanelRow,
|
|
4
|
+
RadioControl,
|
|
5
|
+
ToggleControl,
|
|
6
|
+
__experimentalUnitControl as UnitControl,
|
|
7
|
+
} from '@wordpress/components';
|
|
8
|
+
|
|
9
|
+
import Select from 'react-select';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
|
|
12
|
+
const TypographyControls = ({ title, fontStyle, initialOpen, isMobile, onChange }) => {
|
|
13
|
+
const {
|
|
14
|
+
default_fontSize,
|
|
15
|
+
mobile_fontSize,
|
|
16
|
+
fontSize,
|
|
17
|
+
fontFamily,
|
|
18
|
+
fontWeight,
|
|
19
|
+
isItalic
|
|
20
|
+
} = fontStyle;
|
|
21
|
+
|
|
22
|
+
const fontFamilyOptions = [
|
|
23
|
+
{ value: 'Arial, sans-serif', label: 'Arial', fontFamily: 'Arial, sans-serif' },
|
|
24
|
+
{ value: 'Courier New, monospace', label: 'Courier New', fontFamily: 'Courier New, monospace' },
|
|
25
|
+
{ value: 'Georgia, serif', label: 'Georgia', fontFamily: 'Georgia, serif' },
|
|
26
|
+
{ label: 'Noto Sans JP', value: 'Noto Sans JP, sans-serif', fontFamily: 'Noto Sans JP, sans-serif' },
|
|
27
|
+
{ label: 'Texturina', value: 'Texturina, serif', fontFamily: 'Texturina, serif' },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const units = [
|
|
31
|
+
{ value: 'px', label: 'px' },
|
|
32
|
+
{ value: 'em', label: 'em' },
|
|
33
|
+
{ value: 'rem', label: 'rem' },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const customStyles = {
|
|
37
|
+
option: (provided, state) => ({
|
|
38
|
+
...provided,
|
|
39
|
+
fontFamily: state.data.fontFamily,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const FontSelect = ({ label, value, onChange }) => (
|
|
44
|
+
<>
|
|
45
|
+
{label && <label className="components-base-control__label">{label}</label>}
|
|
46
|
+
<Select
|
|
47
|
+
options={fontFamilyOptions}
|
|
48
|
+
value={fontFamilyOptions.find((option) => option.value === value)}
|
|
49
|
+
onChange={(newValue) => {
|
|
50
|
+
onChange(newValue.value);
|
|
51
|
+
}}
|
|
52
|
+
styles={customStyles}
|
|
53
|
+
/>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<PanelBody title={title} initialOpen={initialOpen} >
|
|
59
|
+
<UnitControl
|
|
60
|
+
dragDirection="e"
|
|
61
|
+
onChange={(newValue) => {
|
|
62
|
+
newValue = newValue != '' ? newValue : '0px'
|
|
63
|
+
const set_size = !isMobile ? { default_fontSize: newValue } : { mobile_fontSize: newValue };
|
|
64
|
+
const newStyle = { ...fontStyle, ...set_size };
|
|
65
|
+
onChange(newStyle);
|
|
66
|
+
}}
|
|
67
|
+
label={!isMobile ?
|
|
68
|
+
__("Size(desk top)", 'block-collections')
|
|
69
|
+
: __("Size(mobile)", 'block-collections')}
|
|
70
|
+
value={!isMobile ? default_fontSize : mobile_fontSize}
|
|
71
|
+
units={units}
|
|
72
|
+
/>
|
|
73
|
+
|
|
74
|
+
<FontSelect
|
|
75
|
+
label={__("font family", 'block-collections')}
|
|
76
|
+
value={fontFamily}
|
|
77
|
+
onChange={(newValue) => {
|
|
78
|
+
const newStyle = { ...fontStyle, fontFamily: newValue };
|
|
79
|
+
onChange(newStyle);
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<label className="components-base-control__label">{__('font weight', 'block-collections')}</label>
|
|
84
|
+
<PanelRow className='itmar_weight_row'>
|
|
85
|
+
<RadioControl
|
|
86
|
+
selected={fontWeight}
|
|
87
|
+
options={[
|
|
88
|
+
{ label: 'LIGHT', value: "300" },
|
|
89
|
+
{ label: 'REGULAR', value: "400" },
|
|
90
|
+
{ label: 'MEDIUM', value: "500" },
|
|
91
|
+
{ label: 'S-BOLD', value: "600" },
|
|
92
|
+
{ label: 'BOLD', value: "700" },
|
|
93
|
+
{ label: 'BLACK', value: "900" },
|
|
94
|
+
]}
|
|
95
|
+
onChange={(newValue) => {
|
|
96
|
+
const newStyle = { ...fontStyle, fontWeight: newValue };
|
|
97
|
+
onChange(newStyle);
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
</PanelRow>
|
|
101
|
+
|
|
102
|
+
<label className="components-base-control__label">{__('Italic display', 'block-collections')}</label>
|
|
103
|
+
<ToggleControl
|
|
104
|
+
checked={isItalic}
|
|
105
|
+
onChange={(newValue) => {
|
|
106
|
+
const newStyle = { ...fontStyle, isItalic: newValue };
|
|
107
|
+
onChange(newStyle);
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
</PanelBody>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
export default TypographyControls;
|