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-list / 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-list/generalTab.js

1,018 lines 25.3 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 { useState } from "@wordpress/element";
3 import { ensureHttps } from "../shared/helpFn";
4 import {
5 Background,
6 Border,
7 Spacing,
8 Toggle,
9 BoxShadow,
10 SPRangeControl,
11 SelectField,
12 SpColorPicker,
13 TypographyNew,
14 InputControl,
15 MediaPicker,
16 SpSVGIconPicker,
17 } from "../../components";
18 import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl";
19 import { AlignCenter, AlignLeft, AlignRight, AlignTop, AlignMiddle, AlignBottom } from "../../icons/icons";
20 import {
21 BackgroundShapeCircle,
22 BackgroundShapeSquare,
23 BackgroundShapeHexagon,
24 BackgroundShapeDiamond,
25 BackgroundShapeStarburst,
26 } from "./icons";
27 import { BgIcon, GradientIcon } from "../../components/background/svgIcon";
28 import IconsLibrary from "../../components/iconLibrary/iconLibrary";
29 import ProInfo from "../../components/proInfo/proInfo";
30
31 const RADIAL_SHAPES = [
32 { label: __("Circle", "post-carousel"), value: "circle" },
33 { label: __("Ellipse", "post-carousel"), value: "ellipse" },
34 ];
35
36 const RADIAL_POSITIONS = [
37 { label: __("Center Center", "post-carousel"), value: "center center" },
38 { label: __("Center Left", "post-carousel"), value: "center left" },
39 { label: __("Center Right", "post-carousel"), value: "center right" },
40 { label: __("Top Center", "post-carousel"), value: "top center" },
41 { label: __("Top Left", "post-carousel"), value: "top left" },
42 { label: __("Top Right", "post-carousel"), value: "top right" },
43 { label: __("Bottom Center", "post-carousel"), value: "bottom center" },
44 { label: __("Bottom Left", "post-carousel"), value: "bottom left" },
45 { label: __("Bottom Right", "post-carousel"), value: "bottom right" },
46 ];
47
48 const BACKGROUND_ITEMS = [
49 {
50 label: <BgIcon />,
51 value: "bgColor",
52 tooltip: __("Solid", "post-carousel"),
53 },
54 {
55 label: <GradientIcon />,
56 value: "gradient",
57 tooltip: __("Gradient", "post-carousel"),
58 },
59 ];
60
61 const DEFAULT_SPACING = {
62 unit: "px",
63 value: { top: "0", right: "0", bottom: "0", left: "0" },
64 };
65
66 export const SmartListGeneralTab = ({ attributes, setAttributes }) => {
67 const {
68 linkURL,
69 openInNewTab,
70 noFollowLink,
71 // listItemWidth
72 } = attributes;
73
74 const handleLinkURL = (newLink) => {
75 const link = ensureHttps(newLink);
76 setAttributes({ linkURL: link });
77 };
78
79 return (
80 <>
81 <InputControl
82 label={__("Link URL", "post-carousel")}
83 attributes={linkURL}
84 flex={false}
85 inputType="text"
86 attributesKey={"linkURL"}
87 onChange={handleLinkURL}
88 setAttributes={setAttributes}
89 placeholder={__("#", "post-carousel")}
90 pro={true}
91 />
92
93 <Toggle
94 label={__("Open In a New Tab", "post-carousel")}
95 attributes={openInNewTab}
96 attributesKey={"openInNewTab"}
97 setAttributes={setAttributes}
98 pro={true}
99 />
100
101 <Toggle
102 label={__("Add “No Follow” to the Link", "post-carousel")}
103 attributes={noFollowLink}
104 attributesKey={"noFollowLink"}
105 setAttributes={setAttributes}
106 pro={true}
107 />
108 {/* <SPRangeControl
109 label={__("Width", "post-carousel")}
110 attributes={listItemWidth}
111 attributesKey={"listItemWidth"}
112 setAttributes={setAttributes}
113 units={["px", "%", "em"]}
114 defaultValue={{ unit: "px", value: "" }}
115 max={600}
116 min={0}
117 /> */}
118 </>
119 );
120 };
121
122 export const SmartListStyleTab = ({ attributes, setAttributes }) => {
123 const {
124 smartListBg,
125 borderStyle,
126 borderStyleWidth,
127 borderRadius,
128 boxShadowEnable,
129 listBoxShadow,
130 borderHoverStyle,
131 borderHoverStyleWidth,
132 borderHoverRadius,
133 boxShadowHoverEnable,
134 boxShadowHover,
135 padding,
136 } = attributes;
137
138 const [smartListStyleType, setSmartListStyleType] = useState("color");
139
140 return (
141 <>
142 <SPToggleGroupControl
143 attributes={smartListStyleType}
144 items={[
145 {
146 label: __("Normal", "post-carousel"),
147 value: "color",
148 },
149 { label: __("Hover", "post-carousel"), value: "hover" },
150 ]}
151 onClick={(val) => setSmartListStyleType(val)}
152 />
153
154 {smartListStyleType === "color" && (
155 <>
156 <Background
157 label={__("Background Type", "post-carousel")}
158 colorLabel="Solid Color"
159 defaultColor="#fff"
160 attributes={smartListBg}
161 attributesKey={"smartListBg"}
162 setAttributes={setAttributes}
163 colorType={smartListStyleType}
164 pro={true}
165 items={[
166 {
167 label: <BgIcon />,
168 value: "bgColor",
169 tooltip: "Solid",
170 },
171 {
172 label: <GradientIcon />,
173 value: "gradient",
174 tooltip: "Gradient",
175 },
176 ]}
177 />
178
179 <Border
180 attributes={{
181 border: borderStyle,
182 borderWidth: borderStyleWidth,
183 }}
184 setAttributes={setAttributes}
185 attributesKey={{
186 border: "borderStyle",
187 borderWidth: "borderStyleWidth",
188 }}
189 btnType="normal"
190 />
191
192 <Spacing
193 label={__("Border Radius", "post-carousel")}
194 attributes={borderRadius}
195 attributesKey={"borderRadius"}
196 setAttributes={setAttributes}
197 units={["Px", "%", "em"]}
198 defaultValue={DEFAULT_SPACING}
199 indicator={"radius"}
200 />
201 <Toggle
202 label={__("Shadow", "post-carousel")}
203 attributes={boxShadowEnable}
204 attributesKey={"boxShadowEnable"}
205 setAttributes={setAttributes}
206 />
207 {boxShadowEnable && (
208 <BoxShadow
209 label={__("Shadow", "post-carousel")}
210 attributes={listBoxShadow}
211 attributesKey={"listBoxShadow"}
212 setAttributes={setAttributes}
213 />
214 )}
215 </>
216 )}
217 {smartListStyleType === "hover" && (
218 <>
219 <Background
220 label={__("Background Type", "post-carousel")}
221 colorLabel="Solid Color"
222 defaultColor="transparent"
223 attributes={smartListBg}
224 attributesKey={"smartListBg"}
225 setAttributes={setAttributes}
226 colorType={smartListStyleType}
227 items={[
228 {
229 label: <BgIcon />,
230 value: "bgColor",
231 tooltip: "Solid",
232 },
233 {
234 label: <GradientIcon />,
235 value: "gradient",
236 tooltip: "Gradient",
237 },
238 ]}
239 // items={ BACKGROUND_ITEMS }
240 />
241
242 <Border
243 attributes={{
244 border: borderHoverStyle,
245 borderWidth: borderHoverStyleWidth,
246 }}
247 setAttributes={setAttributes}
248 attributesKey={{
249 border: "borderHoverStyle",
250 borderWidth: "borderHoverStyleWidth",
251 }}
252 btnType="normal"
253 />
254 <Spacing
255 label={__("Border Radius", "post-carousel")}
256 attributes={borderHoverRadius}
257 attributesKey={"borderHoverRadius"}
258 setAttributes={setAttributes}
259 units={["Px", "%", "em"]}
260 defaultValue={DEFAULT_SPACING}
261 indicator={"radius"}
262 />
263 <Toggle
264 label={__("Shadow", "post-carousel")}
265 attributes={boxShadowHoverEnable}
266 attributesKey={"boxShadowHoverEnable"}
267 setAttributes={setAttributes}
268 />
269 {boxShadowHoverEnable && (
270 <BoxShadow
271 label={__("Shadow", "post-carousel")}
272 attributes={boxShadowHover}
273 attributesKey={"boxShadowHover"}
274 setAttributes={setAttributes}
275 />
276 )}
277 </>
278 )}
279
280 <Spacing
281 label={__("Padding", "post-carousel")}
282 attributes={padding}
283 attributesKey={"padding"}
284 setAttributes={setAttributes}
285 units={["Px", "%", "em"]}
286 defaultValue={DEFAULT_SPACING}
287 />
288 </>
289 );
290 };
291
292 export const IconImageGeneralTab = ({ attributes, setAttributes }) => {
293 const {
294 iconEnable,
295 iconSource,
296 svgIconName,
297 iconName,
298 iconSize,
299 iconSourceCustom,
300 iconCustomWidth,
301 iconCustomHeight,
302 iconPosition,
303 iconEnableParent,
304 parentListsLayout,
305 iconAlignment,
306 } = attributes;
307
308 const iconAlignmentItems =
309 iconPosition === "top"
310 ? [
311 { label: <AlignLeft />, value: "start" },
312 { label: <AlignCenter />, value: "center" },
313 { label: <AlignRight />, value: "end" },
314 ]
315 : [
316 { label: <AlignTop />, value: "start" },
317 { label: <AlignMiddle />, value: "center" },
318 { label: <AlignBottom />, value: "end" },
319 ];
320
321 return (
322 <>
323 <Toggle
324 label={__("Icon", "post-carousel")}
325 attributes={iconEnable ?? iconEnableParent}
326 attributesKey={"iconEnable"}
327 setAttributes={setAttributes}
328 />
329 {(iconEnable ?? iconEnableParent) && (
330 <>
331 <SPToggleGroupControl
332 label={__("Icon Source", "post-carousel")}
333 attributes={iconSource}
334 attributesKey={"iconSource"}
335 setAttributes={setAttributes}
336 items={[
337 {
338 label: __("Icon Set", "post-carousel"),
339 value: "iconSet",
340 },
341 {
342 label: __("Library", "post-carousel"),
343 value: "library",
344 disabled: true,
345 },
346 {
347 label: __("Custom", "post-carousel"),
348 value: "custom",
349 disabled: true,
350 },
351 ]}
352 />
353
354 {["iconSet", "library"].includes(iconSource) && (
355 <>
356 {"iconSet" === iconSource && (
357 <>
358 <SpSVGIconPicker
359 label={__("Icon Sources", "post-carousel")}
360 attributes={svgIconName}
361 attributesKey={"svgIconName"}
362 setAttributes={setAttributes}
363 />
364 </>
365 )}
366
367 {"library" === iconSource && (
368 <IconsLibrary
369 attributes={iconName}
370 attributesKey={"iconName"}
371 setAttributes={setAttributes}
372 />
373 )}
374 <SPRangeControl
375 label={__("Icon Size", "post-carousel")}
376 attributes={iconSize}
377 attributesKey={"iconSize"}
378 setAttributes={setAttributes}
379 units={["px", "%", "em"]}
380 defaultValue={{ unit: "px", value: 24 }}
381 max={100}
382 min={9}
383 />
384 </>
385 )}
386
387 {iconSource === "custom" && (
388 <>
389 <MediaPicker
390 label={__("Icon/Image Source", "post-carousel")}
391 imageKey="iconSourceCustom"
392 enableImageSize={false}
393 setAttributes={setAttributes}
394 backgroundImage={iconSourceCustom}
395 />
396
397 <SPRangeControl
398 label={__("Width", "post-carousel")}
399 attributes={iconCustomWidth}
400 attributesKey={"iconCustomWidth"}
401 setAttributes={setAttributes}
402 units={["px", "%", "em"]}
403 defaultValue={{ unit: "px", value: 24 }}
404 />
405
406 <SPRangeControl
407 label={__("Height", "post-carousel")}
408 attributes={iconCustomHeight}
409 attributesKey={"iconCustomHeight"}
410 setAttributes={setAttributes}
411 units={["px", "%", "em"]}
412 defaultValue={{ unit: "px", value: 24 }}
413 />
414 </>
415 )}
416
417 {parentListsLayout !== "layout-five" && (
418 <SelectField
419 label={__("Icon Position", "post-carousel")}
420 attributes={iconPosition}
421 attributesKey={"iconPosition"}
422 setAttributes={setAttributes}
423 items={[
424 {
425 label: __("Select Position", "post-carousel"),
426 },
427 {
428 label: __("Before", "post-carousel"),
429 value: "0",
430 },
431 {
432 label: __("After", "post-carousel"),
433 value: "1",
434 },
435 {
436 label: __("Top", "post-carousel"),
437 value: "top",
438 },
439 ]}
440 />
441 )}
442
443 <SPToggleGroupControl
444 label={__("Alignment", "post-carousel")}
445 attributes={iconAlignment}
446 attributesKey={"iconAlignment"}
447 setAttributes={setAttributes}
448 items={iconAlignmentItems}
449 />
450 </>
451 )}
452 </>
453 );
454 };
455
456 export const IconImageStyleTab = ({ attributes, setAttributes }) => {
457 const {
458 iconEnable,
459 iconEnableParent,
460 iconBackgroundEnable,
461 backgroundShape,
462 iconColor,
463 iconBg,
464 iconBgRadialShape,
465 iconBgRadialPosition,
466 iconBorderStyle,
467 iconBorderStyleWidth,
468 iconBorderRadius,
469 iconBgHoverRadialShape,
470 iconBgHoverRadialPosition,
471 iconHoverBorderStyle,
472 iconHoverBorderStyleWidth,
473 iconHoverBorderRadius,
474 iconPadding,
475 } = attributes;
476
477 const [iconStyleState, setIconStyleState] = useState("color");
478
479 return (
480 <>
481 {(iconEnable ?? iconEnableParent) && (
482 <>
483 <Toggle
484 label={__("Icon Background", "post-carousel")}
485 attributes={iconBackgroundEnable}
486 attributesKey={"iconBackgroundEnable"}
487 setAttributes={setAttributes}
488 />
489 {iconBackgroundEnable && (
490 <>
491 <div className="sp-smart-post-component-title">
492 {__("Choose Background Shape", "post-carousel")}
493 </div>
494 <SPToggleGroupControl
495 attributes={backgroundShape}
496 items={[
497 {
498 label: <BackgroundShapeSquare value={backgroundShape} />,
499 value: "backgroundShapeSquare",
500 },
501 {
502 label: <BackgroundShapeCircle value={backgroundShape} />,
503 value: "backgroundShapeCircle",
504 },
505 {
506 label: <BackgroundShapeHexagon value={backgroundShape} />,
507 value: "backgroundShapeHexagon",
508 },
509 {
510 label: <BackgroundShapeDiamond value={backgroundShape} />,
511 value: "backgroundShapeDiamond",
512 },
513 {
514 label: <BackgroundShapeStarburst value={backgroundShape} />,
515 value: "backgroundShapeStarburst",
516 },
517 ]}
518 onClick={(val) => setAttributes({ backgroundShape: val })}
519 />
520 </>
521 )}
522
523 <SPToggleGroupControl
524 attributes={iconStyleState}
525 items={[
526 {
527 label: __("Normal", "post-carousel"),
528 value: "color",
529 },
530 {
531 label: __("Hover", "post-carousel"),
532 value: "hover",
533 },
534 ]}
535 onClick={(val) => setIconStyleState(val)}
536 />
537
538 {iconStyleState === "color" && (
539 <>
540 <SpColorPicker
541 label={__("Icon Color", "post-carousel")}
542 value={iconColor.color}
543 onChange={(newColor) =>
544 setAttributes({
545 iconColor: {
546 ...iconColor,
547 color: newColor,
548 },
549 })
550 }
551 defaultColor="#757575"
552 />
553 {iconBackgroundEnable && (
554 <>
555 <Background
556 label={__("Icon Background Style", "post-carousel")}
557 colorLabel="Icon Background Color"
558 defaultColor="#E9F4FF"
559 attributes={iconBg}
560 attributesKey={"iconBg"}
561 setAttributes={setAttributes}
562 colorType={iconStyleState}
563 enableImageSize={true}
564 items={BACKGROUND_ITEMS}
565 />
566
567 {iconBg[iconStyleState]?.style === "gradient" && (
568 <>
569 {/^radial-gradient/.test(iconBg[iconStyleState]?.gradient) && (
570 <>
571 <SelectField
572 attributes={iconBgRadialShape}
573 attributesKey={"iconBgRadialShape"}
574 setAttributes={setAttributes}
575 items={RADIAL_SHAPES}
576 />
577 <SelectField
578 attributes={iconBgRadialPosition}
579 attributesKey={"iconBgRadialPosition"}
580 setAttributes={setAttributes}
581 items={RADIAL_POSITIONS}
582 />
583 </>
584 )}
585 </>
586 )}
587 </>
588 )}
589
590 <Border
591 attributes={{
592 border: iconBorderStyle,
593 borderWidth: iconBorderStyleWidth,
594 }}
595 setAttributes={setAttributes}
596 attributesKey={{
597 border: "iconBorderStyle",
598 borderWidth: "iconBorderStyleWidth",
599 }}
600 btnType="normal"
601 />
602 {backgroundShape === "backgroundShapeSquare" && (
603 <Spacing
604 label={__("Border Radius", "post-carousel")}
605 attributes={iconBorderRadius}
606 attributesKey={"iconBorderRadius"}
607 setAttributes={setAttributes}
608 units={["Px", "%", "em"]}
609 defaultValue={DEFAULT_SPACING}
610 indicator={"radius"}
611 />
612 )}
613 </>
614 )}
615
616 {iconStyleState === "hover" && (
617 <>
618 <SpColorPicker
619 label={__("Icon Color", "post-carousel")}
620 value={iconColor.hoverColor}
621 onChange={(newColor) =>
622 setAttributes({
623 iconColor: {
624 ...iconColor,
625 hoverColor: newColor,
626 },
627 })
628 }
629 defaultColor="#757575"
630 />
631 {iconBackgroundEnable && (
632 <>
633 <Background
634 label={__("Icon Background Style", "post-carousel")}
635 colorLabel="Icon Background Color"
636 defaultColor="#E9F4FF"
637 attributes={iconBg}
638 attributesKey={"iconBg"}
639 setAttributes={setAttributes}
640 colorType={iconStyleState}
641 enableImageSize={true}
642 items={BACKGROUND_ITEMS}
643 />
644
645 {iconBg[iconStyleState]?.style === "gradient" && (
646 <>
647 {/^radial-gradient/.test(iconBg[iconStyleState]?.gradient) && (
648 <>
649 <SelectField
650 attributes={iconBgHoverRadialShape}
651 attributesKey={"iconBgHoverRadialShape"}
652 setAttributes={setAttributes}
653 items={RADIAL_SHAPES}
654 />
655 <SelectField
656 attributes={iconBgHoverRadialPosition}
657 attributesKey={"iconBgHoverRadialPosition"}
658 setAttributes={setAttributes}
659 items={RADIAL_POSITIONS}
660 />
661 </>
662 )}
663 </>
664 )}
665 </>
666 )}
667
668 <Border
669 attributes={{
670 border: iconHoverBorderStyle,
671 borderWidth: iconHoverBorderStyleWidth,
672 }}
673 setAttributes={setAttributes}
674 attributesKey={{
675 border: "iconHoverBorderStyle",
676 borderWidth: "iconHoverBorderStyleWidth",
677 }}
678 btnType="normal"
679 />
680 {backgroundShape === "backgroundShapeSquare" && (
681 <Spacing
682 label={__("Border Radius", "post-carousel")}
683 attributes={iconHoverBorderRadius}
684 attributesKey={"iconHoverBorderRadius"}
685 setAttributes={setAttributes}
686 units={["Px", "%", "em"]}
687 defaultValue={DEFAULT_SPACING}
688 indicator={"radius"}
689 />
690 )}
691 </>
692 )}
693
694 <Spacing
695 label={__("Padding", "post-carousel")}
696 attributes={iconPadding}
697 attributesKey={"iconPadding"}
698 setAttributes={setAttributes}
699 units={["Px", "em"]}
700 defaultValue={DEFAULT_SPACING}
701 />
702 </>
703 )}
704 </>
705 );
706 };
707
708 export const ContentGeneralTab = ({ attributes, setAttributes }) => {
709 const { listTitleEnable, descriptionEnable, titleDescriptionGap } = attributes;
710
711 return (
712 <>
713 <Toggle
714 label={__("List Title", "post-carousel")}
715 attributes={listTitleEnable}
716 attributesKey={"listTitleEnable"}
717 setAttributes={setAttributes}
718 />
719
720 <Toggle
721 label={__("Description", "post-carousel")}
722 attributes={descriptionEnable}
723 attributesKey={"descriptionEnable"}
724 setAttributes={setAttributes}
725 pro={true}
726 />
727
728 {listTitleEnable && descriptionEnable && (
729 <SPRangeControl
730 label={__("Title to Description Gap", "post-carousel")}
731 attributes={titleDescriptionGap}
732 attributesKey={"titleDescriptionGap"}
733 setAttributes={setAttributes}
734 units={["px", "em"]}
735 defaultValue={{ unit: "px", value: "" }}
736 max={100}
737 />
738 )}
739 </>
740 );
741 };
742
743 export const ContentStyleTab = ({ attributes, setAttributes }) => {
744 const {
745 titleTypography,
746 titleFontSize,
747 titleLatterSpacing,
748 titleLineHeight,
749 titleWordSpacing,
750 descriptionTypography,
751 descriptionFontSize,
752 descriptionLatterSpacing,
753 descriptionLineHeight,
754 descriptionWordSpacing,
755 titleColor,
756 descriptionColor,
757 descriptionEnable,
758 } = attributes;
759
760 const [contentStyleType, setContentStyleType] = useState("color");
761
762 return (
763 <>
764 <TypographyNew
765 attributes={{
766 family: titleTypography,
767 familyKey: "titleTypography",
768 fontSize: titleFontSize,
769 fontSizeKey: "titleFontSize",
770 fontSpacing: titleLatterSpacing,
771 fontSpacingKey: "titleLatterSpacing",
772 lineHeight: titleLineHeight,
773 lineHeightKey: "titleLineHeight",
774 wordSpacing: titleWordSpacing,
775 wordSpacingKey: "titleWordSpacing",
776 }}
777 setAttributes={setAttributes}
778 spacingDefaultValue={{ unit: "px", value: 0 }}
779 fontSizeDefault={{
780 unit: "px",
781 value: 20,
782 }}
783 lineDefaultValue={{ unit: "px", value: 27.5 }}
784 typographyLabel={__("Title Typography", "post-carousel")}
785 />
786 {descriptionEnable && (
787 <TypographyNew
788 attributes={{
789 family: descriptionTypography,
790 familyKey: "descriptionTypography",
791 fontSize: descriptionFontSize,
792 fontSizeKey: "descriptionFontSize",
793 fontSpacing: descriptionLatterSpacing,
794 fontSpacingKey: "descriptionLatterSpacing",
795 lineHeight: descriptionLineHeight,
796 lineHeightKey: "descriptionLineHeight",
797 wordSpacing: descriptionWordSpacing,
798 wordSpacingKey: "descriptionWordSpacing",
799 }}
800 setAttributes={setAttributes}
801 spacingDefaultValue={{ unit: "px", value: 0 }}
802 fontSizeDefault={{
803 unit: "px",
804 value: 14,
805 }}
806 lineDefaultValue={{ unit: "px", value: 27.5 }}
807 typographyLabel={__("Description Typography", "post-carousel")}
808 />
809 )}
810
811 <SPToggleGroupControl
812 attributes={contentStyleType}
813 items={[
814 {
815 label: __("Normal", "post-carousel"),
816 value: "color",
817 },
818 { label: __("Hover", "post-carousel"), value: "hover" },
819 ]}
820 onClick={(val) => setContentStyleType(val)}
821 />
822
823 {contentStyleType === "color" && (
824 <>
825 <SpColorPicker
826 label={__("Title Color", "post-carousel")}
827 value={titleColor.color}
828 onChange={(newColor) =>
829 setAttributes({
830 titleColor: {
831 ...titleColor,
832 color: newColor,
833 },
834 })
835 }
836 defaultColor="#2F2F2F"
837 />
838 {descriptionEnable && (
839 <SpColorPicker
840 label={__("Description Color", "post-carousel")}
841 value={descriptionColor.color}
842 onChange={(newColor) =>
843 setAttributes({
844 descriptionColor: {
845 ...descriptionColor,
846 color: newColor,
847 },
848 })
849 }
850 defaultColor="#757575"
851 />
852 )}
853 </>
854 )}
855 {contentStyleType === "hover" && (
856 <>
857 <SpColorPicker
858 label={__("Title Color", "post-carousel")}
859 value={titleColor.hoverColor}
860 onChange={(newColor) =>
861 setAttributes({
862 titleColor: {
863 ...titleColor,
864 hoverColor: newColor,
865 },
866 })
867 }
868 defaultColor="#2F2F2F"
869 />
870 {descriptionEnable && (
871 <SpColorPicker
872 label={__("Description Color", "post-carousel")}
873 value={descriptionColor.hoverColor}
874 onChange={(newColor) =>
875 setAttributes({
876 descriptionColor: {
877 ...descriptionColor,
878 hoverColor: newColor,
879 },
880 })
881 }
882 defaultColor="#757575"
883 />
884 )}
885 </>
886 )}
887 </>
888 );
889 };
890
891 export const BadgeGeneralTab = ({ attributes, setAttributes }) => {
892 const { badgeEnable, badgeLabel } = attributes;
893
894 return (
895 <>
896 <Toggle
897 label={__("Badge", "post-carousel")}
898 attributes={badgeEnable}
899 attributesKey={"badgeEnable"}
900 setAttributes={setAttributes}
901 pro={true}
902 />
903 {badgeEnable && (
904 <InputControl
905 label={__("Badge Label", "post-carousel")}
906 attributes={badgeLabel}
907 flex={false}
908 inputType="text"
909 attributesKey={"badgeLabel"}
910 setAttributes={setAttributes}
911 placeholder={__("HOT", "post-carousel")}
912 />
913 )}
914 </>
915 );
916 };
917
918 export const BadgeStyleTab = ({ attributes, setAttributes }) => {
919 const {
920 badgeTypography,
921 badgeFontSize,
922 badgeLatterSpacing,
923 badgeLineHeight,
924 badgeWordSpacing,
925 badgeColor,
926 badgeBgColor,
927 badgeBorderStyle,
928 badgeBorderStyleWidth,
929 badgeBorderRadius,
930 badgePadding,
931 badgeMargin,
932 badgeEnable,
933 } = attributes;
934
935 return (
936 <>
937 {badgeEnable && (
938 <>
939 <TypographyNew
940 attributes={{
941 family: badgeTypography,
942 familyKey: "badgeTypography",
943 fontSize: badgeFontSize,
944 fontSizeKey: "badgeFontSize",
945 fontSpacing: badgeLatterSpacing,
946 fontSpacingKey: "badgeLatterSpacing",
947 lineHeight: badgeLineHeight,
948 lineHeightKey: "badgeLineHeight",
949 wordSpacing: badgeWordSpacing,
950 wordSpacingKey: "badgeWordSpacing",
951 }}
952 setAttributes={setAttributes}
953 spacingDefaultValue={{ unit: "px", value: 0 }}
954 fontSizeDefault={{
955 unit: "px",
956 value: 20,
957 }}
958 lineDefaultValue={{ unit: "px", value: 27.5 }}
959 typographyLabel={__("Typography", "post-carousel")}
960 />
961
962 <SpColorPicker
963 label={__("Text Color", "post-carousel")}
964 value={badgeColor}
965 onChange={(newColor) => setAttributes({ badgeColor: newColor })}
966 defaultColor="#0255A7"
967 />
968 <SpColorPicker
969 label={__("Background Color", "post-carousel")}
970 value={badgeBgColor}
971 onChange={(newColor) => setAttributes({ badgeBgColor: newColor })}
972 defaultColor="#DFECFF"
973 />
974
975 <Border
976 attributes={{
977 border: badgeBorderStyle,
978 borderWidth: badgeBorderStyleWidth,
979 }}
980 setAttributes={setAttributes}
981 attributesKey={{
982 border: "badgeBorderStyle",
983 borderWidth: "badgeBorderStyleWidth",
984 }}
985 btnType="normal"
986 />
987 <Spacing
988 label={__("Border Radius", "post-carousel")}
989 attributes={badgeBorderRadius}
990 attributesKey={"badgeBorderRadius"}
991 setAttributes={setAttributes}
992 units={["Px", "%", "em"]}
993 defaultValue={DEFAULT_SPACING}
994 indicator={"radius"}
995 />
996
997 <Spacing
998 label={__("Padding", "post-carousel")}
999 attributes={badgePadding}
1000 attributesKey={"badgePadding"}
1001 setAttributes={setAttributes}
1002 units={["Px", "em"]}
1003 defaultValue={DEFAULT_SPACING}
1004 />
1005 <Spacing
1006 label={__("Margin", "post-carousel")}
1007 attributes={badgeMargin}
1008 attributesKey={"badgeMargin"}
1009 setAttributes={setAttributes}
1010 units={["Px", "em"]}
1011 defaultValue={DEFAULT_SPACING}
1012 />
1013 </>
1014 )}
1015 </>
1016 );
1017 };
1018