PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / blocks / container / styleTab.js

styleTab.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at src/blocks/container/styleTab.js

436 lines 11.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from "@wordpress/i18n";
2 import {
3 Background,
4 Border,
5 BoxShadow,
6 Divider,
7 InputControl,
8 SelectField,
9 Spacing,
10 SpColorPicker,
11 SPRangeControl,
12 SPToggleGroupControl,
13 Toggle,
14 } from "../../components";
15 import { useState } from "@wordpress/element";
16 import { BgIcon, GradientIcon, Image, Video } from "../../components/background/svgIcon";
17
18 import { allBgType, excludeVideoBgType, imageBlandMode, overlayTypeItems } from "../../controls/constants";
19 import { useDeviceType } from "../../controls/controls";
20 import { Editor } from "@monaco-editor/react";
21
22 // const overlayTypeItems = [
23 // {
24 // label: __( 'No Overlay', 'post-carousel' ),
25 // value: 'no-overlay',
26 // },
27 // {
28 // label: __( 'Solid', 'post-carousel' ),
29 // value: 'solid-overlay',
30 // },
31 // {
32 // label: __( 'Gradient', 'post-carousel' ),
33 // value: 'gradient-overlay',
34 // },
35 // ];
36 // const allBgType = [
37 // {
38 // label: <BgIcon />,
39 // value: 'bgColor',
40 // tooltip: 'Solid',
41 // },
42 // {
43 // label: <GradientIcon />,
44 // value: 'gradient',
45 // tooltip: 'Gradient',
46 // },
47 // {
48 // label: <Image />,
49 // value: 'image',
50 // tooltip: 'Image',
51 // },
52 // {
53 // label: <Video />,
54 // value: 'video',
55 // tooltip: 'Video',
56 // },
57 // ];
58 // const excludeVideoBgType = [
59 // {
60 // label: <BgIcon />,
61 // value: 'bgColor',
62 // tooltip: 'Solid',
63 // },
64 // {
65 // label: <GradientIcon />,
66 // value: 'gradient',
67 // tooltip: 'Gradient',
68 // },
69 // {
70 // label: <Image />,
71 // value: 'image',
72 // tooltip: 'Image',
73 // },
74 // ];
75
76 export const ContainerStyleTab = ({ attributes, setAttributes }) => {
77 const {
78 containerBG,
79 containerBGImage,
80 containerBGVideo,
81 containerOverlayType,
82 containerOverlayBg,
83 containerOverlayOpacity,
84 containerOverlayBlandMode,
85 containerBorder,
86 containerBorderWidth,
87 containerBorderRadius,
88 containerBoxShadowEnable,
89 containerBoxShadow,
90 containerPadding,
91 containerMargin,
92 containerBGImageHover,
93 containerBoxShadowHover,
94 containerBoxShadowEnableHover,
95 containerBoxShadowDefault,
96 containerBoxShadowDefaultHover,
97 containerOverlayTypeHover,
98 containerOverlayOpacityHover,
99 containerOverlayBlandModeHover,
100 containerBorderWidthHover,
101 containerBorderRadiusHover,
102 } = attributes;
103 const [bgState, setBgState] = useState("color");
104
105 const bgBtn = bgState === "color" ? allBgType : excludeVideoBgType;
106 const deviceType = useDeviceType();
107
108 const overlayTypeHandler = (newValue, key) => {
109 setAttributes({
110 [key]: newValue,
111 containerOverlayBg: {
112 ...containerOverlayBg,
113 [bgState]: {
114 ...containerOverlayBg[bgState],
115 style: newValue === "gradient-overlay" ? "gradient" : "bgColor",
116 },
117 },
118 });
119 };
120 const overlayOpacityHandler = (newValue, key) => {
121 const attr = attributes[key];
122 setAttributes({
123 [key]: {
124 ...attr,
125 device: { ...attr.device, [deviceType]: newValue.value },
126 },
127 });
128 };
129
130 return (
131 <>
132 <SPToggleGroupControl
133 attributes={bgState}
134 onClick={(newValue) => setBgState(newValue)}
135 items={[
136 {
137 value: "color",
138 label: __("Normal", "post-carousel"),
139 },
140 {
141 value: "hover",
142 label: __("Hover", "post-carousel"),
143 },
144 ]}
145 />
146 <Background
147 label={__("Background Style", "post-carousel")}
148 attributes={containerBG}
149 attributesKey={"containerBG"}
150 setAttributes={setAttributes}
151 colorType={bgState}
152 imageObj={{
153 imageKey: "containerBGImage",
154 // hoverKey: 'containerBGImageHover',
155 backgroundImage: containerBGImage,
156 // hoverImg: containerBGImageHover,
157 }}
158 videoObj={{
159 imageKey: "containerBGVideo",
160 backgroundImage: containerBGVideo,
161 }}
162 items={bgBtn}
163 />
164 {"color" === bgState && (
165 <>
166 {["image", "video"].includes(containerBG.color.style) && (
167 <>
168 <SelectField
169 label={__("Overlay Type", "post-carousel")}
170 attributes={containerOverlayType}
171 attributesKey={"containerOverlayType"}
172 setAttributes={setAttributes}
173 onChange={(newValue) => overlayTypeHandler(newValue, "containerOverlayType")}
174 items={overlayTypeItems}
175 />
176 {"no-overlay" !== containerOverlayType && (
177 <>
178 <p style={{ marginBottom: "0" }}>
179 {containerOverlayBg[bgState].style === "gradient" && "Gradient Color"}
180 </p>
181 <Background
182 attributes={containerOverlayBg}
183 attributesKey={"containerOverlayBg"}
184 setAttributes={setAttributes}
185 colorType={bgState}
186 />
187 <SPRangeControl
188 label={__("Opacity", "post-carousel")}
189 attributes={containerOverlayOpacity}
190 attributesKey={"containerOverlayOpacity"}
191 setAttributes={setAttributes}
192 units={["%"]}
193 max={100}
194 defaultValue={{
195 unit: "%",
196 value: 75,
197 }}
198 customValue={containerOverlayOpacity.device?.[deviceType]}
199 onValueChange={(newValue) =>
200 overlayOpacityHandler(newValue, "containerOverlayOpacity")
201 }
202 />
203 <SelectField
204 label={__("Blend Mode", "post-carousel")}
205 attributes={containerOverlayBlandMode}
206 attributesKey={"containerOverlayBlandMode"}
207 setAttributes={setAttributes}
208 items={imageBlandMode}
209 />
210 </>
211 )}
212 </>
213 )}
214 <Border
215 label={__("Border", "post-carousel")}
216 attributes={{
217 border: containerBorder,
218 borderWidth: containerBorderWidth,
219 }}
220 attributesKey={{
221 border: "containerBorder",
222 borderWidth: "containerBorderWidth",
223 }}
224 setAttributes={setAttributes}
225 units={["px", "%", "em"]}
226 defaultValue={{ unit: "px", value: 1 }}
227 btnType={"normal"}
228 />
229 <Spacing
230 label={__("Border Radius", "post-carousel")}
231 attributes={containerBorderRadius}
232 attributesKey={"containerBorderRadius"}
233 setAttributes={setAttributes}
234 units={["px", "%", "em"]}
235 defaultValue={{
236 unit: "px",
237 value: { top: 0, right: 0, bottom: 0, left: 0 },
238 }}
239 indicator={"radius"}
240 />
241 <Toggle
242 label={__("Box Shadow", "post-carousel")}
243 attributes={containerBoxShadowEnable}
244 attributesKey={"containerBoxShadowEnable"}
245 setAttributes={setAttributes}
246 />
247 {containerBoxShadowEnable && (
248 <>
249 <BoxShadow
250 label={__("Box Shadow Value", "post-carousel")}
251 attributes={containerBoxShadow}
252 attributesKey={"containerBoxShadow"}
253 setAttributes={setAttributes}
254 />
255 </>
256 )}
257 </>
258 )}
259 {"hover" === bgState && (
260 <>
261 {"image" === containerBG.hover.style && (
262 <>
263 <SelectField
264 label={__("Overlay Type on Hover", "post-carousel")}
265 attributes={containerOverlayTypeHover}
266 attributesKey={"containerOverlayTypeHover"}
267 setAttributes={setAttributes}
268 onChange={(newValue) => overlayTypeHandler(newValue, "containerOverlayTypeHover")}
269 items={overlayTypeItems}
270 />
271 {"no-overlay" !== containerOverlayTypeHover && (
272 <>
273 <p style={{ marginBottom: "0" }}>
274 {containerOverlayBg[bgState].style === "gradient" && "Gradient Color"}
275 </p>
276 <Background
277 attributes={containerOverlayBg}
278 attributesKey={"containerOverlayBg"}
279 setAttributes={setAttributes}
280 colorType={bgState}
281 />
282 <SPRangeControl
283 label={__("Hover Opacity", "post-carousel")}
284 attributes={containerOverlayOpacityHover}
285 attributesKey={"containerOverlayOpacityHover"}
286 setAttributes={setAttributes}
287 units={["%"]}
288 max={100}
289 defaultValue={{
290 unit: "%",
291 value: 50,
292 }}
293 customValue={containerOverlayOpacityHover.device?.[deviceType]}
294 onValueChange={(newValue) =>
295 overlayOpacityHandler(newValue, "containerOverlayOpacityHover")
296 }
297 />
298 <SelectField
299 label={__("Blend Mode", "post-carousel")}
300 attributes={containerOverlayBlandModeHover}
301 attributesKey={"containerOverlayBlandModeHover"}
302 setAttributes={setAttributes}
303 items={imageBlandMode}
304 />
305 </>
306 )}
307 </>
308 )}
309 <Border
310 label={__("Border", "post-carousel")}
311 attributes={{
312 border: containerBorder,
313 borderWidth: containerBorderWidthHover,
314 }}
315 attributesKey={{
316 border: "containerBorder",
317 borderWidth: "containerBorderWidthHover",
318 }}
319 setAttributes={setAttributes}
320 units={["px", "%", "em"]}
321 defaultValue={{ unit: "px", value: "" }}
322 btnType={"hover"}
323 />
324 <Spacing
325 label={__("Border Radius", "post-carousel")}
326 attributes={containerBorderRadiusHover}
327 attributesKey={"containerBorderRadiusHover"}
328 setAttributes={setAttributes}
329 units={["px", "%", "em"]}
330 defaultValue={{
331 unit: "px",
332 value: { top: 0, right: 0, bottom: 0, left: 0 },
333 }}
334 indicator={"radius"}
335 />
336 <Toggle
337 label={__("Box Shadow on Hover", "post-carousel")}
338 attributes={containerBoxShadowEnableHover}
339 attributesKey={"containerBoxShadowEnableHover"}
340 setAttributes={setAttributes}
341 />
342 {containerBoxShadowEnableHover && (
343 <BoxShadow
344 label={__("Box Shadow Value on Hover", "post-carousel")}
345 attributes={containerBoxShadowHover}
346 attributesKey={"containerBoxShadowHover"}
347 setAttributes={setAttributes}
348 />
349 )}
350 </>
351 )}
352 <Divider position={"w-100pct bottom"} />
353 <Spacing
354 label={__("Padding", "post-carousel")}
355 attributes={containerPadding}
356 attributesKey={"containerPadding"}
357 setAttributes={setAttributes}
358 units={["px", "%", "em"]}
359 max={200}
360 defaultValue={{
361 unit: "px",
362 value: { top: 8, right: 10, bottom: 8, left: 10 },
363 }}
364 />
365 <Spacing
366 label={__("Margin", "post-carousel")}
367 attributes={containerMargin}
368 attributesKey={"containerMargin"}
369 setAttributes={setAttributes}
370 units={["px", "%", "em"]}
371 max={200}
372 defaultValue={{
373 unit: "px",
374 value: { top: 8, right: 10, bottom: 8, left: 10 },
375 }}
376 />
377 </>
378 );
379 };
380
381 export const ContainerVisibilityTab = ({ attributes, setAttributes }) => {
382 const { advanceVisibilityHideDesktop, advanceVisibilityHideTablet, advanceVisibilityHideMobile } = attributes;
383
384 return (
385 <>
386 <Toggle
387 label={__("Hide on Desktop", "post-carousel")}
388 attributes={advanceVisibilityHideDesktop}
389 attributesKey={"advanceVisibilityHideDesktop"}
390 setAttributes={setAttributes}
391 pro={true}
392 />
393 <Toggle
394 label={__("Hide on Tablet", "post-carousel")}
395 attributes={advanceVisibilityHideTablet}
396 attributesKey={"advanceVisibilityHideTablet"}
397 setAttributes={setAttributes}
398 pro={true}
399 />
400 <Toggle
401 label={__("Hide on Mobile", "post-carousel")}
402 attributes={advanceVisibilityHideMobile}
403 attributesKey={"advanceVisibilityHideMobile"}
404 setAttributes={setAttributes}
405 pro={true}
406 />
407 </>
408 );
409 };
410
411 export const ContainerAdvanceAdvancedTab = ({ attributes, setAttributes }) => {
412 const { advancedAdditionalID, advancedAdditionalClass } = attributes;
413
414 return (
415 <>
416 <InputControl
417 label={__("ID", "post-carousel")}
418 attributes={advancedAdditionalID}
419 attributesKey={"advancedAdditionalID"}
420 setAttributes={setAttributes}
421 inputType="text"
422 flex={false}
423 />
424 <InputControl
425 label={__("Additional CSS Class(ES)", "post-carousel")}
426 attributes={advancedAdditionalClass}
427 attributesKey={"advancedAdditionalClass"}
428 setAttributes={setAttributes}
429 placeholder={__("", "post-carousel")}
430 inputType="text"
431 flex={false}
432 />
433 </>
434 );
435 };
436