import { __ } from "@wordpress/i18n"; import { useEffect, useMemo, useState } from "@wordpress/element"; import { Background, InputControl, Layouts, SelectField, SPRangeControl } from "../../components"; import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; import useLayouts from "../../hooks/useLayouts"; import { AlignCenter, AlignLeft, AlignRight } from "../../icons/icons"; import Toggle from "../../components/toggle/toggle"; import { BgIcon, GradientIcon, TransparentIcon } from "../../components/background/svgIcon"; import { openLinksOptions } from "../../controls/constants"; import { useDeviceType } from "../../controls/controls"; import ProInfo from "../../components/proInfo/proInfo"; export const ThumbnailSliderTwoGeneralTab = ({ attributes, setAttributes }) => { const { blockName, thumbnailSliderTwoLayout, thumbnailTwoAlignment, thumbnailTwoPosition, thumbnailSliderTwoHeight, thumbnailTwoItemsHeight, thumbnailItemsToShow, catTabCategoryColor, titleMargin, contentAlignment, generalLinkOpen, thumbnailTwoGeneralPreloader, postLimit, } = attributes; const layouts = useLayouts(blockName, thumbnailSliderTwoLayout); const [thumbnailPositionItem, setThumbnailPositionItem] = useState([]); const [layoutName, setLayoutName] = useState("thumbnail-slider-layout-one"); const deviceType = useDeviceType(); const layoutDefault = useMemo( () => ({ "thumbnail-slider-two-layout-one": { thumbnailTwoPosition: "bottom", contentVerticalPosition: "top", contentHorizontalPosition: "center", thumbnailItemsToShow: { ...thumbnailItemsToShow, device: { ...thumbnailItemsToShow.device, [deviceType]: 3, }, }, postLimit: "3", thumbnailTwoItemsHeight: { ...thumbnailTwoItemsHeight, device: { ...thumbnailTwoItemsHeight.device, Desktop: 132 }, }, carouselNavArrow: false, catTabCategoryColor: { ...catTabCategoryColor, color: "#222222", }, titleMargin: { ...titleMargin, device: { ...titleMargin.device, Desktop: { ...titleMargin.device.Desktop, top: 6, bottom: 0, right: 0, left: 0, }, }, }, }, "thumbnail-slider-two-layout-two": { contentVerticalPosition: "top", contentHorizontalPosition: "center", thumbnailTwoPosition: "bottom", thumbnailItemsToShow: { ...thumbnailItemsToShow, device: { ...thumbnailItemsToShow.device, [deviceType]: 4, }, }, postLimit: "4", thumbnailTwoItemsHeight: { ...thumbnailTwoItemsHeight, device: { ...thumbnailTwoItemsHeight.device, Desktop: 60 }, }, carouselNavArrow: false, catTabCategoryColor: { ...catTabCategoryColor, color: "#222222", }, }, "thumbnail-slider-two-layout-three": { contentVerticalPosition: "bottom", contentHorizontalPosition: "left", thumbnailTwoPosition: "right", thumbnailItemsToShow: { ...thumbnailItemsToShow, device: { ...thumbnailItemsToShow.device, [deviceType]: 3, }, }, postLimit: "4", thumbnailTwoItemsHeight: { ...thumbnailTwoItemsHeight, device: { ...thumbnailTwoItemsHeight.device, Desktop: 220 }, }, carouselNavArrow: true, catTabCategoryColor: { ...catTabCategoryColor, color: "#fff", }, }, "thumbnail-slider-two-layout-four": { contentVerticalPosition: "bottom", contentHorizontalPosition: "left", thumbnailTwoPosition: "right", titleMargin: { ...titleMargin, device: { ...titleMargin.device, Desktop: { ...titleMargin.device.Desktop, top: 0, bottom: 0, right: 0, left: 0, }, }, }, thumbnailItemsToShow: { ...thumbnailItemsToShow, device: { ...thumbnailItemsToShow.device, [deviceType]: 4, }, }, postLimit: "4", thumbnailTwoItemsHeight: { ...thumbnailTwoItemsHeight, device: { ...thumbnailTwoItemsHeight.device, Desktop: 132 }, }, carouselNavArrow: true, catTabCategoryColor: { ...catTabCategoryColor, color: "#fff", }, }, "thumbnail-slider-two-layout-five": { contentVerticalPosition: "bottom", contentHorizontalPosition: "left", thumbnailTwoPosition: "right", carouselNavArrow: true, thumbnailItemsToShow: { ...thumbnailItemsToShow, device: { ...thumbnailItemsToShow.device, [deviceType]: 5, }, }, postLimit: "8", thumbnailTwoItemsHeight: { ...thumbnailTwoItemsHeight, device: { ...thumbnailTwoItemsHeight.device, Desktop: 132 }, }, catTabCategoryColor: { ...catTabCategoryColor, color: "#fff", }, }, }), [] ); const layoutsChangeHandler = (newValue) => { if (newValue === thumbnailSliderTwoLayout) return; const newData = { ...layoutDefault?.[newValue], thumbnailSliderTwoLayout: newValue, blockLayoutName: newValue, }; setAttributes(newData); setLayoutName(newValue); }; const configThumbPosition = useMemo( () => ({ "thumbnail-slider-two-layout-one": [], "thumbnail-slider-two-layout-two": [ { label: "Left", value: "left" }, { label: "Right", value: "right" }, { label: "Bottom", value: "bottom" }, ], "thumbnail-slider-two-layout-three": [ { label: "Left", value: "left" }, { label: "Right", value: "right" }, ], "thumbnail-slider-two-layout-four": [ { label: "Left", value: "left" }, { label: "Right", value: "right" }, ], "thumbnail-slider-two-layout-five": [], }), [] ); useEffect(() => { setThumbnailPositionItem(configThumbPosition[thumbnailSliderTwoLayout] || []); }, [thumbnailSliderTwoLayout]); useEffect(() => { if (["left", "right"].includes(thumbnailTwoPosition)) { const contentPosition = thumbnailTwoPosition === "left" ? "right" : "left"; setAttributes({ contentHorizontalPosition: contentPosition }); } }, [thumbnailTwoPosition]); return ( <> {layouts?.length > 0 && ( )} {/* */} {"thumbnail-slider-two-layout-one" === thumbnailSliderTwoLayout && ( , value: "left" }, { label: , value: "center" }, { label: , value: "right" }, ]} /> )} {!["thumbnail-slider-two-layout-one", "thumbnail-slider-two-layout-five"].includes( thumbnailSliderTwoLayout ) && ( )} {!["thumbnail-slider-two-layout-four", "thumbnail-slider-two-layout-five"].includes( thumbnailSliderTwoLayout ) && ( )} {!["thumbnail-slider-two-layout-one", "thumbnail-slider-two-layout-five"].includes( thumbnailSliderTwoLayout ) && ( )} , value: "left" }, { label: , value: "center" }, { label: , value: "right" }, ]} /> Unlock exclusive layouts and advanced display controls. Upgrade to Pro! ); }; export const ThumbnailTwoSliderTab = ({ attributes, setAttributes }) => { const { carouselAutoPlay, carouselAutoPlayDelay, carouselSpeed, carouselDirection, thumbnailTwoSlideToScroll, carouselPauseOnHover, thumbnailTwoAnimationEffect, thumbnailTwoAdaptiveHeight, infiniteLoop, thumbnailTwoTabKeyNavigation, thumbnailTwoMouseWheelControl, thumbnailTwoFreeScrollMode, // thumbnailTwoNavArrow, carouselNavArrow, } = attributes; return ( <> {carouselAutoPlay && ( )} {carouselAutoPlay && ( )} ); }; export const ThumbnailProgressBarTab = ({ attributes, setAttributes }) => { const [colorState, setColorState] = useState("normal"); const { thumbnailProgressPosition, thumbnailProgressBarWidth, thumbnailProgressThickness, thumbnailProgressColor } = attributes; return ( <> setColorState(newValue)} items={[ { label: "Normal", value: "normal" }, { label: "Active", value: "active" }, ]} /> {"normal" === colorState && ( , value: "transparent", tooltip: "Transparent", }, { label: , value: "bgColor", tooltip: "Solid", }, { label: , value: "gradient", tooltip: "Gradient", }, ]} /> )} {"active" === colorState && ( , value: "transparent", tooltip: "Transparent", }, { label: , value: "bgColor", tooltip: "Solid", }, { label: , value: "gradient", tooltip: "Gradient", }, ]} /> )} ); }; export const ThumbnailTwoGeneralTab = ({ attributes, setAttributes }) => { const { contentAlignment, generalLinkOpen, thumbnailTwoGeneralPreloader } = attributes; return ( <> , value: "left" }, { label: , value: "center" }, { label: , value: "right" }, ]} /> ); };