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 / taxonomy / Content.js

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

524 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useState } from "@wordpress/element";
2 import {
3 Background,
4 BoxShadow,
5 Divider,
6 SelectField,
7 Spacing,
8 SpColorPicker,
9 SPToggleGroupControl,
10 } from "../../components";
11 import { __, _n } from "@wordpress/i18n";
12 import { BgIcon, GradientIcon, TransparentIcon } from "../../components/background/svgIcon";
13 import Border from "../../components/border/border";
14 import Toggle from "../../components/toggle/toggle";
15
16 export const Content = ({ attributes, setAttributes }) => {
17 const {
18 contentVerticalPosition,
19 contentHorizontalPosition,
20 blockName,
21 postCardBg,
22 postCardBorder,
23 postCardHoverBorder,
24 postCardBorderWidth,
25 postCardBorderRadius,
26 postCardBoxShadowEnable,
27 postCardBoxShadow,
28 postCardPadding,
29 postCardHoverBorderWidth,
30 postCardHoverBorderRadius,
31 postCardHoverBoxShadowEnable,
32 postCardHoverBoxShadow,
33 contentAreaMargin,
34 blockLayoutName,
35 hoverAnimation,
36 layout,
37 displayOverlyThum,
38 displayOverlyHoverThum,
39 imageOverlayColor,
40 imageOverlayCustomColor,
41 imageOverlayHoverColor,
42 imageOverlayCustomHoverColor,
43 contentMultiColorBg,
44 contentAreaBg,
45 catRadius,
46 showHideDivider,
47 } = attributes;
48
49 const [contentAreaBgStyleType, setContentAreaBgStyleType] = useState("color");
50
51 return (
52 <>
53 {!["taxonomy-layout-five", "taxonomy-layout-six", "taxonomy-layout-one"].includes(layout) && (
54 <SelectField
55 label={__("Hover Animation", "post-carousel")}
56 attributes={hoverAnimation}
57 attributesKey={"hoverAnimation"}
58 setAttributes={setAttributes}
59 flexStyle={false}
60 items={[
61 { label: "Zoom In", value: "zoomIn" },
62 { label: "Zoom Out", value: "zoomOut" },
63 { label: "Slide Left", value: "slideLeft" },
64 { label: "Slide Right", value: "slideRight" },
65 ]}
66 defaultOption="No Animation"
67 />
68 )}
69
70 {[
71 "taxonomy-layout-four",
72 "taxonomy-layout-seven",
73 "taxonomy-layout-eight",
74 "taxonomy-layout-five",
75 "taxonomy-layout-six",
76 ].includes(layout) && (
77 <>
78 <SPToggleGroupControl
79 label={__("Horizontal Position", "post-carousel")}
80 attributes={contentHorizontalPosition}
81 attributesKey="contentHorizontalPosition"
82 setAttributes={setAttributes}
83 items={
84 [
85 "post-slider-layout-five",
86 "post-slider-two-layout-three",
87 "thumbnail-slider-layout-six",
88 ].includes(blockLayoutName)
89 ? [
90 { label: "Left", value: "left" },
91 { label: "Right", value: "right" },
92 ]
93 : [
94 { label: "Left", value: "left" },
95 { label: "Center", value: "center" },
96 { label: "Right", value: "right" },
97 ]
98 }
99 />
100 </>
101 )}
102
103 {["taxonomy-layout-seven"].includes(layout) && (
104 <>
105 <SPToggleGroupControl
106 label={__("Vertical Position", "post-carousel")}
107 attributes={contentVerticalPosition}
108 attributesKey="contentVerticalPosition"
109 setAttributes={setAttributes}
110 items={[
111 { label: "Top", value: "start" },
112 { label: "Center", value: "center" },
113 { label: "Bottom", value: "end" },
114 ]}
115 />
116 </>
117 )}
118
119 <SPToggleGroupControl
120 attributes={contentAreaBgStyleType}
121 items={
122 "thumbnail-slider-two" !== blockName
123 ? [
124 { label: "Normal", value: "color" },
125 { label: "Hover", value: "hover" },
126 ]
127 : [
128 { label: "Normal", value: "color" },
129 { label: "Hover & Active", value: "hover" },
130 ]
131 }
132 onClick={(val) => setContentAreaBgStyleType(val)}
133 />
134
135 {layout !== "taxonomy-layout-five" &&
136 layout !== "taxonomy-layout-six" &&
137 layout !== "taxonomy-layout-one" && (
138 <>
139 {contentAreaBgStyleType === "color" ? (
140 <>
141 {"taxonomy-layout-eight" === layout && (
142 <Toggle
143 label={__("Multi-Color Background", "post-carousel")}
144 attributes={contentMultiColorBg}
145 attributesKey={"contentMultiColorBg"}
146 setAttributes={setAttributes}
147 />
148 )}
149
150 {!["taxonomy-layout-four", "taxonomy-layout-seven", "taxonomy-layout-eight"].includes(
151 layout
152 ) && (
153 <Toggle
154 label={__("Display Category Thumb", "post-carousel")}
155 attributes={displayOverlyThum}
156 attributesKey={"displayOverlyThum"}
157 setAttributes={setAttributes}
158 />
159 )}
160
161 {displayOverlyThum && (
162 <>
163 <SelectField
164 label={__("Overlay Color", "post-carousel")}
165 attributes={imageOverlayColor}
166 attributesKey={"imageOverlayColor"}
167 setAttributes={setAttributes}
168 items={[
169 {
170 label: "No Overlay",
171 value: "no-overlay",
172 },
173 {
174 label: "Multi Color - Solid",
175 value: "multi-solid",
176 },
177 {
178 label: "Multi Color - Gradient",
179 value: "multi-gradient",
180 },
181 {
182 label: "Warm Sunset",
183 value: "warm-sunset",
184 },
185 {
186 label: "Ocean Breeze",
187 value: "ocean-breeze",
188 },
189 {
190 label: "Royal Gold",
191 value: "royal-gold",
192 },
193 {
194 label: "Cool Blues",
195 value: "cool-blues",
196 },
197 {
198 label: "Soft Pastel",
199 value: "soft-pastel",
200 },
201 {
202 label: "Elegant Purple",
203 value: "elegant-purple",
204 },
205 {
206 label: "Energetic Orange",
207 value: "energetic-orange",
208 },
209 {
210 label: "Custom",
211 value: "custom",
212 },
213 ]}
214 />
215 {"custom" === imageOverlayColor && (
216 <SpColorPicker
217 label={__("Color", "post-carousel")}
218 value={imageOverlayCustomColor}
219 onChange={(newColor) =>
220 setAttributes({
221 imageOverlayCustomColor: newColor,
222 })
223 }
224 defaultColor="#eecacaff"
225 />
226 )}
227 </>
228 )}
229 </>
230 ) : (
231 <>
232 {!["taxonomy-layout-four", "taxonomy-layout-seven", "taxonomy-layout-eight"].includes(
233 layout
234 ) && (
235 <Toggle
236 label={__("Display Category Thumb", "post-carousel")}
237 attributes={displayOverlyHoverThum}
238 attributesKey={"displayOverlyHoverThum"}
239 setAttributes={setAttributes}
240 />
241 )}
242
243 {displayOverlyHoverThum && (
244 <>
245 <SelectField
246 label={__("Overlay Color", "post-carousel")}
247 attributes={imageOverlayHoverColor}
248 attributesKey={"imageOverlayHoverColor"}
249 setAttributes={setAttributes}
250 items={[
251 {
252 label: "No Overlay",
253 value: "no-overlay",
254 },
255 {
256 label: "Multi Color - Solid",
257 value: "multi-solid",
258 },
259 {
260 label: "Multi Color - Gradient",
261 value: "multi-gradient",
262 },
263 {
264 label: "Warm Sunset",
265 value: "warm-sunset",
266 },
267 {
268 label: "Ocean Breeze",
269 value: "ocean-breeze",
270 },
271 {
272 label: "Royal Gold",
273 value: "royal-gold",
274 },
275 {
276 label: "Cool Blues",
277 value: "cool-blues",
278 },
279 {
280 label: "Soft Pastel",
281 value: "soft-pastel",
282 },
283 {
284 label: "Elegant Purple",
285 value: "elegant-purple",
286 },
287 {
288 label: "Energetic Orange",
289 value: "energetic-orange",
290 },
291 {
292 label: "Custom",
293 value: "custom",
294 },
295 ]}
296 />
297 {"custom" === imageOverlayHoverColor && (
298 <SpColorPicker
299 label={__("Color", "post-carousel")}
300 value={imageOverlayCustomHoverColor}
301 onChange={(newColor) =>
302 setAttributes({
303 imageOverlayCustomHoverColor: newColor,
304 })
305 }
306 defaultColor="#eecacaff"
307 />
308 )}
309 </>
310 )}
311 </>
312 )}
313 </>
314 )}
315
316 {(layout === "taxonomy-layout-five" ||
317 (layout === "taxonomy-layout-eight" && !contentMultiColorBg) ||
318 layout === "taxonomy-layout-four" ||
319 layout === "taxonomy-layout-six" ||
320 (!displayOverlyThum && contentAreaBgStyleType === "color") ||
321 (contentAreaBgStyleType === "hover" && !displayOverlyHoverThum)) && (
322 <Background
323 label={__("Background Type", "post-carousel")}
324 colorLabel="Solid Color"
325 defaultColor="#fff"
326 attributes={
327 ["taxonomy-layout-eight", "taxonomy-layout-four"].includes(layout) ? contentAreaBg : postCardBg
328 }
329 attributesKey={
330 ["taxonomy-layout-eight", "taxonomy-layout-four"].includes(layout)
331 ? "contentAreaBg"
332 : "postCardBg"
333 }
334 setAttributes={setAttributes}
335 colorType={contentAreaBgStyleType}
336 items={[
337 {
338 label: <TransparentIcon />,
339 value: "transparent",
340 tooltip: "Transparent",
341 },
342 {
343 label: <BgIcon />,
344 value: "bgColor",
345 tooltip: "Solid",
346 },
347 {
348 label: <GradientIcon />,
349 value: "gradient",
350 tooltip: "Gradient",
351 },
352 ]}
353 />
354 )}
355
356 {contentAreaBgStyleType === "color" ? (
357 <>
358 {(layout !== "taxonomy-layout-one" || !showHideDivider) && (
359 <>
360 <Border
361 attributes={{
362 border: postCardBorder,
363 borderWidth: postCardBorderWidth,
364 }}
365 attributesKey={{
366 border: "postCardBorder",
367 borderWidth: "postCardBorderWidth",
368 }}
369 setAttributes={setAttributes}
370 btnType="normal"
371 />
372
373 <Spacing
374 label={__("Border Radius", "post-carousel")}
375 attributes={postCardBorderRadius}
376 attributesKey={"postCardBorderRadius"}
377 setAttributes={setAttributes}
378 units={["Px", "%", "em"]}
379 defaultValue={{
380 unit: "px",
381 value: {
382 top: "0",
383 right: "0",
384 bottom: "0",
385 left: "0",
386 },
387 }}
388 indicator={"radius"}
389 />
390 </>
391 )}
392
393 <Toggle
394 label={__("Box Shadow", "post-carousel")}
395 attributes={postCardBoxShadowEnable}
396 attributesKey={"postCardBoxShadowEnable"}
397 setAttributes={setAttributes}
398 />
399
400 {postCardBoxShadowEnable && (
401 <BoxShadow
402 label={__("Box Shadow", "post-carousel")}
403 attributes={postCardBoxShadow}
404 attributesKey={"postCardBoxShadow"}
405 setAttributes={setAttributes}
406 />
407 )}
408 </>
409 ) : (
410 <>
411 {(layout !== "taxonomy-layout-one" || !showHideDivider) && (
412 <>
413 <Border
414 attributes={{
415 border: postCardHoverBorder,
416 borderWidth: postCardHoverBorderWidth,
417 }}
418 attributesKey={{
419 border: "postCardHoverBorder",
420 borderWidth: "postCardHoverBorderWidth",
421 }}
422 setAttributes={setAttributes}
423 btnType="normal"
424 />
425
426 <Spacing
427 label={__("Border Radius", "post-carousel")}
428 attributes={postCardHoverBorderRadius}
429 attributesKey={"postCardHoverBorderRadius"}
430 setAttributes={setAttributes}
431 units={["Px", "%", "em"]}
432 defaultValue={{
433 unit: "px",
434 value: {
435 top: "8",
436 right: "8",
437 bottom: "8",
438 left: "8",
439 },
440 }}
441 indicator={"radius"}
442 />
443 </>
444 )}
445
446 <Toggle
447 label={__("Box Shadow", "post-carousel")}
448 attributes={postCardHoverBoxShadowEnable}
449 attributesKey={"postCardHoverBoxShadowEnable"}
450 setAttributes={setAttributes}
451 />
452
453 {postCardHoverBoxShadowEnable && (
454 <BoxShadow
455 label={__("Box Shadow", "post-carousel")}
456 attributes={postCardHoverBoxShadow}
457 attributesKey={"postCardHoverBoxShadow"}
458 setAttributes={setAttributes}
459 />
460 )}
461 </>
462 )}
463
464 <Divider position={"sp-w-100pct bottom"} />
465
466 {["taxonomy-layout-four", "taxonomy-layout-eight"].includes(layout) && (
467 <Spacing
468 label={__("Cat Border Radius", "post-carousel")}
469 attributes={catRadius}
470 attributesKey={"catRadius"}
471 setAttributes={setAttributes}
472 units={["Px", "%", "em"]}
473 defaultValue={{
474 unit: "px",
475 value: {
476 top: "8",
477 right: "8",
478 bottom: "8",
479 left: "8",
480 },
481 }}
482 indicator={"radius"}
483 />
484 )}
485 {layout !== "taxonomy-layout-three" && (
486 <Spacing
487 label={__("Padding", "post-carousel")}
488 attributes={postCardPadding}
489 attributesKey={"postCardPadding"}
490 setAttributes={setAttributes}
491 units={["px", "%", "em"]}
492 defaultValue={{
493 unit: "px",
494 value: {
495 top: "0",
496 right: "0",
497 bottom: "0",
498 left: "0",
499 },
500 }}
501 />
502 )}
503 {layout !== "taxonomy-layout-six" && (
504 <Spacing
505 label={__("Margin", "post-carousel")}
506 attributes={contentAreaMargin}
507 attributesKey={"contentAreaMargin"}
508 setAttributes={setAttributes}
509 units={["px", "%", "em"]}
510 defaultValue={{
511 unit: "px",
512 value: {
513 top: "0",
514 right: "0",
515 bottom: "0",
516 left: "0",
517 },
518 }}
519 />
520 )}
521 </>
522 );
523 };
524