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
package/src/ShadowCtrl.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { __ } from "@wordpress/i18n";
|
|
2
|
-
import { __experimentalPanelColorGradientSettings as PanelColorGradientSettings } from "@wordpress/block-editor";
|
|
3
|
-
import {
|
|
4
|
-
PanelBody,
|
|
5
|
-
PanelRow,
|
|
6
|
-
ToggleControl,
|
|
7
|
-
RangeControl,
|
|
8
|
-
RadioControl,
|
|
9
|
-
} from "@wordpress/components";
|
|
10
|
-
import { useState, useEffect } from "@wordpress/element";
|
|
11
|
-
import { ShadowElm } from "./ShadowElm";
|
|
12
|
-
|
|
13
|
-
const ShadowCtrl = ({ shadowStyle, onChange }) => {
|
|
14
|
-
const [shadowState, setShadowState] = useState(shadowStyle);
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
shadowType,
|
|
18
|
-
spread,
|
|
19
|
-
lateral,
|
|
20
|
-
longitude,
|
|
21
|
-
nomalBlur,
|
|
22
|
-
shadowColor,
|
|
23
|
-
blur,
|
|
24
|
-
intensity,
|
|
25
|
-
distance,
|
|
26
|
-
newDirection,
|
|
27
|
-
clayDirection,
|
|
28
|
-
embos,
|
|
29
|
-
opacity,
|
|
30
|
-
depth,
|
|
31
|
-
bdBlur,
|
|
32
|
-
expand,
|
|
33
|
-
glassblur,
|
|
34
|
-
glassopa,
|
|
35
|
-
hasOutline,
|
|
36
|
-
} = shadowState;
|
|
37
|
-
|
|
38
|
-
//シャドーのスタイル変更と背景色変更に伴う親コンポーネントの変更
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const shadowElm = ShadowElm(shadowState);
|
|
41
|
-
if (shadowElm) onChange(shadowElm, shadowState);
|
|
42
|
-
}, [shadowState]);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<>
|
|
46
|
-
<PanelBody
|
|
47
|
-
title={__("Shadow Type", "block-collections")}
|
|
48
|
-
initialOpen={true}
|
|
49
|
-
>
|
|
50
|
-
<div className="itmar_shadow_type">
|
|
51
|
-
<RadioControl
|
|
52
|
-
selected={shadowType}
|
|
53
|
-
options={[
|
|
54
|
-
{ label: __("Nomal", "block-collections"), value: "nomal" },
|
|
55
|
-
{
|
|
56
|
-
label: __("Neumorphism", "block-collections"),
|
|
57
|
-
value: "newmor",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
label: __("Claymorphism", "block-collections"),
|
|
61
|
-
value: "claymor",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
label: __("Grassmophism", "block-collections"),
|
|
65
|
-
value: "glassmor",
|
|
66
|
-
},
|
|
67
|
-
]}
|
|
68
|
-
onChange={(changeOption) =>
|
|
69
|
-
setShadowState({ ...shadowState, shadowType: changeOption })
|
|
70
|
-
}
|
|
71
|
-
/>
|
|
72
|
-
</div>
|
|
73
|
-
{shadowType !== "claymor" && (
|
|
74
|
-
<div className="embos">
|
|
75
|
-
<RadioControl
|
|
76
|
-
label={__("unevenness", "block-collections")}
|
|
77
|
-
selected={embos}
|
|
78
|
-
options={[{ value: "swell" }, { value: "dent" }]}
|
|
79
|
-
onChange={(changeOption) =>
|
|
80
|
-
setShadowState({ ...shadowState, embos: changeOption })
|
|
81
|
-
}
|
|
82
|
-
/>
|
|
83
|
-
</div>
|
|
84
|
-
)}
|
|
85
|
-
</PanelBody>
|
|
86
|
-
|
|
87
|
-
{shadowType === "nomal" && (
|
|
88
|
-
<PanelBody
|
|
89
|
-
title={__("Nomal settings", "block-collections")}
|
|
90
|
-
initialOpen={false}
|
|
91
|
-
>
|
|
92
|
-
<RangeControl
|
|
93
|
-
value={spread}
|
|
94
|
-
label={__("Spread", "block-collections")}
|
|
95
|
-
max={50}
|
|
96
|
-
min={0}
|
|
97
|
-
onChange={(val) => setShadowState({ ...shadowState, spread: val })}
|
|
98
|
-
withInputField={false}
|
|
99
|
-
/>
|
|
100
|
-
<RangeControl
|
|
101
|
-
value={lateral}
|
|
102
|
-
label={__("Lateral direction", "block-collections")}
|
|
103
|
-
max={50}
|
|
104
|
-
min={0}
|
|
105
|
-
onChange={(val) => setShadowState({ ...shadowState, lateral: val })}
|
|
106
|
-
withInputField={false}
|
|
107
|
-
/>
|
|
108
|
-
<RangeControl
|
|
109
|
-
value={longitude}
|
|
110
|
-
label={__("Longitudinal direction", "block-collections")}
|
|
111
|
-
max={50}
|
|
112
|
-
min={0}
|
|
113
|
-
onChange={(val) =>
|
|
114
|
-
setShadowState({ ...shadowState, longitude: val })
|
|
115
|
-
}
|
|
116
|
-
withInputField={false}
|
|
117
|
-
/>
|
|
118
|
-
<RangeControl
|
|
119
|
-
value={nomalBlur}
|
|
120
|
-
label={__("Blur", "block-collections")}
|
|
121
|
-
max={20}
|
|
122
|
-
min={0}
|
|
123
|
-
onChange={(val) =>
|
|
124
|
-
setShadowState({ ...shadowState, nomalBlur: val })
|
|
125
|
-
}
|
|
126
|
-
withInputField={false}
|
|
127
|
-
/>
|
|
128
|
-
<PanelColorGradientSettings
|
|
129
|
-
title={__("Shadow Color Setting", "block-collections")}
|
|
130
|
-
settings={[
|
|
131
|
-
{
|
|
132
|
-
colorValue: shadowColor,
|
|
133
|
-
label: __("Choose Shadow color", "block-collections"),
|
|
134
|
-
onColorChange: (newValue) =>
|
|
135
|
-
setShadowState({ ...shadowState, shadowColor: newValue }),
|
|
136
|
-
},
|
|
137
|
-
]}
|
|
138
|
-
/>
|
|
139
|
-
</PanelBody>
|
|
140
|
-
)}
|
|
141
|
-
|
|
142
|
-
{shadowType === "newmor" && (
|
|
143
|
-
<PanelBody
|
|
144
|
-
title={__("Neumorphism settings", "block-collections")}
|
|
145
|
-
initialOpen={false}
|
|
146
|
-
>
|
|
147
|
-
<RangeControl
|
|
148
|
-
value={distance}
|
|
149
|
-
label={__("Distance", "block-collections")}
|
|
150
|
-
max={50}
|
|
151
|
-
min={0}
|
|
152
|
-
onChange={(val) =>
|
|
153
|
-
setShadowState({ ...shadowState, distance: val })
|
|
154
|
-
}
|
|
155
|
-
withInputField={false}
|
|
156
|
-
/>
|
|
157
|
-
<RangeControl
|
|
158
|
-
value={intensity}
|
|
159
|
-
label={__("Intensity", "block-collections")}
|
|
160
|
-
max={100}
|
|
161
|
-
min={0}
|
|
162
|
-
onChange={(val) =>
|
|
163
|
-
setShadowState({ ...shadowState, intensity: val })
|
|
164
|
-
}
|
|
165
|
-
withInputField={false}
|
|
166
|
-
/>
|
|
167
|
-
<RangeControl
|
|
168
|
-
value={blur}
|
|
169
|
-
label={__("Blur", "block-collections")}
|
|
170
|
-
max={20}
|
|
171
|
-
min={0}
|
|
172
|
-
onChange={(val) => setShadowState({ ...shadowState, blur: val })}
|
|
173
|
-
withInputField={false}
|
|
174
|
-
/>
|
|
175
|
-
<PanelRow>
|
|
176
|
-
<div className="light_direction">
|
|
177
|
-
<RadioControl
|
|
178
|
-
selected={newDirection}
|
|
179
|
-
options={[
|
|
180
|
-
{ value: "top_left" },
|
|
181
|
-
{ value: "top_right" },
|
|
182
|
-
{ value: "bottom_left" },
|
|
183
|
-
{ value: "bottom_right" },
|
|
184
|
-
]}
|
|
185
|
-
onChange={(changeOption) =>
|
|
186
|
-
setShadowState({ ...shadowState, newDirection: changeOption })
|
|
187
|
-
}
|
|
188
|
-
/>
|
|
189
|
-
</div>
|
|
190
|
-
</PanelRow>
|
|
191
|
-
</PanelBody>
|
|
192
|
-
)}
|
|
193
|
-
{shadowType === "claymor" && (
|
|
194
|
-
<PanelBody
|
|
195
|
-
title={__("Claymorphism settings", "block-collections")}
|
|
196
|
-
initialOpen={false}
|
|
197
|
-
>
|
|
198
|
-
<RangeControl
|
|
199
|
-
value={opacity}
|
|
200
|
-
label={__("Opacity", "block-collections")}
|
|
201
|
-
max={1}
|
|
202
|
-
min={0}
|
|
203
|
-
step={0.1}
|
|
204
|
-
onChange={(val) => setShadowState({ ...shadowState, opacity: val })}
|
|
205
|
-
withInputField={false}
|
|
206
|
-
/>
|
|
207
|
-
<RangeControl
|
|
208
|
-
value={depth}
|
|
209
|
-
label="Depth"
|
|
210
|
-
max={20}
|
|
211
|
-
min={0}
|
|
212
|
-
onChange={(val) => setShadowState({ ...shadowState, depth: val })}
|
|
213
|
-
withInputField={false}
|
|
214
|
-
/>
|
|
215
|
-
<RangeControl
|
|
216
|
-
value={expand}
|
|
217
|
-
label="Expand"
|
|
218
|
-
max={50}
|
|
219
|
-
min={0}
|
|
220
|
-
onChange={(val) => setShadowState({ ...shadowState, expand: val })}
|
|
221
|
-
withInputField={false}
|
|
222
|
-
/>
|
|
223
|
-
<RangeControl
|
|
224
|
-
value={bdBlur}
|
|
225
|
-
label="Background Blur"
|
|
226
|
-
max={10}
|
|
227
|
-
min={0}
|
|
228
|
-
onChange={(val) => setShadowState({ ...shadowState, bdBlur: val })}
|
|
229
|
-
withInputField={false}
|
|
230
|
-
/>
|
|
231
|
-
<div className="light_direction claymor">
|
|
232
|
-
<RadioControl
|
|
233
|
-
selected={clayDirection}
|
|
234
|
-
options={[
|
|
235
|
-
{ value: "right_bottom" },
|
|
236
|
-
{ value: "top_right" },
|
|
237
|
-
{ value: "top" },
|
|
238
|
-
]}
|
|
239
|
-
onChange={(changeOption) =>
|
|
240
|
-
setShadowState({ ...shadowState, clayDirection: changeOption })
|
|
241
|
-
}
|
|
242
|
-
/>
|
|
243
|
-
</div>
|
|
244
|
-
</PanelBody>
|
|
245
|
-
)}
|
|
246
|
-
|
|
247
|
-
{shadowType === "glassmor" && (
|
|
248
|
-
<PanelBody
|
|
249
|
-
title={__("Grassmophism settings", "block-collections")}
|
|
250
|
-
initialOpen={false}
|
|
251
|
-
>
|
|
252
|
-
<RangeControl
|
|
253
|
-
value={glassblur}
|
|
254
|
-
label={__("Glass blur", "block-collections")}
|
|
255
|
-
max={20}
|
|
256
|
-
min={0}
|
|
257
|
-
onChange={(val) =>
|
|
258
|
-
setShadowState({ ...shadowState, glassblur: val })
|
|
259
|
-
}
|
|
260
|
-
withInputField={false}
|
|
261
|
-
/>
|
|
262
|
-
<RangeControl
|
|
263
|
-
value={glassopa}
|
|
264
|
-
label={__("Glass Opacity", "block-collections")}
|
|
265
|
-
max={1}
|
|
266
|
-
min={0}
|
|
267
|
-
step={0.1}
|
|
268
|
-
onChange={(val) =>
|
|
269
|
-
setShadowState({ ...shadowState, glassopa: val })
|
|
270
|
-
}
|
|
271
|
-
withInputField={false}
|
|
272
|
-
/>
|
|
273
|
-
<fieldset>
|
|
274
|
-
<ToggleControl
|
|
275
|
-
label={__("Show outline", "block-collections")}
|
|
276
|
-
checked={hasOutline}
|
|
277
|
-
onChange={() =>
|
|
278
|
-
setShadowState({ ...shadowState, hasOutline: !hasOutline })
|
|
279
|
-
}
|
|
280
|
-
/>
|
|
281
|
-
</fieldset>
|
|
282
|
-
</PanelBody>
|
|
283
|
-
)}
|
|
284
|
-
</>
|
|
285
|
-
);
|
|
286
|
-
};
|
|
287
|
-
export default ShadowCtrl;
|
package/src/ShadowElm.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { __ } from "@wordpress/i18n";
|
|
2
|
-
import { dispatch } from "@wordpress/data";
|
|
3
|
-
import { hslToRgb16, HexToRGB, rgb16ToHsl } from "./hslToRgb";
|
|
4
|
-
|
|
5
|
-
//方向と距離
|
|
6
|
-
const dirctionDigit = (direction, distance) => {
|
|
7
|
-
let destTopLeft, destTopRight, destBottomLeft, destBottomRight;
|
|
8
|
-
switch (direction) {
|
|
9
|
-
case "top_left":
|
|
10
|
-
destTopLeft = distance;
|
|
11
|
-
destTopRight = distance;
|
|
12
|
-
destBottomLeft = distance * -1;
|
|
13
|
-
destBottomRight = distance * -1;
|
|
14
|
-
break;
|
|
15
|
-
case "top_right":
|
|
16
|
-
destTopLeft = distance * -1;
|
|
17
|
-
destTopRight = distance;
|
|
18
|
-
destBottomLeft = distance;
|
|
19
|
-
destBottomRight = distance * -1;
|
|
20
|
-
break;
|
|
21
|
-
case "bottom_left":
|
|
22
|
-
destTopLeft = distance;
|
|
23
|
-
destTopRight = distance * -1;
|
|
24
|
-
destBottomLeft = distance * -1;
|
|
25
|
-
destBottomRight = distance;
|
|
26
|
-
break;
|
|
27
|
-
case "bottom_right":
|
|
28
|
-
destTopLeft = distance * -1;
|
|
29
|
-
destTopRight = distance * -1;
|
|
30
|
-
destBottomLeft = distance;
|
|
31
|
-
destBottomRight = distance;
|
|
32
|
-
break;
|
|
33
|
-
case "right_bottom":
|
|
34
|
-
destTopLeft = distance;
|
|
35
|
-
destTopRight = distance * -1;
|
|
36
|
-
destBottomLeft = distance * -1;
|
|
37
|
-
destBottomRight = distance;
|
|
38
|
-
break;
|
|
39
|
-
case "top":
|
|
40
|
-
destTopLeft = 0;
|
|
41
|
-
destTopRight = 0;
|
|
42
|
-
destBottomLeft = distance * -1;
|
|
43
|
-
destBottomRight = distance;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
topLeft: destTopLeft,
|
|
48
|
-
topRight: destTopRight,
|
|
49
|
-
bottomLeft: destBottomLeft,
|
|
50
|
-
bottmRight: destBottomRight,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// グラデーションの色値は通常'linear-gradient'または'radial-gradient'で始まるので、
|
|
55
|
-
// これらのキーワードを探すことでグラデーションかどうかを判断します。
|
|
56
|
-
function isGradient(colorValue) {
|
|
57
|
-
return (
|
|
58
|
-
colorValue.includes("linear-gradient") ||
|
|
59
|
-
colorValue.includes("radial-gradient")
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const ShadowElm = (shadowState) => {
|
|
64
|
-
//let baseColor;
|
|
65
|
-
const {
|
|
66
|
-
shadowType,
|
|
67
|
-
spread,
|
|
68
|
-
lateral,
|
|
69
|
-
longitude,
|
|
70
|
-
nomalBlur,
|
|
71
|
-
shadowColor,
|
|
72
|
-
blur,
|
|
73
|
-
intensity,
|
|
74
|
-
distance,
|
|
75
|
-
newDirection,
|
|
76
|
-
clayDirection,
|
|
77
|
-
embos,
|
|
78
|
-
opacity,
|
|
79
|
-
depth,
|
|
80
|
-
bdBlur,
|
|
81
|
-
expand,
|
|
82
|
-
glassblur,
|
|
83
|
-
glassopa,
|
|
84
|
-
hasOutline,
|
|
85
|
-
baseColor,
|
|
86
|
-
} = shadowState;
|
|
87
|
-
|
|
88
|
-
//ノーマル
|
|
89
|
-
if (shadowType === "nomal") {
|
|
90
|
-
//boxshadowの生成
|
|
91
|
-
const ShadowStyle =
|
|
92
|
-
embos === "dent"
|
|
93
|
-
? {
|
|
94
|
-
style: {
|
|
95
|
-
boxShadow: `${lateral}px ${longitude}px ${nomalBlur}px ${spread}px transparent, inset ${lateral}px ${longitude}px ${nomalBlur}px ${spread}px ${shadowColor}`,
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
: {
|
|
99
|
-
style: {
|
|
100
|
-
boxShadow: `${lateral}px ${longitude}px ${nomalBlur}px ${spread}px ${shadowColor}, inset ${lateral}px ${longitude}px ${nomalBlur}px ${spread}px transparent`,
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
//Shadowのスタイルを返す
|
|
104
|
-
return ShadowStyle;
|
|
105
|
-
}
|
|
106
|
-
//ニューモフィズム
|
|
107
|
-
else if (shadowType === "newmor") {
|
|
108
|
-
//背景がグラデーションのときはセットしない
|
|
109
|
-
if (isGradient(baseColor)) {
|
|
110
|
-
dispatch("core/notices").createNotice(
|
|
111
|
-
"error",
|
|
112
|
-
__(
|
|
113
|
-
"Neumorphism cannot be set when the background color is a gradient. ",
|
|
114
|
-
"itmar_guest_contact_block"
|
|
115
|
-
),
|
|
116
|
-
{ type: "snackbar", isDismissible: true }
|
|
117
|
-
);
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
//ボタン背景色のHSL値
|
|
121
|
-
const hslValue = rgb16ToHsl(baseColor);
|
|
122
|
-
//影の明るさを変更
|
|
123
|
-
const lightVal =
|
|
124
|
-
hslValue.lightness + intensity < 100
|
|
125
|
-
? hslValue.lightness + intensity
|
|
126
|
-
: 100;
|
|
127
|
-
const darkVal =
|
|
128
|
-
hslValue.lightness - intensity > 0 ? hslValue.lightness - intensity : 0;
|
|
129
|
-
const lightValue = hslToRgb16(hslValue.hue, hslValue.saturation, lightVal);
|
|
130
|
-
const darkValue = hslToRgb16(hslValue.hue, hslValue.saturation, darkVal);
|
|
131
|
-
//boxshadowの生成
|
|
132
|
-
//立体の方向
|
|
133
|
-
const dircObj = dirctionDigit(newDirection, distance);
|
|
134
|
-
|
|
135
|
-
const baseStyle = {
|
|
136
|
-
style: {
|
|
137
|
-
border: "none",
|
|
138
|
-
background: baseColor,
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const newmorStyle =
|
|
143
|
-
embos === "swell"
|
|
144
|
-
? {
|
|
145
|
-
style: {
|
|
146
|
-
...baseStyle.style,
|
|
147
|
-
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`,
|
|
148
|
-
},
|
|
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
|
-
__(
|
|
168
|
-
"claymorphism cannot be set when the background color is a gradient. ",
|
|
169
|
-
"itmar_guest_contact_block"
|
|
170
|
-
),
|
|
171
|
-
{ type: "snackbar", isDismissible: true }
|
|
172
|
-
);
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
const rgbValue = HexToRGB(baseColor);
|
|
176
|
-
const outsetObj = dirctionDigit(clayDirection, expand);
|
|
177
|
-
const insetObj = dirctionDigit(clayDirection, depth);
|
|
178
|
-
const baseStyle = {
|
|
179
|
-
style: {
|
|
180
|
-
background: `rgba(255, 255, 255, ${opacity})`,
|
|
181
|
-
backdropFilter: `blur(${bdBlur}px)`,
|
|
182
|
-
border: "none",
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
const claymorStyle = {
|
|
186
|
-
...baseStyle,
|
|
187
|
-
style: {
|
|
188
|
-
...baseStyle.style,
|
|
189
|
-
boxShadow: `${outsetObj.topLeft}px ${outsetObj.bottmRight}px ${
|
|
190
|
-
expand * 2
|
|
191
|
-
}px 0px rgba(${rgbValue.red}, ${rgbValue.green}, ${
|
|
192
|
-
rgbValue.blue
|
|
193
|
-
}, 0.5), inset ${insetObj.topRight}px ${
|
|
194
|
-
insetObj.bottomLeft
|
|
195
|
-
}px 16px 0px rgba(${rgbValue.red}, ${rgbValue.green}, ${
|
|
196
|
-
rgbValue.blue
|
|
197
|
-
}, 0.6), inset 0px 11px 28px 0px rgb(255, 255, 255)`,
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
//attributesに保存
|
|
201
|
-
return claymorStyle;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
//グラスモーフィズム
|
|
205
|
-
else if (shadowType === "glassmor") {
|
|
206
|
-
const baseStyle = {
|
|
207
|
-
style: {
|
|
208
|
-
backgroundColor: `rgba(255, 255, 255, ${glassopa})`,
|
|
209
|
-
...(hasOutline ? { border: `1px solid rgba(255, 255, 255, 0.4)` } : {}),
|
|
210
|
-
borderRightColor: `rgba(255, 255, 255, 0.2)`,
|
|
211
|
-
borderBottomColor: `rgba(255, 255, 255, 0.2)`,
|
|
212
|
-
backdropFilter: `blur( ${glassblur}px )`,
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
const glassmorStyle =
|
|
216
|
-
embos === "swell"
|
|
217
|
-
? {
|
|
218
|
-
...baseStyle,
|
|
219
|
-
style: {
|
|
220
|
-
...baseStyle.style,
|
|
221
|
-
boxShadow: `0 8px 12px 0 rgba( 31, 38, 135, 0.37 ), inset 0 8px 12px 0 transparent`,
|
|
222
|
-
},
|
|
223
|
-
}
|
|
224
|
-
: {
|
|
225
|
-
...baseStyle,
|
|
226
|
-
style: {
|
|
227
|
-
...baseStyle.style,
|
|
228
|
-
boxShadow: `0 8px 12px 0 transparent, inset 0 8px 12px 0 rgba( 31, 38, 135, 0.37 )`,
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
//attributesに保存
|
|
233
|
-
return glassmorStyle;
|
|
234
|
-
}
|
|
235
|
-
};
|
package/src/draggingFook.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "@wordpress/element";
|
|
2
|
-
import { __ } from "@wordpress/i18n";
|
|
3
|
-
|
|
4
|
-
export const useDraggingMove = (
|
|
5
|
-
isMovable,
|
|
6
|
-
blockRef,
|
|
7
|
-
position,
|
|
8
|
-
onPositionChange
|
|
9
|
-
) => {
|
|
10
|
-
const elmposition = useRef({ x: 0, y: 0 });
|
|
11
|
-
const isDragging = useRef(false);
|
|
12
|
-
const mousePosition = useRef({ x: 0, y: 0 });
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const element = blockRef.current;
|
|
16
|
-
|
|
17
|
-
if (!isMovable) {
|
|
18
|
-
if (element) {
|
|
19
|
-
element.classList.remove("itmar_isDraggable"); //移動カーソル表示クラス削除
|
|
20
|
-
}
|
|
21
|
-
return; // 移動許可がある場合のみ、後続のロジックを実行
|
|
22
|
-
}
|
|
23
|
-
//positionの変化に合わせて現在位置を変更
|
|
24
|
-
const pos_value_x = position.x.match(/(-?\d+)([%a-zA-Z]+)/);
|
|
25
|
-
const pos_value_y = position.y.match(/(-?\d+)([%a-zA-Z]+)/);
|
|
26
|
-
elmposition.current = {
|
|
27
|
-
x: parseInt(pos_value_x[1]),
|
|
28
|
-
y: parseInt(pos_value_y[1]),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
//イベントハンドラ
|
|
32
|
-
const handleMouseDown = (event) => {
|
|
33
|
-
// 移動カーソル表示クラス名を追加します。
|
|
34
|
-
element.classList.add("itmar_isDraggable");
|
|
35
|
-
//ドラッグの開始フラグオン
|
|
36
|
-
isDragging.current = true;
|
|
37
|
-
//ドラッグ開始の絶対位置
|
|
38
|
-
mousePosition.current = { x: event.clientX, y: event.clientY };
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const handleMouseMove = (event) => {
|
|
42
|
-
if (!isDragging.current) return; //ドラッグ中でなければ処理を中止
|
|
43
|
-
const dx = event.clientX - mousePosition.current.x;
|
|
44
|
-
const dy = event.clientY - mousePosition.current.y;
|
|
45
|
-
//ドラッグ後の位置を保存
|
|
46
|
-
const newPosition = {
|
|
47
|
-
x: elmposition.current.x + dx,
|
|
48
|
-
y: elmposition.current.y + dy,
|
|
49
|
-
};
|
|
50
|
-
elmposition.current = newPosition;
|
|
51
|
-
mousePosition.current = { x: event.clientX, y: event.clientY }; //マウス位置の保存
|
|
52
|
-
//ドラッグによるブロックの一時的移動
|
|
53
|
-
element.style.transform = `translate(${elmposition.current.x}px, ${elmposition.current.y}px)`;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const handleMouseUp = () => {
|
|
57
|
-
isDragging.current = false;
|
|
58
|
-
element.style.transform = null;
|
|
59
|
-
//呼出しもとに要素の位置を返す
|
|
60
|
-
onPositionChange({
|
|
61
|
-
x: `${elmposition.current.x}px`,
|
|
62
|
-
y: `${elmposition.current.y}px`,
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
const handleMouseLeave = () => {
|
|
66
|
-
isDragging.current = false;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
if (element) {
|
|
70
|
-
// クラス名を追加します。
|
|
71
|
-
element.classList.add("itmar_isDraggable");
|
|
72
|
-
}
|
|
73
|
-
// イベントハンドラを追加します。
|
|
74
|
-
element.addEventListener("mousedown", handleMouseDown);
|
|
75
|
-
element.addEventListener("mousemove", handleMouseMove);
|
|
76
|
-
element.addEventListener("mouseup", handleMouseUp);
|
|
77
|
-
element.addEventListener("mouseleave", handleMouseLeave);
|
|
78
|
-
|
|
79
|
-
// イベントリスナーを削除するクリーンアップ関数を返します。
|
|
80
|
-
return () => {
|
|
81
|
-
element.removeEventListener("mousedown", handleMouseDown);
|
|
82
|
-
element.removeEventListener("mousemove", handleMouseMove);
|
|
83
|
-
element.removeEventListener("mouseup", handleMouseUp);
|
|
84
|
-
element.removeEventListener("mouseleave", handleMouseLeave);
|
|
85
|
-
element.style.transform = null;
|
|
86
|
-
};
|
|
87
|
-
}, [isMovable, blockRef, position, onPositionChange]); // 依存配列に isMovable を含めます
|
|
88
|
-
};
|