import { __ } from "@wordpress/i18n";
import { GradientPicker } from "@wordpress/components";
import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl";
import { SmartButtonDefaultIcon, SmartButtonGhostIcon, SmartButtonGradientIcon } from "../../icons/icons";
import {
Toggle,
BoxShadow,
Spacing,
Border,
InputControl,
SpColorPicker,
Layouts,
Divider,
TypographyNew,
SelectDropdown,
SPRangeControl,
SelectField,
} from "../../components";
import hoverEffectsItems from "./hoverEffectsItems";
import { useState } from "@wordpress/element";
import {
ArrowMinimal,
ArrowOutline,
ArrowSolid,
ChevronBold,
ChevronBorderLine,
ChevronOutline,
ChevronSolid,
DoubleChevron,
DoubleChevronOutline,
TriangleOutline,
} from "../../icons/arrowIcons";
import { useSelect } from "@wordpress/data";
import ProInfo from "../../components/proInfo/proInfo";
export const SmartBtnGeneralTab = ({ attributes, setAttributes }) => {
const {
buttonBgColor,
buttonBorderRadius,
buttonBorder,
buttonBorderWidth,
buttonBoxShadowEnable,
buttonBoxShadow,
buttonHoverBorderRadius,
buttonHoverBoxShadowEnable,
buttonHoverBoxShadow,
buttonLink,
buttonPadding,
buttonStyle,
hoverEffects,
shadowColor,
buttonGradientBg,
buttonGradientHoverBg,
buttonHoverBorder,
buttonHoverBorderWidth,
openNewTab,
buttonBorderGradientWidthHover,
buttonBorderGradientRadiusHover,
buttonBorderGradientHover,
buttonLabelColor,
} = attributes;
const [bgColorState, setBgColorState] = useState("normal");
const layoutChange = (newValue) => {
if (newValue === buttonStyle) {
return;
}
const hoverValue = {
default: "defaultHover",
ghost: "ghostDefault",
gradient: "gradientHover",
};
const updatedAttributes = {
buttonStyle: newValue,
hoverEffects: hoverValue[newValue] || hoverEffects, // fallback to existing
};
// Extra styles for specific layouts
if (newValue === "ghost") {
updatedAttributes.buttonBgColor = {
...buttonBgColor,
color: "transparent",
};
updatedAttributes.buttonLabelColor = {
...buttonLabelColor,
color: "var(--smart-post-secondary)",
hoverColor: "#FFF",
};
}
if (newValue === "default") {
updatedAttributes.buttonBgColor = {
...buttonBgColor,
color: "var(--smart-post-secondary)",
};
updatedAttributes.buttonLabelColor = {
...buttonLabelColor,
color: "#fff",
hoverColor: "",
};
}
if (newValue === "gradient") {
updatedAttributes.buttonLabelColor = {
...buttonLabelColor,
color: "#fff",
hoverColor: "",
};
}
setAttributes(updatedAttributes);
};
const hoverEffectsChange = (newValue) => {
if (newValue === hoverEffects) {
return;
}
setAttributes({ hoverEffects: newValue });
};
const { defaultGradients, customGradients } = useSelect((select) => {
const settings = select("smartpost/global-settings");
return {
customGradients: settings.getCustomGradients(),
defaultGradients: settings.getDefaultGradient(),
};
}, []);
return (
<>
,
label: "Default",
value: "default",
},
{
icon: ,
label: "Ghost",
value: "ghost",
},
{
icon: ,
label: "Gradient",
value: "gradient",
type: "pro",
demoLink: "https://wpsmartpost.com/blocks/#demoId3588",
},
]}
/>
{!(buttonStyle === "gradient") && (
)}
{!(buttonStyle === "gradient") && (
<>
setBgColorState(newColor)}
/>
{/* Normal State */}
{"normal" === bgColorState ? (
<>
setAttributes({
buttonBgColor: {
...buttonBgColor,
color: newColor,
},
})
}
defaultColor=""
/>
{["default", "ghost"].includes(buttonStyle) &&
[
"defaultHover",
"shine",
"ghostDefault",
"slideRight",
"slideSkew",
"slideTop",
"drawOutline",
].includes(hoverEffects) && (
<>
{buttonBoxShadowEnable && (
)}
>
)}
{["default", "ghost"].includes(buttonStyle) &&
[
"defaultHover",
"shine",
"multiLayers",
"ghostDefault",
"slideRight",
"slideSkew",
"slideTop",
"neoFollow",
"gradient",
"drawOutline",
"raiseShadow",
].includes(hoverEffects) && (
)}
>
) : (
// Hover State
<>
setAttributes({
buttonBgColor: {
...buttonBgColor,
hoverColor: newColor,
},
})
}
/>
{["default"].includes(buttonStyle) &&
["raiseShadow", "multiLayers"].includes(hoverEffects) && (
setAttributes({
shadowColor: newColor,
})
}
defaultColor="#333333"
/>
)}
{["default", "ghost"].includes(buttonStyle) &&
[
"defaultHover",
"shine",
"ghostDefault",
"slideRight",
"slideSkew",
"slideTop",
"drawOutline",
"ghostDefault",
].includes(hoverEffects) && (
<>
{buttonHoverBoxShadowEnable && (
)}
>
)}
{["default", "ghost"].includes(buttonStyle) &&
[
"defaultHover",
"shine",
"multiLayers",
"raiseShadow",
"gradShadow",
"neoFollow",
"ghostDefault",
"slideRight",
"slideSkew",
"slideTop",
"drawOutline",
].includes(hoverEffects) && (
)}
>
)}
>
)}
{buttonStyle === "gradient" && (
<>
setBgColorState(newColor)}
/>
{bgColorState === "normal" ? (
<>
Gradient Color
setAttributes({
buttonGradientBg: currentGradient,
})
}
/>
>
) : (
<>
Hover Gradient Color
setAttributes({
buttonGradientHoverBg: currentGradient,
})
}
/>
>
)}
>
)}
>
);
};
export const SmartBtnLabelTab = ({ attributes, setAttributes }) => {
const {
buttonLabelTypography,
buttonLabelFontSize,
buttonLabelLatterSpacing,
buttonLabelLineHeight,
buttonLabelColor,
buttonLabelWordSpacing,
buttonLabelEnable,
buttonLabelGlobalTypography,
} = attributes;
const [colorState, setColorState] = useState("normal");
return (
<>
{/* */}
{buttonLabelEnable && (
<>
setColorState(newColor)}
/>
{"normal" === colorState ? (
setAttributes({
buttonLabelColor: {
...buttonLabelColor,
color: newColor,
},
})
}
defaultColor="#333333"
/>
) : (
setAttributes({
buttonLabelColor: {
...buttonLabelColor,
hoverColor: newColor,
},
})
}
/>
)}
>
)}
>
);
};
export const SmartBtnIconTab = ({ attributes, setAttributes }) => {
const { iconSource, iconGap, iconPosition, enableIcon, buttonLabelEnable, smartBtnIconSize, smartBtnIconColor } =
attributes;
const [iconColorState, setIconColorState] = useState("normal");
const iconPositionItems = [
{ label: "Left", value: "left" },
{ label: "Right", value: "right" },
{ label: "Top", value: "top" },
{ label: "Bottom", value: "bottom" },
];
return (
<>
{enableIcon && (
<>
{/* */}
,
},
{
label: __("Chevron Outline", "post-carousel"),
value: "chevron-outline",
icon: ,
},
{
label: __("Chevron Bold", "post-carousel"),
value: "chevron-bold",
icon: ,
},
{
label: __("Double Chevron", "post-carousel"),
value: "double-chevron",
icon: ,
},
{
label: __("Arrow Solid", "post-carousel"),
value: "arrow-solid",
icon: ,
},
{
label: __("Arrow Outline", "post-carousel"),
value: "arrow-outline",
icon: ,
},
{
label: __("Arrow Minimal", "post-carousel"),
value: "arrow-minimal",
icon: ,
},
{
label: __("Chevron Border Line", "post-carousel"),
value: "chevron-border-line",
icon: ,
},
{
label: __("Double Chevron Outline", "post-carousel"),
value: "double-chevron-outline",
icon: ,
},
{
label: __("Triangle Outline", "post-carousel"),
value: "triangle-outline",
icon: ,
},
]}
/>
{iconSource && (
<>
{/* */}
{/*
setIconColorState( newColor )
}
/>
{ 'normal' === iconColorState ? (
setAttributes( {
iconColor: {
...iconColor,
color: newColor,
},
} )
}
defaultColor="#333333"
/>
) : (
setAttributes( {
iconColor: {
...iconColor,
hoverColor: newColor,
},
} )
}
/>
) } */}
{buttonLabelEnable && (
)}
setIconColorState(newValue)}
items={[
{ label: "Normal", value: "normal" },
{ label: "Hover", value: "hover" },
]}
/>
{"normal" === iconColorState ? (
<>
setAttributes({
smartBtnIconColor: {
...smartBtnIconColor,
color: newValue,
},
})
}
/>
>
) : (
<>
setAttributes({
smartBtnIconColor: {
...smartBtnIconColor,
hover: newValue,
},
})
}
/>
>
)}
>
)}
>
)}
Premium Only
Enhance your buttons with customizable icons
-
— Add icons to buttons
-
— Icon size and spacing control
-
— Flexible icon positioning
-
— Normal and hover color styling
Upgrade to Pro
>
);
};