PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
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 / smart-lists / generalTab.js

generalTab.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/blocks/smart-lists/generalTab.js

1,312 lines 33.1 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 { __ } from "@wordpress/i18n";
3 import {
4 Layouts,
5 Background,
6 Border,
7 Spacing,
8 Toggle,
9 BoxShadow,
10 SPRangeControl,
11 SelectField,
12 SpColorPicker,
13 TypographyNew,
14 MediaPicker,
15 SpSVGIconPicker,
16 } from "../../components";
17 import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl";
18 import IconsLibrary from "../../components/iconLibrary/iconLibrary";
19 import { AlignCenter, AlignLeft, AlignRight, AlignTop, AlignMiddle, AlignBottom } from "../../icons/icons";
20
21 import { BgIcon, GradientIcon, Image } from "../../components/background/svgIcon";
22 import {
23 LayoutOne,
24 LayoutTwo,
25 LayoutFour,
26 LayoutFive,
27 BackgroundShapeCircle,
28 BackgroundShapeSquare,
29 BackgroundShapeHexagon,
30 BackgroundShapeDiamond,
31 BackgroundShapeStarburst,
32 } from "./icons";
33 import ProInfo from "../../components/proInfo/proInfo";
34
35 const RADIAL_SHAPES = [
36 { label: __("Circle", "post-carousel"), value: "circle" },
37 { label: __("Ellipse", "post-carousel"), value: "ellipse" },
38 ];
39
40 const RADIAL_POSITIONS = [
41 { label: __("Center Center", "post-carousel"), value: "center center" },
42 { label: __("Center Left", "post-carousel"), value: "center left" },
43 { label: __("Center Right", "post-carousel"), value: "center right" },
44 { label: __("Top Center", "post-carousel"), value: "top center" },
45 { label: __("Top Left", "post-carousel"), value: "top left" },
46 { label: __("Top Right", "post-carousel"), value: "top right" },
47 { label: __("Bottom Center", "post-carousel"), value: "bottom center" },
48 { label: __("Bottom Left", "post-carousel"), value: "bottom left" },
49 { label: __("Bottom Right", "post-carousel"), value: "bottom right" },
50 ];
51
52 const BACKGROUND_ITEMS = [
53 {
54 label: <BgIcon />,
55 value: "bgColor",
56 tooltip: __("Solid", "post-carousel"),
57 },
58 {
59 label: <GradientIcon />,
60 value: "gradient",
61 tooltip: __("Gradient", "post-carousel"),
62 },
63 ];
64
65 const DEFAULT_SPACING = {
66 unit: "px",
67 value: { top: "0", right: "0", bottom: "0", left: "0" },
68 };
69
70 export const SmartListsGeneralTab = ({ attributes, setAttributes }) => {
71 const {
72 smartListsLayout,
73 listOrientation,
74 listsAlignment,
75 spaceBetweenLists,
76 iconContentGap,
77 dividerEnable,
78 dividerStyle,
79 dividerWidth,
80 dividerColor,
81 listItemsWidth,
82 } = attributes;
83
84 // Default config for layouts
85 const layoutConfigs = {
86 "layout-one": {
87 dividerEnable: false,
88 descriptionEnable: false,
89 iconBackgroundEnable: false,
90 iconContentGap: {
91 ...iconContentGap,
92 device: { ...iconContentGap.device, Desktop: "10" },
93 },
94 spaceBetweenLists: {
95 ...spaceBetweenLists,
96 device: { ...spaceBetweenLists.device, Desktop: "24" },
97 },
98 listOrientation: "vertical",
99 iconPosition: 0,
100 },
101 "layout-two": {
102 dividerEnable: true,
103 descriptionEnable: true,
104 iconBackgroundEnable: true,
105 iconContentGap: {
106 ...iconContentGap,
107 device: { ...iconContentGap.device, Desktop: "10" },
108 },
109 spaceBetweenLists: {
110 ...spaceBetweenLists,
111 device: { ...spaceBetweenLists.device, Desktop: "24" },
112 },
113 listOrientation: "vertical",
114 iconPosition: 0,
115 },
116 "layout-three": {
117 dividerEnable: false,
118 descriptionEnable: true,
119 iconBackgroundEnable: true,
120 iconContentGap: {
121 ...iconContentGap,
122 device: { ...iconContentGap.device, Desktop: "10" },
123 },
124 spaceBetweenLists: {
125 ...spaceBetweenLists,
126 device: { ...spaceBetweenLists.device, Desktop: "24" },
127 },
128 listOrientation: "vertical",
129 iconPosition: 0,
130 },
131 "layout-four": {
132 dividerEnable: false,
133 descriptionEnable: true,
134 iconBackgroundEnable: true,
135 iconContentGap: {
136 ...iconContentGap,
137 device: { ...iconContentGap.device, Desktop: "10" },
138 },
139 spaceBetweenLists: {
140 ...spaceBetweenLists,
141 device: { ...spaceBetweenLists.device, Desktop: "12" },
142 },
143 listOrientation: "vertical",
144 iconPosition: 0,
145 },
146 "layout-five": {
147 dividerEnable: false,
148 descriptionEnable: true,
149 iconBackgroundEnable: true,
150 iconContentGap: {
151 ...iconContentGap,
152 device: { ...iconContentGap.device, Desktop: "18" },
153 },
154 listOrientation: "horizontal",
155 iconPosition: "top",
156 },
157 };
158
159 const layoutChange = (newValue) => {
160 if (newValue === smartListsLayout) {
161 return;
162 }
163 setAttributes({ smartListsLayout: newValue });
164
165 setAttributes({
166 smartListsLayout: newValue,
167 ...(layoutConfigs[newValue] || {}),
168 });
169 };
170
171 return (
172 <div className="sp-smart-post-lists-general">
173 <Layouts
174 attributes={smartListsLayout}
175 setAttributes={setAttributes}
176 attributesKey={"smartListsLayout"}
177 displayActive={true}
178 showDemoTitle={true}
179 grid={3}
180 onChange={layoutChange}
181 label={__("List Preset", "post-carousel")}
182 items={[
183 {
184 icon: <LayoutOne value={smartListsLayout} />,
185 value: "layout-one",
186 },
187 {
188 icon: <LayoutTwo value={smartListsLayout} />,
189 value: "layout-two",
190 type: "pro",
191 demoLink: "https://wpsmartpost.com/blocks/#demoId3592"
192 },
193
194 {
195 icon: <LayoutFour value={smartListsLayout} />,
196 value: "layout-four",
197 type: "pro",
198 demoLink: "https://wpsmartpost.com/blocks/#demoId3592"
199 },
200 {
201 icon: <LayoutFive value={smartListsLayout} />,
202 value: "layout-five",
203 type: "pro",
204 demoLink: "https://wpsmartpost.com/blocks/#demoId3592"
205 },
206 ]}
207 />
208
209 <div>
210 <div className="sp-smart-post-component-title">{__("List Orientation", "post-carousel")}</div>
211
212 <SPToggleGroupControl
213 attributes={listOrientation}
214 items={[
215 {
216 label: __("Horizontal", "post-carousel"),
217 value: "horizontal",
218 },
219 {
220 label: __("Vertical", "post-carousel"),
221 value: "vertical",
222 },
223 ]}
224 onClick={(val) => setAttributes({ listOrientation: val })}
225 />
226
227 <SPToggleGroupControl
228 label={__("Alignment", "post-carousel")}
229 attributes={listsAlignment}
230 attributesKey={"listsAlignment"}
231 setAttributes={setAttributes}
232 items={[
233 { label: <AlignLeft />, value: "start" },
234 { label: <AlignCenter />, value: "center" },
235 { label: <AlignRight />, value: "end" },
236 ]}
237 />
238
239 <SPRangeControl
240 label={__("Space Between Lists", "post-carousel")}
241 attributes={spaceBetweenLists}
242 attributesKey={"spaceBetweenLists"}
243 setAttributes={setAttributes}
244 units={["PX", "%", "EM"]}
245 defaultValue={{ unit: "px", value: 8 }}
246 max={100}
247 />
248
249 <SPRangeControl
250 label={__("Icon to Content Gap", "post-carousel")}
251 attributes={iconContentGap}
252 attributesKey={"iconContentGap"}
253 setAttributes={setAttributes}
254 units={["PX", "EM"]}
255 defaultValue={{ unit: "px", value: 10 }}
256 max={100}
257 />
258 <SPRangeControl
259 label={__("Items Width", "post-carousel")}
260 attributes={listItemsWidth}
261 attributesKey={"listItemsWidth"}
262 setAttributes={setAttributes}
263 units={["PX", "%", "EM"]}
264 defaultValue={{ unit: "px", value: "" }}
265 max={400}
266 pro={true}
267 />
268
269 <>
270 <Toggle
271 label={__("Divider", "post-carousel")}
272 attributes={dividerEnable}
273 attributesKey={"dividerEnable"}
274 setAttributes={setAttributes}
275 pro={true}
276 />
277
278 {dividerEnable && (
279 <>
280 <SelectField
281 label={__("Divider Style", "post-carousel")}
282 attributes={dividerStyle}
283 attributesKey={"dividerStyle"}
284 setAttributes={setAttributes}
285 items={[
286 {
287 label: __("Solid", "post-carousel"),
288 value: "solid",
289 },
290 {
291 label: __("Dotted", "post-carousel"),
292 value: "dotted",
293 },
294 {
295 label: __("Dashed", "post-carousel"),
296 value: "dashed",
297 },
298 {
299 label: __("Double Line", "post-carousel"),
300 value: "double",
301 },
302 ]}
303 />
304 <SPRangeControl
305 label={__("Divider Width", "post-carousel")}
306 attributes={dividerWidth}
307 attributesKey={"dividerWidth"}
308 setAttributes={setAttributes}
309 units={["px", "em"]}
310 defaultValue={{
311 unit: "px",
312 value: 1,
313 }}
314 max={20}
315 />
316 <SpColorPicker
317 label={__("Divider Color", "post-carousel")}
318 value={dividerColor}
319 onChange={(newColor) =>
320 setAttributes({
321 dividerColor: newColor,
322 })
323 }
324 defaultColor="#D9D9D9"
325 />
326 </>
327 )}
328 </>
329 </div>
330 <hr />
331 <ProInfo>
332 <span>Unlock exclusive layouts and advanced display controls.</span> <a href="https://wpsmartpost.com/pricing/?ref=1" target="_blank" rel="noopener noreferrer">Upgrade to Pro!</a>
333 </ProInfo>
334 </div>
335 );
336 };
337
338 export const SmartListsStyleTab = ({ attributes, setAttributes }) => {
339 const {
340 smartListsBg,
341 smartListsBgImage,
342 smartListsRadialShape,
343 smartListsRadialPosition,
344 smartListsBgImageScale,
345 bgImageOverlayEnable,
346 borderStyle,
347 borderStyleWidth,
348 borderRadius,
349 boxShadowEnable,
350 boxShadow,
351 smartListsHoverBgImage,
352 smartListsHoverRadialShape,
353 smartListsHoverRadialPosition,
354 smartListsBgHoverImageScale,
355 bgImageOverlayHoverEnable,
356 bgImageHoverOverlayOpacity,
357 borderHoverStyle,
358 borderHoverStyleWidth,
359 borderHoverRadius,
360 boxShadowHoverEnable,
361 boxShadowHover,
362 padding,
363 margin,
364 bgImageOverlayColor,
365 bgImageOverlayOpacity,
366 } = attributes;
367
368 const [smartListsStyleType, setSmartListsStyleType] = useState("color");
369
370 return (
371 <>
372 <SPToggleGroupControl
373 attributes={smartListsStyleType}
374 items={[
375 {
376 label: __("Normal", "post-carousel"),
377 value: "color",
378 },
379 {
380 label: __("Hover", "post-carousel"),
381 value: "hover",
382 },
383 ]}
384 onClick={(val) => setSmartListsStyleType(val)}
385 />
386
387 {smartListsStyleType === "color" && (
388 <>
389 <Background
390 label={__("Background Style", "post-carousel")}
391 colorLabel="Color"
392 defaultColor="transparent"
393 attributes={smartListsBg}
394 attributesKey={"smartListsBg"}
395 setAttributes={setAttributes}
396 colorType={smartListsStyleType}
397 enableImageSize={true}
398 items={[
399 {
400 label: <BgIcon />,
401 value: "bgColor",
402 tooltip: __("Solid", "post-carousel"),
403 },
404 {
405 label: <GradientIcon />,
406 value: "gradient",
407 tooltip: __("Gradient", "post-carousel"),
408 },
409 {
410 label: <Image />,
411 value: "image",
412 tooltip: __("Image", "post-carousel"),
413 },
414 ]}
415 imageObj={{
416 imageKey: "smartListsBgImage",
417 backgroundImage: smartListsBgImage,
418 }}
419 />
420
421 {smartListsBg[smartListsStyleType]?.style === "gradient" && (
422 <>
423 {/^radial-gradient/.test(smartListsBg[smartListsStyleType]?.gradient) && (
424 <>
425 <SelectField
426 attributes={smartListsRadialShape}
427 attributesKey={"smartListsRadialShape"}
428 setAttributes={setAttributes}
429 items={RADIAL_SHAPES}
430 />
431 <SelectField
432 attributes={smartListsRadialPosition}
433 attributesKey={"smartListsRadialPosition"}
434 setAttributes={setAttributes}
435 items={RADIAL_POSITIONS}
436 />
437 </>
438 )}
439 </>
440 )}
441
442 {smartListsBg[smartListsStyleType]?.style === "image" && (
443 <>
444 <SPToggleGroupControl
445 label={__("Image Scale", "post-carousel")}
446 attributes={smartListsBgImageScale}
447 attributesKey={"smartListsBgImageScale"}
448 setAttributes={setAttributes}
449 items={[
450 {
451 label: __("None", "post-carousel"),
452 value: "auto",
453 },
454 {
455 label: __("Cover", "post-carousel"),
456 value: "cover",
457 },
458 {
459 label: __("Contain", "post-carousel"),
460 value: "contain",
461 },
462 ]}
463 />
464
465 <Toggle
466 label={__("Overlay", "post-carousel")}
467 attributes={bgImageOverlayEnable}
468 attributesKey={"bgImageOverlayEnable"}
469 setAttributes={setAttributes}
470 />
471
472 {bgImageOverlayEnable && (
473 <>
474 <SpColorPicker
475 label={__("Overlay Color", "post-carousel")}
476 value={bgImageOverlayColor.color}
477 onChange={(newColor) =>
478 setAttributes({
479 bgImageOverlayColor: {
480 ...bgImageOverlayColor,
481 color: newColor,
482 },
483 })
484 }
485 defaultColor="#fff"
486 />
487
488 <SPRangeControl
489 label={__("Overlay Opacity", "post-carousel")}
490 attributes={bgImageOverlayOpacity}
491 attributesKey={"bgImageOverlayOpacity"}
492 setAttributes={setAttributes}
493 max={1}
494 step={0.1}
495 />
496 </>
497 )}
498 </>
499 )}
500 <Border
501 attributes={{
502 border: borderStyle,
503 borderWidth: borderStyleWidth,
504 }}
505 setAttributes={setAttributes}
506 attributesKey={{
507 border: "borderStyle",
508 borderWidth: "borderStyleWidth",
509 }}
510 btnType="normal"
511 />
512 <Spacing
513 label={__("Border Radius", "post-carousel")}
514 attributes={borderRadius}
515 attributesKey={"borderRadius"}
516 setAttributes={setAttributes}
517 units={["Px", "%", "em"]}
518 defaultValue={DEFAULT_SPACING}
519 indicator={"radius"}
520 />
521
522 <Toggle
523 label={__("Shadow", "post-carousel")}
524 attributes={boxShadowEnable}
525 attributesKey={"boxShadowEnable"}
526 setAttributes={setAttributes}
527 />
528 {boxShadowEnable && (
529 <BoxShadow
530 label={__("Shadow", "post-carousel")}
531 attributes={boxShadow}
532 attributesKey={"boxShadow"}
533 setAttributes={setAttributes}
534 />
535 )}
536 </>
537 )}
538 {smartListsStyleType === "hover" && (
539 <>
540 <Background
541 label={__("Background Type", "post-carousel")}
542 colorLabel="Solid Color"
543 defaultColor="#fff"
544 attributes={smartListsBg}
545 attributesKey={"smartListsBg"}
546 setAttributes={setAttributes}
547 colorType={smartListsStyleType}
548 enableImageSize={true}
549 items={[
550 {
551 label: <BgIcon />,
552 value: "bgColor",
553 tooltip: __("Solid", "post-carousel"),
554 },
555 {
556 label: <GradientIcon />,
557 value: "gradient",
558 tooltip: __("Gradient", "post-carousel"),
559 },
560 {
561 label: <Image />,
562 value: "image",
563 tooltip: __("Image", "post-carousel"),
564 },
565 ]}
566 imageObj={{
567 imageKey: "smartListsHoverBgImage",
568 backgroundImage: smartListsHoverBgImage,
569 }}
570 />
571
572 {smartListsBg[smartListsStyleType]?.style === "gradient" && (
573 <>
574 {/^radial-gradient/.test(smartListsBg[smartListsStyleType]?.gradient) && (
575 <>
576 <SelectField
577 attributes={smartListsHoverRadialShape}
578 attributesKey={"smartListsHoverRadialShape"}
579 setAttributes={setAttributes}
580 items={RADIAL_SHAPES}
581 />
582 <SelectField
583 attributes={smartListsHoverRadialPosition}
584 attributesKey={"smartListsHoverRadialPosition"}
585 setAttributes={setAttributes}
586 items={RADIAL_POSITIONS}
587 />
588 </>
589 )}
590 </>
591 )}
592
593 {smartListsBg[smartListsStyleType]?.style === "image" && (
594 <>
595 <SPToggleGroupControl
596 label={__("Image Scale", "post-carousel")}
597 attributes={smartListsBgHoverImageScale}
598 attributesKey={"smartListsBgHoverImageScale"}
599 setAttributes={setAttributes}
600 items={[
601 {
602 label: __("None", "post-carousel"),
603 value: "auto",
604 },
605 {
606 label: __("Cover", "post-carousel"),
607 value: "cover",
608 },
609 {
610 label: __("Contain", "post-carousel"),
611 value: "contain",
612 },
613 ]}
614 />
615 <Toggle
616 label={__("Overlay", "post-carousel")}
617 attributes={bgImageOverlayHoverEnable}
618 attributesKey={"bgImageOverlayHoverEnable"}
619 setAttributes={setAttributes}
620 />
621 {bgImageOverlayHoverEnable && (
622 <>
623 <SpColorPicker
624 label={__("Overlay Color", "post-carousel")}
625 value={bgImageOverlayColor.hoverColor}
626 onChange={(newColor) =>
627 setAttributes({
628 bgImageOverlayColor: {
629 ...bgImageOverlayColor,
630 hoverColor: newColor,
631 },
632 })
633 }
634 defaultColor="#fff"
635 />
636
637 <SPRangeControl
638 label={__("Overlay Opacity", "post-carousel")}
639 attributes={bgImageHoverOverlayOpacity}
640 attributesKey={"bgImageHoverOverlayOpacity"}
641 setAttributes={setAttributes}
642 max={1}
643 step={0.1}
644 />
645 </>
646 )}
647 </>
648 )}
649 <Border
650 attributes={{
651 border: borderHoverStyle,
652 borderWidth: borderHoverStyleWidth,
653 }}
654 setAttributes={setAttributes}
655 attributesKey={{
656 border: "borderHoverStyle",
657 borderWidth: "borderHoverStyleWidth",
658 }}
659 btnType="normal"
660 />
661 <Spacing
662 label={__("Border Radius", "post-carousel")}
663 attributes={borderHoverRadius}
664 attributesKey={"borderHoverRadius"}
665 setAttributes={setAttributes}
666 units={["Px", "%", "em"]}
667 defaultValue={DEFAULT_SPACING}
668 indicator={"radius"}
669 />
670 <Toggle
671 label={__("Shadow", "post-carousel")}
672 attributes={boxShadowHoverEnable}
673 attributesKey={"boxShadowHoverEnable"}
674 setAttributes={setAttributes}
675 />
676 {boxShadowHoverEnable && (
677 <BoxShadow
678 label={__("Shadow", "post-carousel")}
679 attributes={boxShadowHover}
680 attributesKey={"boxShadowHover"}
681 setAttributes={setAttributes}
682 />
683 )}
684 </>
685 )}
686 <Spacing
687 label={__("Padding", "post-carousel")}
688 attributes={padding}
689 attributesKey={"padding"}
690 setAttributes={setAttributes}
691 units={["Px", "%", "em"]}
692 defaultValue={DEFAULT_SPACING}
693 />
694 <Spacing
695 label={__("Margin", "post-carousel")}
696 attributes={margin}
697 attributesKey={"margin"}
698 setAttributes={setAttributes}
699 units={["Px", "%", "em"]}
700 defaultValue={DEFAULT_SPACING}
701 />
702 </>
703 );
704 };
705
706 export const IconImageGeneralTab = ({ attributes, setAttributes }) => {
707 const {
708 iconEnable,
709 iconSource,
710 svgIconName,
711 iconName,
712 iconSize,
713 iconSourceCustom,
714 iconCustomWidth,
715 iconCustomHeight,
716 iconPosition,
717 smartListsLayout,
718 iconAlignment,
719 } = attributes;
720
721 const iconAlignmentItems =
722 iconPosition === "top"
723 ? [
724 { label: <AlignLeft />, value: "start" },
725 { label: <AlignCenter />, value: "center" },
726 { label: <AlignRight />, value: "end" },
727 ]
728 : [
729 { label: <AlignTop />, value: "start" },
730 { label: <AlignMiddle />, value: "center" },
731 { label: <AlignBottom />, value: "end" },
732 ];
733
734 return (
735 <>
736 <Toggle
737 label={__("Icon", "post-carousel")}
738 attributes={iconEnable}
739 attributesKey={"iconEnable"}
740 setAttributes={setAttributes}
741 />
742 {iconEnable && (
743 <>
744 <SPToggleGroupControl
745 label={__("Icon Source", "post-carousel")}
746 attributes={iconSource}
747 attributesKey={"iconSource"}
748 setAttributes={setAttributes}
749 items={[
750 {
751 label: __("Icon Set", "post-carousel"),
752 value: "iconSet",
753 },
754 {
755 label: __("Library", "post-carousel"),
756 value: "library",
757 disabled: true
758 },
759 {
760 label: __("Custom", "post-carousel"),
761 value: "custom",
762 disabled: true
763 },
764 ]}
765 />
766
767 {["iconSet", "library"].includes(iconSource) && (
768 <>
769 {"iconSet" === iconSource && (
770 <>
771 <SpSVGIconPicker
772 attributes={svgIconName}
773 attributesKey={"svgIconName"}
774 setAttributes={setAttributes}
775 />
776 </>
777 )}
778
779 {"library" === iconSource && (
780 <IconsLibrary
781 attributes={iconName}
782 attributesKey={"iconName"}
783 setAttributes={setAttributes}
784 />
785 )}
786 <SPRangeControl
787 label={__("Icon Size", "post-carousel")}
788 attributes={iconSize}
789 attributesKey={"iconSize"}
790 setAttributes={setAttributes}
791 units={["px", "%", "em"]}
792 defaultValue={{ unit: "px", value: 24 }}
793 max={100}
794 min={2}
795 />
796 </>
797 )}
798
799 {iconSource === "custom" && (
800 <>
801 <MediaPicker
802 label={__("", "post-carousel")}
803 imageKey="iconSourceCustom"
804 enableImageSize={false}
805 setAttributes={setAttributes}
806 backgroundImage={iconSourceCustom}
807 />
808
809 <SPRangeControl
810 label={__("Width", "post-carousel")}
811 attributes={iconCustomWidth}
812 attributesKey={"iconCustomWidth"}
813 setAttributes={setAttributes}
814 units={["px", "%", "em"]}
815 defaultValue={{ unit: "px", value: 24 }}
816 max={100}
817 min={12}
818 />
819
820 <SPRangeControl
821 label={__("Height", "post-carousel")}
822 attributes={iconCustomHeight}
823 attributesKey={"iconCustomHeight"}
824 setAttributes={setAttributes}
825 units={["px", "%", "em"]}
826 defaultValue={{ unit: "px", value: 24 }}
827 max={100}
828 min={12}
829 />
830 </>
831 )}
832 {smartListsLayout !== "layout-five" && (
833 <SelectField
834 label={__("Icon Position", "post-carousel")}
835 attributes={iconPosition}
836 attributesKey={"iconPosition"}
837 setAttributes={setAttributes}
838 items={[
839 {
840 label: __("Before", "post-carousel"),
841 value: "0",
842 },
843 {
844 label: __("After", "post-carousel"),
845 value: "1",
846 },
847 {
848 label: __("Top (Pro)", "post-carousel"),
849 value: "top",
850 disabled: true
851 },
852 ]}
853 />
854 )}
855
856 <SPToggleGroupControl
857 label={__("Alignment", "post-carousel")}
858 attributes={iconAlignment}
859 attributesKey={"iconAlignment"}
860 setAttributes={setAttributes}
861 items={iconAlignmentItems}
862 />
863 </>
864 )}
865 </>
866 );
867 };
868 export const IconImageStyleTab = ({ attributes, setAttributes }) => {
869 const {
870 iconEnable,
871 iconBackgroundEnable,
872 backgroundShape,
873 iconColor,
874 iconBg,
875 iconBgRadialShape,
876 iconBgRadialPosition,
877 iconBorderStyle,
878 iconBorderStyleWidth,
879 iconBorderRadius,
880 iconBgHoverRadialShape,
881 iconBgHoverRadialPosition,
882 iconHoverBorderStyle,
883 iconHoverBorderStyleWidth,
884 iconHoverBorderRadius,
885 iconPadding,
886 } = attributes;
887 const [iconStyleState, setIconStyleState] = useState("color");
888
889 return (
890 <>
891 {iconEnable && (
892 <>
893 <Toggle
894 label={__("Icon Background", "post-carousel")}
895 attributes={iconBackgroundEnable}
896 attributesKey={"iconBackgroundEnable"}
897 setAttributes={setAttributes}
898 />
899 {iconBackgroundEnable && (
900 <>
901 <div className="sp-smart-post-component-title">
902 {__("Choose Background Shape", "post-carousel")}
903 </div>
904 <SPToggleGroupControl
905 attributes={backgroundShape}
906 items={[
907 {
908 label: <BackgroundShapeSquare value={backgroundShape} />,
909 value: "backgroundShapeSquare",
910 },
911 {
912 label: <BackgroundShapeCircle value={backgroundShape} />,
913 value: "backgroundShapeCircle",
914 },
915 {
916 label: <BackgroundShapeHexagon value={backgroundShape} />,
917 value: "backgroundShapeHexagon",
918 },
919 {
920 label: <BackgroundShapeDiamond value={backgroundShape} />,
921 value: "backgroundShapeDiamond",
922 },
923 {
924 label: <BackgroundShapeStarburst value={backgroundShape} />,
925 value: "backgroundShapeStarburst",
926 },
927 ]}
928 onClick={(val) => setAttributes({ backgroundShape: val })}
929 />
930 </>
931 )}
932
933 <SPToggleGroupControl
934 attributes={iconStyleState}
935 items={[
936 {
937 label: __("Normal", "post-carousel"),
938 value: "color",
939 },
940 {
941 label: __("Hover", "post-carousel"),
942 value: "hover",
943 },
944 ]}
945 onClick={(val) => setIconStyleState(val)}
946 />
947
948 {iconStyleState === "color" && (
949 <>
950 <SpColorPicker
951 label={__("Icon Color", "post-carousel")}
952 value={iconColor.color}
953 onChange={(newColor) =>
954 setAttributes({
955 iconColor: {
956 ...iconColor,
957 color: newColor,
958 },
959 })
960 }
961 defaultColor="#757575"
962 />
963 {iconBackgroundEnable && (
964 <>
965 <Background
966 label={__("Icon Background Style", "post-carousel")}
967 colorLabel="Icon Background Color"
968 defaultColor="#dddddd"
969 attributes={iconBg}
970 attributesKey={"iconBg"}
971 setAttributes={setAttributes}
972 colorType={iconStyleState}
973 enableImageSize={true}
974 items={BACKGROUND_ITEMS}
975 />
976
977 {iconBg[iconStyleState]?.style === "gradient" && (
978 <>
979 {/^radial-gradient/.test(iconBg[iconStyleState]?.gradient) && (
980 <>
981 <SelectField
982 attributes={iconBgRadialShape}
983 attributesKey={"iconBgRadialShape"}
984 setAttributes={setAttributes}
985 items={RADIAL_SHAPES}
986 />
987 <SelectField
988 attributes={iconBgRadialPosition}
989 attributesKey={"iconBgRadialPosition"}
990 setAttributes={setAttributes}
991 items={RADIAL_POSITIONS}
992 />
993 </>
994 )}
995 </>
996 )}
997 </>
998 )}
999
1000 <Border
1001 attributes={{
1002 border: iconBorderStyle,
1003 borderWidth: iconBorderStyleWidth,
1004 }}
1005 setAttributes={setAttributes}
1006 attributesKey={{
1007 border: "iconBorderStyle",
1008 borderWidth: "iconBorderStyleWidth",
1009 }}
1010 btnType="normal"
1011 />
1012
1013 <Spacing
1014 label={__("Border Radius", "post-carousel")}
1015 attributes={iconBorderRadius}
1016 attributesKey={"iconBorderRadius"}
1017 setAttributes={setAttributes}
1018 units={["Px", "%", "em"]}
1019 defaultValue={DEFAULT_SPACING}
1020 indicator={"radius"}
1021 />
1022 </>
1023 )}
1024 {iconStyleState === "hover" && (
1025 <>
1026 <SpColorPicker
1027 label={__("Icon Color", "post-carousel")}
1028 value={iconColor.hoverColor}
1029 onChange={(newColor) =>
1030 setAttributes({
1031 iconColor: {
1032 ...iconColor,
1033 hoverColor: newColor,
1034 },
1035 })
1036 }
1037 defaultColor="#757575"
1038 />
1039 {iconBackgroundEnable && (
1040 <>
1041 <Background
1042 label={__("Icon Background Style", "post-carousel")}
1043 colorLabel="Icon Background Color"
1044 defaultColor="#E9F4FF"
1045 attributes={iconBg}
1046 attributesKey={"iconBg"}
1047 setAttributes={setAttributes}
1048 colorType={iconStyleState}
1049 enableImageSize={true}
1050 items={BACKGROUND_ITEMS}
1051 />
1052
1053 {iconBg[iconStyleState]?.style === "gradient" && (
1054 <>
1055 {/^radial-gradient/.test(iconBg[iconStyleState]?.gradient) && (
1056 <>
1057 <SelectField
1058 attributes={iconBgHoverRadialShape}
1059 attributesKey={"iconBgHoverRadialShape"}
1060 setAttributes={setAttributes}
1061 items={RADIAL_SHAPES}
1062 />
1063 <SelectField
1064 attributes={iconBgHoverRadialPosition}
1065 attributesKey={"iconBgHoverRadialPosition"}
1066 setAttributes={setAttributes}
1067 items={RADIAL_POSITIONS}
1068 />
1069 </>
1070 )}
1071 </>
1072 )}
1073 </>
1074 )}
1075
1076 <Border
1077 attributes={{
1078 border: iconHoverBorderStyle,
1079 borderWidth: iconHoverBorderStyleWidth,
1080 }}
1081 setAttributes={setAttributes}
1082 attributesKey={{
1083 border: "iconHoverBorderStyle",
1084 borderWidth: "iconHoverBorderStyleWidth",
1085 }}
1086 btnType="normal"
1087 />
1088
1089 {iconBackgroundEnable && backgroundShape === "backgroundShapeSquare" && (
1090 <Spacing
1091 label={__("Border Radius", "post-carousel")}
1092 attributes={iconHoverBorderRadius}
1093 attributesKey={"iconHoverBorderRadius"}
1094 setAttributes={setAttributes}
1095 units={["Px", "%", "em"]}
1096 defaultValue={DEFAULT_SPACING}
1097 indicator={"radius"}
1098 />
1099 )}
1100 </>
1101 )}
1102
1103 <Spacing
1104 label={__("Padding", "post-carousel")}
1105 attributes={iconPadding}
1106 attributesKey={"iconPadding"}
1107 setAttributes={setAttributes}
1108 units={["Px", "em"]}
1109 defaultValue={DEFAULT_SPACING}
1110 />
1111 </>
1112 )}
1113 </>
1114 );
1115 };
1116 export const ContentGeneralTab = ({ attributes, setAttributes }) => {
1117 const { listTitleEnable, descriptionEnable, titleDescriptionGap, contentAlignment } = attributes;
1118
1119 return (
1120 <>
1121 <Toggle
1122 label={__("List Title", "post-carousel")}
1123 attributes={listTitleEnable}
1124 attributesKey={"listTitleEnable"}
1125 setAttributes={setAttributes}
1126 />
1127
1128 <Toggle
1129 label={__("Description", "post-carousel")}
1130 attributes={descriptionEnable}
1131 attributesKey={"descriptionEnable"}
1132 setAttributes={setAttributes}
1133 pro={true}
1134 />
1135 {listTitleEnable && descriptionEnable && (
1136 <>
1137 <SPRangeControl
1138 label={__("Title to Description Gap", "post-carousel")}
1139 attributes={titleDescriptionGap}
1140 attributesKey={"titleDescriptionGap"}
1141 setAttributes={setAttributes}
1142 units={["px", "em"]}
1143 defaultValue={{ unit: "px", value: 6 }}
1144 max={100}
1145 />
1146 </>
1147 )}
1148 <SPToggleGroupControl
1149 label={__("Alignment", "post-carousel")}
1150 attributes={contentAlignment}
1151 attributesKey={"contentAlignment"}
1152 setAttributes={setAttributes}
1153 items={[
1154 { label: <AlignLeft />, value: "left" },
1155 { label: <AlignCenter />, value: "center" },
1156 { label: <AlignRight />, value: "right" },
1157 ]}
1158 />
1159 </>
1160 );
1161 };
1162 export const ContentStyleTab = ({ attributes, setAttributes }) => {
1163 const {
1164 titleTypography,
1165 titleFontSize,
1166 titleLatterSpacing,
1167 titleLineHeight,
1168 titleWordSpacing,
1169 descriptionEnable,
1170 descriptionTypography,
1171 descriptionFontSize,
1172 descriptionLatterSpacing,
1173 descriptionLineHeight,
1174 descriptionWordSpacing,
1175 titleColor,
1176 descriptionColor,
1177 } = attributes;
1178
1179 const [contentStyleType, setContentStyleType] = useState("color");
1180
1181 return (
1182 <>
1183 <TypographyNew
1184 attributes={{
1185 family: titleTypography,
1186 familyKey: "titleTypography",
1187 fontSize: titleFontSize,
1188 fontSizeKey: "titleFontSize",
1189 fontSpacing: titleLatterSpacing,
1190 fontSpacingKey: "titleLatterSpacing",
1191 lineHeight: titleLineHeight,
1192 lineHeightKey: "titleLineHeight",
1193 wordSpacing: titleWordSpacing,
1194 wordSpacingKey: "titleWordSpacing",
1195 }}
1196 setAttributes={setAttributes}
1197 spacingDefaultValue={{ unit: "px", value: 0 }}
1198 fontSizeDefault={{
1199 unit: "px",
1200 value: 16,
1201 }}
1202 lineDefaultValue={{ unit: "px", value: 16 }}
1203 typographyLabel={__("Title Typography", "post-carousel")}
1204 />
1205 {descriptionEnable && (
1206 <TypographyNew
1207 attributes={{
1208 family: descriptionTypography,
1209 familyKey: "descriptionTypography",
1210 fontSize: descriptionFontSize,
1211 fontSizeKey: "descriptionFontSize",
1212 fontSpacing: descriptionLatterSpacing,
1213 fontSpacingKey: "descriptionLatterSpacing",
1214 lineHeight: descriptionLineHeight,
1215 lineHeightKey: "descriptionLineHeight",
1216 wordSpacing: descriptionWordSpacing,
1217 wordSpacingKey: "descriptionWordSpacing",
1218 }}
1219 setAttributes={setAttributes}
1220 spacingDefaultValue={{ unit: "px", value: 0 }}
1221 fontSizeDefault={{
1222 unit: "px",
1223 value: 14,
1224 }}
1225 lineDefaultValue={{ unit: "px", value: 27.5 }}
1226 typographyLabel={__("Description Typography", "post-carousel")}
1227 />
1228 )}
1229
1230 <SPToggleGroupControl
1231 attributes={contentStyleType}
1232 items={[
1233 {
1234 label: __("Normal", "post-carousel"),
1235 value: "color",
1236 },
1237 {
1238 label: __("Hover", "post-carousel"),
1239 value: "hover",
1240 },
1241 ]}
1242 onClick={(val) => setContentStyleType(val)}
1243 />
1244
1245 {contentStyleType === "color" && (
1246 <>
1247 <SpColorPicker
1248 label={__("Title Color", "post-carousel")}
1249 value={titleColor.color}
1250 onChange={(newColor) =>
1251 setAttributes({
1252 titleColor: {
1253 ...titleColor,
1254 color: newColor,
1255 },
1256 })
1257 }
1258 defaultColor="#2F2F2F"
1259 />
1260 {descriptionEnable && (
1261 <SpColorPicker
1262 label={__("Description Color", "post-carousel")}
1263 value={descriptionColor.color}
1264 onChange={(newColor) =>
1265 setAttributes({
1266 descriptionColor: {
1267 ...descriptionColor,
1268 color: newColor,
1269 },
1270 })
1271 }
1272 defaultColor="#757575"
1273 />
1274 )}
1275 </>
1276 )}
1277 {contentStyleType === "hover" && (
1278 <>
1279 <SpColorPicker
1280 label={__("Title Color", "post-carousel")}
1281 value={titleColor.hoverColor}
1282 onChange={(newColor) =>
1283 setAttributes({
1284 titleColor: {
1285 ...titleColor,
1286 hoverColor: newColor,
1287 },
1288 })
1289 }
1290 defaultColor="#2F2F2F"
1291 />
1292 {descriptionEnable && (
1293 <SpColorPicker
1294 label={__("Description Color", "post-carousel")}
1295 value={descriptionColor.hoverColor}
1296 onChange={(newColor) =>
1297 setAttributes({
1298 descriptionColor: {
1299 ...descriptionColor,
1300 hoverColor: newColor,
1301 },
1302 })
1303 }
1304 defaultColor="#757575"
1305 />
1306 )}
1307 </>
1308 )}
1309 </>
1310 );
1311 };
1312