import { __ } from "@wordpress/i18n"; import MediaPicker from "../../components/mediaUpload/image"; import SPFocalPointPicker from "../../components/focalPoint/focalPointPicker"; import { Background, Border, ButtonSet, Divider, InputControl, SelectField, Spacing, SpColorPicker, SPRangeControl, SPToggleGroupControl, Toggle, TypographyNew, } from "../../components"; import { hoverEffectItems, hoverEffectShortItems, shapeButtonSet } from "./constant"; import { useState } from "@wordpress/element"; import ToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; import { solidGradientBgType } from "../../controls/constants"; import { AlignCenter, AlignLeft, AlignRight, FlexAlignCenter, FlexAlignEnd, FlexAlignStart } from "./icon"; // Smart Image general tab panel export const SmartImageGeneralTab = ({ attributes, setAttributes }) => { const { selectImage, imageSize, selectImageSizes, aspectRatio, maxWidth, imageFocalPoint, enableLink, linkType, linkUrl, buttonLabel, buttonPosition, imageAltText, smartImageWidth, smartImageHeight, imgMaskingEnable, imageShapeSet, selectImageShape, maskingShapedUpload, maskSize, // imageZoom, openInTab, // doubleResolutionRetina, lazyLoad, // selectImageId, imgAlignment, } = attributes; const defaultSizes = [ { label: "Thumbnail", value: "thumbnail" }, { label: "Medium", value: "medium" }, { label: "Large", value: "large" }, { label: "Full", value: "full" }, ]; const imageSizeItems = selectImageSizes ? selectImageSizes : defaultSizes; return ( <> setAttributes({ selectImageId: media?.id })} removeImage={() => setAttributes({ selectImageId: "", imageAltText: "", imgTitleLabel: "", imgCaptionLabel: "", selectImage: {}, }) } /> {imgMaskingEnable && ( <> {"shape-set" === imageShapeSet && ( )} {"custom" === imageShapeSet && ( <> )} )} {"custom" === aspectRatio ? ( <> ) : ( )} {/* TODO : Next Version */} {/* */} {"original" !== aspectRatio && ( )} {enableLink && ( <> {"button" === linkType && ( )} {"button" === linkType && ( )} )} {/* */} , value: "left" }, { label: , value: "center" }, { label: , value: "right" }, ] } /> ); }; // TODO: Image Masking Option for Next Version. // export const SmartImageMaskingGeneralTab = ( { // attributes, // setAttributes, // } ) => { // const { imgMaskingEnable, imageShapeSet, selectImageShape, maskingShapedUpload, maskSize } = // attributes; // return ( // <> // // { 'shape-set' === imageShapeSet && ( // // ) } // { 'custom' === imageShapeSet && ( // <> // // // // ) } // // ); // }; export const SmartImageBackgroundTab = ({ attributes, setAttributes }) => { const { smartImgBgEnable, smartImgBg, smartBgImgBorder, smartBgImgBorderWidth, smartBgImgBorderRadius, smartBgImgInnerPadding, // smartImageBgImage, // TODO: for upcoming version. // smartImgOverlayType, // smartImgOverlayColor, // smartBgImgOverlayBlandMode, // smartBgImgOverlayBlandModeHover, // smartBgImgBlurHover, // smartBgImgBlur, } = attributes; const [hoverState, setHoverState] = useState("color"); const radiusHandler = ({ newValue, typeKey }) => { const updateData = smartBgImgBorderRadius?.allChange ? { top: newValue, right: newValue, bottom: newValue, left: newValue, } : { ...smartBgImgBorderRadius.value, [typeKey]: newValue }; setAttributes({ smartBgImgBorderRadius: { ...smartBgImgBorderRadius, value: updateData, }, }); }; const bgToggleHandler = (newValue) => { const padding = newValue ? { top: 0, right: 0, bottom: 0, left: 0 } : { top: 12, right: 12, bottom: 12, left: 12 }; setAttributes({ smartImgBgEnable: !smartImgBgEnable, smartBgImgInnerPadding: { ...smartBgImgInnerPadding, device: { Desktop: padding, Tablet: padding, Mobile: padding, }, }, }); }; return ( <> bgToggleHandler(newValue)} /> {smartImgBgEnable && ( <> setHoverState(newValue)} items={[ { label: "Normal", value: "color" }, { label: "Hover", value: "hover" }, ]} /> {/* TODO: Upcoming Version. */} {/* { 'image' === smartImgBg?.[ hoverState ]?.style && ( <> { 'custom' === smartImgOverlayType && ( <> { 'color' === hoverState ? ( <> setAttributes( { smartImgOverlayColor: { ...smartImgOverlayColor, color: newValue, }, } ) } /> ) : ( <> setAttributes( { smartImgOverlayColor: { ...smartImgOverlayColor, hover: newValue, }, } ) } /> ) } ) } ) } */} )} ); }; export const SmartImageCaptionTab = ({ attributes, setAttributes }) => { const { imgTitleEnable, imgTitleLabel, imgTitleTypography, imgTitleFontSize, imgTitleLineHeight, imgTitleLetterSpacing, imgTitleWordSpacing, imgCaptionEnable, imgCaptionLabel, imgCaptionTypography, imgCapFontSize, imgCapLineHeight, imgCapLetterSpacing, imgCapWordSpacing, imgTextVisibility, imgTextColor, imgTextPosition, imgTextHorizontal, imgTextVertical, imgTextPadding, } = attributes; const [hoverState, setHoverState] = useState("color"); const [titleCap, setTitleCap] = useState("title"); return ( <> setTitleCap(newValue)} items={[ { label: "Title", value: "title" }, { label: "Caption (Pro)", value: "caption", disabled: true }, ]} /> {"title" === titleCap ? ( <> {imgTitleEnable && ( <> setAttributes({ imgTitleLabel: newValue })} /> )} ) : ( <> {imgCaptionEnable && ( <> )} )} {(imgTitleEnable || imgCaptionEnable) && ( <> {"over-img" === imgTextPosition && ( )} setHoverState(newValue)} items={[ { label: "Normal", value: "color" }, { label: "Hover", value: "hover" }, ]} /> {"color" === hoverState ? ( <> setAttributes({ imgTextColor: { ...imgTextColor, color: newValue, }, }) } /> ) : ( <> setAttributes({ imgTextColor: { ...imgTextColor, color: newValue, }, }) } /> )} , value: "left" }, { label: , value: "center" }, { label: , value: "right" }, ]} /> {"over-img" === imgTextPosition && ( , value: "top" }, { label: , value: "center" }, { label: , value: "bottom" }, ]} rotate={true} /> )} )} ); }; export const SmartImageEffectTab = ({ attributes, setAttributes }) => { const { // imgAnimationEffect, // imgAnimationSpeed, // imgAnimationLineWidth, imgAnimationNormal, imgHoverOverlayEnable, imgHoverOverlayColor, imgMaskingEnable, imageShapeSet, selectImageShape, imgHoverEffectOpacity, } = attributes; const imageAnimAllItems = !imgMaskingEnable || (imgMaskingEnable && "custom" !== imageShapeSet && "original" === selectImageShape); return ( <> {/* */} {/* TODO: Upcoming Version. */} {/* */} {imgHoverOverlayEnable && ( <> )} ); };