| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { GradientPicker } from "@wordpress/components"; |
| 3 |
import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; |
| 4 |
import { SmartButtonDefaultIcon, SmartButtonGhostIcon, SmartButtonGradientIcon } from "../../icons/icons"; |
| 5 |
|
| 6 |
import { |
| 7 |
Toggle, |
| 8 |
BoxShadow, |
| 9 |
Spacing, |
| 10 |
Border, |
| 11 |
InputControl, |
| 12 |
SpColorPicker, |
| 13 |
Layouts, |
| 14 |
Divider, |
| 15 |
TypographyNew, |
| 16 |
SelectDropdown, |
| 17 |
SPRangeControl, |
| 18 |
SelectField, |
| 19 |
} from "../../components"; |
| 20 |
import hoverEffectsItems from "./hoverEffectsItems"; |
| 21 |
import { useState } from "@wordpress/element"; |
| 22 |
import { |
| 23 |
ArrowMinimal, |
| 24 |
ArrowOutline, |
| 25 |
ArrowSolid, |
| 26 |
ChevronBold, |
| 27 |
ChevronBorderLine, |
| 28 |
ChevronOutline, |
| 29 |
ChevronSolid, |
| 30 |
DoubleChevron, |
| 31 |
DoubleChevronOutline, |
| 32 |
TriangleOutline, |
| 33 |
} from "../../icons/arrowIcons"; |
| 34 |
import { useSelect } from "@wordpress/data"; |
| 35 |
import ProInfo from "../../components/proInfo/proInfo"; |
| 36 |
|
| 37 |
export const SmartBtnGeneralTab = ({ attributes, setAttributes }) => { |
| 38 |
const { |
| 39 |
buttonBgColor, |
| 40 |
buttonBorderRadius, |
| 41 |
buttonBorder, |
| 42 |
buttonBorderWidth, |
| 43 |
buttonBoxShadowEnable, |
| 44 |
buttonBoxShadow, |
| 45 |
buttonHoverBorderRadius, |
| 46 |
buttonHoverBoxShadowEnable, |
| 47 |
buttonHoverBoxShadow, |
| 48 |
buttonLink, |
| 49 |
buttonPadding, |
| 50 |
buttonStyle, |
| 51 |
hoverEffects, |
| 52 |
shadowColor, |
| 53 |
buttonGradientBg, |
| 54 |
buttonGradientHoverBg, |
| 55 |
buttonHoverBorder, |
| 56 |
buttonHoverBorderWidth, |
| 57 |
openNewTab, |
| 58 |
buttonBorderGradientWidthHover, |
| 59 |
buttonBorderGradientRadiusHover, |
| 60 |
buttonBorderGradientHover, |
| 61 |
buttonLabelColor, |
| 62 |
} = attributes; |
| 63 |
const [bgColorState, setBgColorState] = useState("normal"); |
| 64 |
|
| 65 |
const layoutChange = (newValue) => { |
| 66 |
if (newValue === buttonStyle) { |
| 67 |
return; |
| 68 |
} |
| 69 |
|
| 70 |
const hoverValue = { |
| 71 |
default: "defaultHover", |
| 72 |
ghost: "ghostDefault", |
| 73 |
gradient: "gradientHover", |
| 74 |
}; |
| 75 |
|
| 76 |
const updatedAttributes = { |
| 77 |
buttonStyle: newValue, |
| 78 |
hoverEffects: hoverValue[newValue] || hoverEffects, // fallback to existing |
| 79 |
}; |
| 80 |
|
| 81 |
// Extra styles for specific layouts |
| 82 |
if (newValue === "ghost") { |
| 83 |
updatedAttributes.buttonBgColor = { |
| 84 |
...buttonBgColor, |
| 85 |
color: "transparent", |
| 86 |
}; |
| 87 |
|
| 88 |
updatedAttributes.buttonLabelColor = { |
| 89 |
...buttonLabelColor, |
| 90 |
color: "var(--smart-post-secondary)", |
| 91 |
hoverColor: "#FFF", |
| 92 |
}; |
| 93 |
} |
| 94 |
|
| 95 |
if (newValue === "default") { |
| 96 |
updatedAttributes.buttonBgColor = { |
| 97 |
...buttonBgColor, |
| 98 |
color: "var(--smart-post-secondary)", |
| 99 |
}; |
| 100 |
|
| 101 |
updatedAttributes.buttonLabelColor = { |
| 102 |
...buttonLabelColor, |
| 103 |
color: "#fff", |
| 104 |
hoverColor: "", |
| 105 |
}; |
| 106 |
} |
| 107 |
if (newValue === "gradient") { |
| 108 |
updatedAttributes.buttonLabelColor = { |
| 109 |
...buttonLabelColor, |
| 110 |
color: "#fff", |
| 111 |
hoverColor: "", |
| 112 |
}; |
| 113 |
} |
| 114 |
|
| 115 |
setAttributes(updatedAttributes); |
| 116 |
}; |
| 117 |
|
| 118 |
const hoverEffectsChange = (newValue) => { |
| 119 |
if (newValue === hoverEffects) { |
| 120 |
return; |
| 121 |
} |
| 122 |
setAttributes({ hoverEffects: newValue }); |
| 123 |
}; |
| 124 |
|
| 125 |
const { defaultGradients, customGradients } = useSelect((select) => { |
| 126 |
const settings = select("smartpost/global-settings"); |
| 127 |
return { |
| 128 |
customGradients: settings.getCustomGradients(), |
| 129 |
defaultGradients: settings.getDefaultGradient(), |
| 130 |
}; |
| 131 |
}, []); |
| 132 |
|
| 133 |
return ( |
| 134 |
<> |
| 135 |
<Layouts |
| 136 |
attributes={buttonStyle} |
| 137 |
setAttributes={setAttributes} |
| 138 |
attributesKey={"buttonStyle"} |
| 139 |
displayActive={true} |
| 140 |
grid={3} |
| 141 |
showDemoTitle={true} |
| 142 |
proBtnClass="sp-smart-small-size" |
| 143 |
onChange={layoutChange} |
| 144 |
label={__("Button Style", "post-carousel")} |
| 145 |
items={[ |
| 146 |
{ |
| 147 |
icon: <SmartButtonDefaultIcon value={buttonStyle} />, |
| 148 |
label: "Default", |
| 149 |
value: "default", |
| 150 |
}, |
| 151 |
{ |
| 152 |
icon: <SmartButtonGhostIcon value={buttonStyle} />, |
| 153 |
label: "Ghost", |
| 154 |
value: "ghost", |
| 155 |
}, |
| 156 |
{ |
| 157 |
icon: <SmartButtonGradientIcon value={buttonStyle} />, |
| 158 |
label: "Gradient", |
| 159 |
value: "gradient", |
| 160 |
type: "pro", |
| 161 |
demoLink: "https://wpsmartpost.com/blocks/#demoId3588", |
| 162 |
}, |
| 163 |
]} |
| 164 |
/> |
| 165 |
{!(buttonStyle === "gradient") && ( |
| 166 |
<Layouts |
| 167 |
attributes={hoverEffects} |
| 168 |
setAttributes={setAttributes} |
| 169 |
attributesKey={"hoverEffects"} |
| 170 |
displayActive={true} |
| 171 |
grid={3} |
| 172 |
onChange={hoverEffectsChange} |
| 173 |
showDemoTitle={true} |
| 174 |
proBtnClass="sp-smart-small-size" |
| 175 |
label={__("Hover Effects", "post-carousel")} |
| 176 |
items={hoverEffectsItems(buttonStyle, hoverEffects)} |
| 177 |
/> |
| 178 |
)} |
| 179 |
|
| 180 |
{!(buttonStyle === "gradient") && ( |
| 181 |
<> |
| 182 |
<SPToggleGroupControl |
| 183 |
attributes={bgColorState} |
| 184 |
items={[ |
| 185 |
{ label: "Normal", value: "normal" }, |
| 186 |
{ label: "Hover", value: "hover" }, |
| 187 |
]} |
| 188 |
onClick={(newColor) => setBgColorState(newColor)} |
| 189 |
/> |
| 190 |
{/* Normal State */} |
| 191 |
{"normal" === bgColorState ? ( |
| 192 |
<> |
| 193 |
<SpColorPicker |
| 194 |
label={__("Background Color", "post-carousel")} |
| 195 |
value={buttonBgColor?.color} |
| 196 |
onChange={(newColor) => |
| 197 |
setAttributes({ |
| 198 |
buttonBgColor: { |
| 199 |
...buttonBgColor, |
| 200 |
color: newColor, |
| 201 |
}, |
| 202 |
}) |
| 203 |
} |
| 204 |
defaultColor="" |
| 205 |
/> |
| 206 |
|
| 207 |
{["default", "ghost"].includes(buttonStyle) && |
| 208 |
[ |
| 209 |
"defaultHover", |
| 210 |
"shine", |
| 211 |
"ghostDefault", |
| 212 |
"slideRight", |
| 213 |
"slideSkew", |
| 214 |
"slideTop", |
| 215 |
"drawOutline", |
| 216 |
].includes(hoverEffects) && ( |
| 217 |
<> |
| 218 |
<Toggle |
| 219 |
label={__("Box Shadow", "post-carousel")} |
| 220 |
attributes={buttonBoxShadowEnable} |
| 221 |
attributesKey={"buttonBoxShadowEnable"} |
| 222 |
setAttributes={setAttributes} |
| 223 |
/> |
| 224 |
{buttonBoxShadowEnable && ( |
| 225 |
<BoxShadow |
| 226 |
label={__("Box Shadow", "post-carousel")} |
| 227 |
attributes={buttonBoxShadow} |
| 228 |
attributesKey={"buttonBoxShadow"} |
| 229 |
setAttributes={setAttributes} |
| 230 |
defaultColor={"#4E4F521A"} |
| 231 |
/> |
| 232 |
)} |
| 233 |
</> |
| 234 |
)} |
| 235 |
|
| 236 |
<Border |
| 237 |
label={__("Border", "post-carousel")} |
| 238 |
attributes={{ |
| 239 |
border: buttonBorder, |
| 240 |
borderWidth: buttonBorderWidth, |
| 241 |
}} |
| 242 |
attributesKey={{ |
| 243 |
border: "buttonBorder", |
| 244 |
borderWidth: "buttonBorderWidth", |
| 245 |
}} |
| 246 |
setAttributes={setAttributes} |
| 247 |
btnType="normal" |
| 248 |
/> |
| 249 |
|
| 250 |
{["default", "ghost"].includes(buttonStyle) && |
| 251 |
[ |
| 252 |
"defaultHover", |
| 253 |
"shine", |
| 254 |
"multiLayers", |
| 255 |
"ghostDefault", |
| 256 |
"slideRight", |
| 257 |
"slideSkew", |
| 258 |
"slideTop", |
| 259 |
"neoFollow", |
| 260 |
"gradient", |
| 261 |
"drawOutline", |
| 262 |
"raiseShadow", |
| 263 |
].includes(hoverEffects) && ( |
| 264 |
<Spacing |
| 265 |
label={__("Border Radius", "post-carousel")} |
| 266 |
attributes={buttonBorderRadius} |
| 267 |
attributesKey={"buttonBorderRadius"} |
| 268 |
setAttributes={setAttributes} |
| 269 |
units={["px", "%", "em"]} |
| 270 |
defaultValue={{ |
| 271 |
unit: "px", |
| 272 |
value: { |
| 273 |
top: "0", |
| 274 |
right: "0", |
| 275 |
bottom: "0", |
| 276 |
left: "0", |
| 277 |
}, |
| 278 |
}} |
| 279 |
indicator={"radius"} |
| 280 |
/> |
| 281 |
)} |
| 282 |
</> |
| 283 |
) : ( |
| 284 |
// Hover State |
| 285 |
<> |
| 286 |
<SpColorPicker |
| 287 |
label={__("Background Color", "post-carousel")} |
| 288 |
value={buttonBgColor.hoverColor} |
| 289 |
onChange={(newColor) => |
| 290 |
setAttributes({ |
| 291 |
buttonBgColor: { |
| 292 |
...buttonBgColor, |
| 293 |
hoverColor: newColor, |
| 294 |
}, |
| 295 |
}) |
| 296 |
} |
| 297 |
/> |
| 298 |
|
| 299 |
{["default"].includes(buttonStyle) && |
| 300 |
["raiseShadow", "multiLayers"].includes(hoverEffects) && ( |
| 301 |
<SpColorPicker |
| 302 |
label={__("Shadow Color", "post-carousel")} |
| 303 |
value={shadowColor} |
| 304 |
onChange={(newColor) => |
| 305 |
setAttributes({ |
| 306 |
shadowColor: newColor, |
| 307 |
}) |
| 308 |
} |
| 309 |
defaultColor="#333333" |
| 310 |
/> |
| 311 |
)} |
| 312 |
|
| 313 |
{["default", "ghost"].includes(buttonStyle) && |
| 314 |
[ |
| 315 |
"defaultHover", |
| 316 |
"shine", |
| 317 |
"ghostDefault", |
| 318 |
"slideRight", |
| 319 |
"slideSkew", |
| 320 |
"slideTop", |
| 321 |
"drawOutline", |
| 322 |
"ghostDefault", |
| 323 |
].includes(hoverEffects) && ( |
| 324 |
<> |
| 325 |
<Toggle |
| 326 |
label={__("Box Shadow", "post-carousel")} |
| 327 |
attributes={buttonHoverBoxShadowEnable} |
| 328 |
attributesKey={"buttonHoverBoxShadowEnable"} |
| 329 |
setAttributes={setAttributes} |
| 330 |
/> |
| 331 |
{buttonHoverBoxShadowEnable && ( |
| 332 |
<BoxShadow |
| 333 |
label={__("Hover Box Shadow", "post-carousel")} |
| 334 |
attributes={buttonHoverBoxShadow} |
| 335 |
attributesKey={"buttonHoverBoxShadow"} |
| 336 |
setAttributes={setAttributes} |
| 337 |
defaultColor={"#4E4F521A"} |
| 338 |
/> |
| 339 |
)} |
| 340 |
</> |
| 341 |
)} |
| 342 |
|
| 343 |
<Border |
| 344 |
label={__("Border", "post-carousel")} |
| 345 |
attributes={{ |
| 346 |
border: buttonHoverBorder, |
| 347 |
borderWidth: buttonHoverBorderWidth, |
| 348 |
}} |
| 349 |
attributesKey={{ |
| 350 |
border: "buttonHoverBorder", |
| 351 |
borderWidth: "buttonHoverBorderWidth", |
| 352 |
}} |
| 353 |
setAttributes={setAttributes} |
| 354 |
btnType="normal" |
| 355 |
/> |
| 356 |
|
| 357 |
{["default", "ghost"].includes(buttonStyle) && |
| 358 |
[ |
| 359 |
"defaultHover", |
| 360 |
"shine", |
| 361 |
"multiLayers", |
| 362 |
"raiseShadow", |
| 363 |
"gradShadow", |
| 364 |
"neoFollow", |
| 365 |
"ghostDefault", |
| 366 |
"slideRight", |
| 367 |
"slideSkew", |
| 368 |
"slideTop", |
| 369 |
"drawOutline", |
| 370 |
].includes(hoverEffects) && ( |
| 371 |
<Spacing |
| 372 |
label={__("Border Radius", "post-carousel")} |
| 373 |
attributes={buttonHoverBorderRadius} |
| 374 |
attributesKey={"buttonHoverBorderRadius"} |
| 375 |
setAttributes={setAttributes} |
| 376 |
units={["px", "%", "em"]} |
| 377 |
defaultValue={{ |
| 378 |
unit: "px", |
| 379 |
value: { |
| 380 |
top: "0", |
| 381 |
right: "0", |
| 382 |
bottom: "0", |
| 383 |
left: "0", |
| 384 |
}, |
| 385 |
}} |
| 386 |
indicator={"radius"} |
| 387 |
/> |
| 388 |
)} |
| 389 |
</> |
| 390 |
)} |
| 391 |
</> |
| 392 |
)} |
| 393 |
|
| 394 |
{buttonStyle === "gradient" && ( |
| 395 |
<> |
| 396 |
<SPToggleGroupControl |
| 397 |
attributes={bgColorState} |
| 398 |
items={[ |
| 399 |
{ label: "Normal", value: "normal" }, |
| 400 |
{ label: "Hover", value: "hover" }, |
| 401 |
]} |
| 402 |
onClick={(newColor) => setBgColorState(newColor)} |
| 403 |
/> |
| 404 |
|
| 405 |
{bgColorState === "normal" ? ( |
| 406 |
<> |
| 407 |
<div className="sp-smart-post-component-gradient"> |
| 408 |
<p className="sp-smart-post-component-title">Gradient Color</p> |
| 409 |
<GradientPicker |
| 410 |
value={buttonGradientBg} |
| 411 |
gradients={[...defaultGradients, ...customGradients]} |
| 412 |
onChange={(currentGradient) => |
| 413 |
setAttributes({ |
| 414 |
buttonGradientBg: currentGradient, |
| 415 |
}) |
| 416 |
} |
| 417 |
/> |
| 418 |
</div> |
| 419 |
|
| 420 |
<Border |
| 421 |
label={__("Border", "post-carousel")} |
| 422 |
attributes={{ |
| 423 |
border: buttonBorder, |
| 424 |
borderWidth: buttonBorderWidth, |
| 425 |
}} |
| 426 |
attributesKey={{ |
| 427 |
border: "buttonBorder", |
| 428 |
borderWidth: "buttonBorderWidth", |
| 429 |
}} |
| 430 |
setAttributes={setAttributes} |
| 431 |
btnType="normal" |
| 432 |
/> |
| 433 |
|
| 434 |
<Spacing |
| 435 |
label={__("Border Radius", "post-carousel")} |
| 436 |
attributes={buttonBorderRadius} |
| 437 |
attributesKey={"buttonBorderRadius"} |
| 438 |
setAttributes={setAttributes} |
| 439 |
units={["px", "%", "em"]} |
| 440 |
defaultValue={{ |
| 441 |
unit: "px", |
| 442 |
value: { |
| 443 |
top: "0", |
| 444 |
right: "0", |
| 445 |
bottom: "0", |
| 446 |
left: "0", |
| 447 |
}, |
| 448 |
}} |
| 449 |
indicator={"radius"} |
| 450 |
/> |
| 451 |
</> |
| 452 |
) : ( |
| 453 |
<> |
| 454 |
<div className="sp-smart-post-component-gradient"> |
| 455 |
<p className="sp-smart-post-component-title">Hover Gradient Color</p> |
| 456 |
<GradientPicker |
| 457 |
value={buttonGradientHoverBg} |
| 458 |
gradients={[...defaultGradients, ...customGradients]} |
| 459 |
onChange={(currentGradient) => |
| 460 |
setAttributes({ |
| 461 |
buttonGradientHoverBg: currentGradient, |
| 462 |
}) |
| 463 |
} |
| 464 |
/> |
| 465 |
</div> |
| 466 |
|
| 467 |
<Border |
| 468 |
label={__("Border", "post-carousel")} |
| 469 |
attributes={{ |
| 470 |
border: buttonBorderGradientHover, |
| 471 |
borderWidth: buttonBorderGradientWidthHover, |
| 472 |
}} |
| 473 |
attributesKey={{ |
| 474 |
border: "buttonBorderGradientHover", |
| 475 |
borderWidth: "buttonBorderGradientWidthHover", |
| 476 |
}} |
| 477 |
setAttributes={setAttributes} |
| 478 |
btnType="normal" |
| 479 |
/> |
| 480 |
|
| 481 |
<Spacing |
| 482 |
label={__("Border Radius", "post-carousel")} |
| 483 |
attributes={buttonBorderGradientRadiusHover} |
| 484 |
attributesKey={"buttonBorderGradientRadiusHover"} |
| 485 |
setAttributes={setAttributes} |
| 486 |
units={["px", "%", "em"]} |
| 487 |
defaultValue={{ |
| 488 |
unit: "px", |
| 489 |
value: { |
| 490 |
top: "0", |
| 491 |
right: "0", |
| 492 |
bottom: "0", |
| 493 |
left: "0", |
| 494 |
}, |
| 495 |
}} |
| 496 |
indicator={"radius"} |
| 497 |
/> |
| 498 |
</> |
| 499 |
)} |
| 500 |
</> |
| 501 |
)} |
| 502 |
|
| 503 |
<Divider position={"sp-w-100pct bottom"} /> |
| 504 |
|
| 505 |
<InputControl |
| 506 |
label={__("Button Link", "post-carousel")} |
| 507 |
attributes={buttonLink} |
| 508 |
flex={false} |
| 509 |
inputType="text" |
| 510 |
attributesKey={"buttonLink"} |
| 511 |
setAttributes={setAttributes} |
| 512 |
placeholder={__("Enter Button URL", "post-carousel")} |
| 513 |
/> |
| 514 |
|
| 515 |
<Toggle |
| 516 |
label={__("Open in New Tab", "post-carousel")} |
| 517 |
attributes={openNewTab} |
| 518 |
attributesKey={"openNewTab"} |
| 519 |
setAttributes={setAttributes} |
| 520 |
/> |
| 521 |
|
| 522 |
<Spacing |
| 523 |
label={__("Padding", "post-carousel")} |
| 524 |
attributes={buttonPadding} |
| 525 |
attributesKey={"buttonPadding"} |
| 526 |
setAttributes={setAttributes} |
| 527 |
units={["px", "%", "em"]} |
| 528 |
defaultValue={{ top: 14, right: 28, bottom: 14, left: 28 }} |
| 529 |
/> |
| 530 |
</> |
| 531 |
); |
| 532 |
}; |
| 533 |
|
| 534 |
export const SmartBtnLabelTab = ({ attributes, setAttributes }) => { |
| 535 |
const { |
| 536 |
buttonLabelTypography, |
| 537 |
buttonLabelFontSize, |
| 538 |
buttonLabelLatterSpacing, |
| 539 |
buttonLabelLineHeight, |
| 540 |
buttonLabelColor, |
| 541 |
buttonLabelWordSpacing, |
| 542 |
buttonLabelEnable, |
| 543 |
buttonLabelGlobalTypography, |
| 544 |
} = attributes; |
| 545 |
const [colorState, setColorState] = useState("normal"); |
| 546 |
|
| 547 |
return ( |
| 548 |
<> |
| 549 |
<Toggle |
| 550 |
label={__("Button Label", "post-carousel")} |
| 551 |
attributes={buttonLabelEnable} |
| 552 |
attributesKey={"buttonLabelEnable"} |
| 553 |
setAttributes={setAttributes} |
| 554 |
/> |
| 555 |
{/* <InputControl |
| 556 |
label={ __( 'Button Label', 'post-carousel' ) } |
| 557 |
attributes={ buttonLabel } |
| 558 |
flex={ false } |
| 559 |
inputType="text" |
| 560 |
attributesKey={ 'buttonLabel' } |
| 561 |
setAttributes={ setAttributes } |
| 562 |
placeholder={ __( 'Button Label', 'post-carousel' ) } |
| 563 |
/> */} |
| 564 |
{buttonLabelEnable && ( |
| 565 |
<> |
| 566 |
<TypographyNew |
| 567 |
attributes={{ |
| 568 |
family: buttonLabelTypography, |
| 569 |
familyKey: "buttonLabelTypography", |
| 570 |
fontSize: buttonLabelFontSize, |
| 571 |
fontSizeKey: "buttonLabelFontSize", |
| 572 |
fontSpacing: buttonLabelLatterSpacing, |
| 573 |
fontSpacingKey: "buttonLabelLatterSpacing", |
| 574 |
lineHeight: buttonLabelLineHeight, |
| 575 |
lineHeightKey: "buttonLabelLineHeight", |
| 576 |
wordSpacing: buttonLabelWordSpacing, |
| 577 |
wordSpacingKey: "buttonLabelWordSpacing", |
| 578 |
globalTypo: buttonLabelGlobalTypography, |
| 579 |
globalTypoKey: "buttonLabelGlobalTypography", |
| 580 |
}} |
| 581 |
setAttributes={setAttributes} |
| 582 |
spacingDefaultValue={{ unit: "px", value: 0 }} |
| 583 |
fontSizeDefault={{ |
| 584 |
unit: "px", |
| 585 |
value: 14, |
| 586 |
}} |
| 587 |
typographyLabel={__("Typography", "post-carousel")} |
| 588 |
/> |
| 589 |
|
| 590 |
<SPToggleGroupControl |
| 591 |
attributes={colorState} |
| 592 |
items={[ |
| 593 |
{ label: "Normal", value: "normal" }, |
| 594 |
{ label: "Hover", value: "hover" }, |
| 595 |
]} |
| 596 |
onClick={(newColor) => setColorState(newColor)} |
| 597 |
/> |
| 598 |
{"normal" === colorState ? ( |
| 599 |
<SpColorPicker |
| 600 |
label={__("Color", "post-carousel")} |
| 601 |
value={buttonLabelColor?.color} |
| 602 |
onChange={(newColor) => |
| 603 |
setAttributes({ |
| 604 |
buttonLabelColor: { |
| 605 |
...buttonLabelColor, |
| 606 |
color: newColor, |
| 607 |
}, |
| 608 |
}) |
| 609 |
} |
| 610 |
defaultColor="#333333" |
| 611 |
/> |
| 612 |
) : ( |
| 613 |
<SpColorPicker |
| 614 |
label={__("Color", "post-carousel")} |
| 615 |
value={buttonLabelColor.hoverColor} |
| 616 |
onChange={(newColor) => |
| 617 |
setAttributes({ |
| 618 |
buttonLabelColor: { |
| 619 |
...buttonLabelColor, |
| 620 |
hoverColor: newColor, |
| 621 |
}, |
| 622 |
}) |
| 623 |
} |
| 624 |
/> |
| 625 |
)} |
| 626 |
</> |
| 627 |
)} |
| 628 |
</> |
| 629 |
); |
| 630 |
}; |
| 631 |
|
| 632 |
export const SmartBtnIconTab = ({ attributes, setAttributes }) => { |
| 633 |
const { iconSource, iconGap, iconPosition, enableIcon, buttonLabelEnable, smartBtnIconSize, smartBtnIconColor } = |
| 634 |
attributes; |
| 635 |
const [iconColorState, setIconColorState] = useState("normal"); |
| 636 |
const iconPositionItems = [ |
| 637 |
{ label: "Left", value: "left" }, |
| 638 |
{ label: "Right", value: "right" }, |
| 639 |
{ label: "Top", value: "top" }, |
| 640 |
{ label: "Bottom", value: "bottom" }, |
| 641 |
]; |
| 642 |
|
| 643 |
return ( |
| 644 |
<> |
| 645 |
<Toggle |
| 646 |
label={__("Icon", "post-carousel")} |
| 647 |
attributes={enableIcon} |
| 648 |
attributesKey={"enableIcon"} |
| 649 |
setAttributes={setAttributes} |
| 650 |
pro={true} |
| 651 |
/> |
| 652 |
|
| 653 |
{enableIcon && ( |
| 654 |
<> |
| 655 |
{/* <IconPicker |
| 656 |
attributes={ iconSource } |
| 657 |
attributesKey="iconSource" |
| 658 |
setAttributes={ setAttributes } |
| 659 |
label="Icon Source" |
| 660 |
onChange={ handleIconSource } |
| 661 |
iconType="arrowIcon" |
| 662 |
/> */} |
| 663 |
|
| 664 |
<SelectDropdown |
| 665 |
label={__("Icon Styles", "post-carousel")} |
| 666 |
attributes={iconSource} |
| 667 |
attributesKey={"iconSource"} |
| 668 |
setAttributes={setAttributes} |
| 669 |
options={[ |
| 670 |
{ |
| 671 |
label: __("Chevron Solid", "post-carousel"), |
| 672 |
value: "chevron-solid", |
| 673 |
icon: <ChevronSolid />, |
| 674 |
}, |
| 675 |
{ |
| 676 |
label: __("Chevron Outline", "post-carousel"), |
| 677 |
value: "chevron-outline", |
| 678 |
icon: <ChevronOutline />, |
| 679 |
}, |
| 680 |
{ |
| 681 |
label: __("Chevron Bold", "post-carousel"), |
| 682 |
value: "chevron-bold", |
| 683 |
icon: <ChevronBold />, |
| 684 |
}, |
| 685 |
{ |
| 686 |
label: __("Double Chevron", "post-carousel"), |
| 687 |
value: "double-chevron", |
| 688 |
icon: <DoubleChevron />, |
| 689 |
}, |
| 690 |
{ |
| 691 |
label: __("Arrow Solid", "post-carousel"), |
| 692 |
value: "arrow-solid", |
| 693 |
icon: <ArrowSolid />, |
| 694 |
}, |
| 695 |
{ |
| 696 |
label: __("Arrow Outline", "post-carousel"), |
| 697 |
value: "arrow-outline", |
| 698 |
icon: <ArrowOutline />, |
| 699 |
}, |
| 700 |
{ |
| 701 |
label: __("Arrow Minimal", "post-carousel"), |
| 702 |
value: "arrow-minimal", |
| 703 |
icon: <ArrowMinimal />, |
| 704 |
}, |
| 705 |
{ |
| 706 |
label: __("Chevron Border Line", "post-carousel"), |
| 707 |
value: "chevron-border-line", |
| 708 |
icon: <ChevronBorderLine />, |
| 709 |
}, |
| 710 |
{ |
| 711 |
label: __("Double Chevron Outline", "post-carousel"), |
| 712 |
value: "double-chevron-outline", |
| 713 |
icon: <DoubleChevronOutline />, |
| 714 |
}, |
| 715 |
{ |
| 716 |
label: __("Triangle Outline", "post-carousel"), |
| 717 |
value: "triangle-outline", |
| 718 |
icon: <TriangleOutline />, |
| 719 |
}, |
| 720 |
]} |
| 721 |
/> |
| 722 |
{iconSource && ( |
| 723 |
<> |
| 724 |
{/* <SPRangeControl |
| 725 |
label={ __( |
| 726 |
'Icon Size', |
| 727 |
'post-carousel' |
| 728 |
) } |
| 729 |
attributes={ iconSize } |
| 730 |
attributesKey={ 'iconSize' } |
| 731 |
setAttributes={ setAttributes } |
| 732 |
units={ [ 'px', '%', 'Em' ] } |
| 733 |
defaultValue={ { unit: 'px', value: 14 } } |
| 734 |
max={ 100 } |
| 735 |
/> */} |
| 736 |
|
| 737 |
{/* <SPToggleGroupControl |
| 738 |
attributes={ iconColorState } |
| 739 |
items={ [ |
| 740 |
{ label: 'Normal', value: 'normal' }, |
| 741 |
{ label: 'Hover', value: 'hover' }, |
| 742 |
] } |
| 743 |
onClick={ ( newColor ) => |
| 744 |
setIconColorState( newColor ) |
| 745 |
} |
| 746 |
/> |
| 747 |
{ 'normal' === iconColorState ? ( |
| 748 |
<SpColorPicker |
| 749 |
label={ __( |
| 750 |
'Color', |
| 751 |
'post-carousel' |
| 752 |
) } |
| 753 |
value={ iconColor.color } |
| 754 |
onChange={ ( newColor ) => |
| 755 |
setAttributes( { |
| 756 |
iconColor: { |
| 757 |
...iconColor, |
| 758 |
color: newColor, |
| 759 |
}, |
| 760 |
} ) |
| 761 |
} |
| 762 |
defaultColor="#333333" |
| 763 |
/> |
| 764 |
) : ( |
| 765 |
<SpColorPicker |
| 766 |
label={ __( |
| 767 |
'Color', |
| 768 |
'post-carousel' |
| 769 |
) } |
| 770 |
value={ iconColor.hoverColor } |
| 771 |
onChange={ ( newColor ) => |
| 772 |
setAttributes( { |
| 773 |
iconColor: { |
| 774 |
...iconColor, |
| 775 |
hoverColor: newColor, |
| 776 |
}, |
| 777 |
} ) |
| 778 |
} |
| 779 |
/> |
| 780 |
) } */} |
| 781 |
|
| 782 |
<SPRangeControl |
| 783 |
label={__("Icon Size", "post-carousel")} |
| 784 |
attributes={smartBtnIconSize} |
| 785 |
attributesKey={"smartBtnIconSize"} |
| 786 |
setAttributes={setAttributes} |
| 787 |
units={["px", "Em"]} |
| 788 |
defaultValue={{ unit: "px", value: 8 }} |
| 789 |
max={100} |
| 790 |
/> |
| 791 |
{buttonLabelEnable && ( |
| 792 |
<SPRangeControl |
| 793 |
label={__("Icon Gap", "post-carousel")} |
| 794 |
attributes={iconGap} |
| 795 |
attributesKey={"iconGap"} |
| 796 |
setAttributes={setAttributes} |
| 797 |
units={["px", "Em"]} |
| 798 |
defaultValue={{ |
| 799 |
unit: "px", |
| 800 |
value: 8, |
| 801 |
}} |
| 802 |
max={100} |
| 803 |
/> |
| 804 |
)} |
| 805 |
|
| 806 |
<SelectField |
| 807 |
label={__("Icon Position", "post-carousel")} |
| 808 |
attributes={iconPosition} |
| 809 |
attributesKey={"iconPosition"} |
| 810 |
setAttributes={setAttributes} |
| 811 |
items={[...iconPositionItems]} |
| 812 |
flexStyle={true} |
| 813 |
/> |
| 814 |
<SPToggleGroupControl |
| 815 |
attributes={iconColorState} |
| 816 |
onClick={(newValue) => setIconColorState(newValue)} |
| 817 |
items={[ |
| 818 |
{ label: "Normal", value: "normal" }, |
| 819 |
{ label: "Hover", value: "hover" }, |
| 820 |
]} |
| 821 |
/> |
| 822 |
{"normal" === iconColorState ? ( |
| 823 |
<> |
| 824 |
<SpColorPicker |
| 825 |
label={__("Color", "post-carousel")} |
| 826 |
value={smartBtnIconColor.color} |
| 827 |
onChange={(newValue) => |
| 828 |
setAttributes({ |
| 829 |
smartBtnIconColor: { |
| 830 |
...smartBtnIconColor, |
| 831 |
color: newValue, |
| 832 |
}, |
| 833 |
}) |
| 834 |
} |
| 835 |
/> |
| 836 |
</> |
| 837 |
) : ( |
| 838 |
<> |
| 839 |
<SpColorPicker |
| 840 |
label={__("Hover Color", "post-carousel")} |
| 841 |
value={smartBtnIconColor.hover} |
| 842 |
onChange={(newValue) => |
| 843 |
setAttributes({ |
| 844 |
smartBtnIconColor: { |
| 845 |
...smartBtnIconColor, |
| 846 |
hover: newValue, |
| 847 |
}, |
| 848 |
}) |
| 849 |
} |
| 850 |
/> |
| 851 |
</> |
| 852 |
)} |
| 853 |
</> |
| 854 |
)} |
| 855 |
</> |
| 856 |
)} |
| 857 |
<ProInfo> |
| 858 |
<h3>Premium Only</h3> |
| 859 |
<h4>Enhance your buttons with customizable icons</h4> |
| 860 |
<ul> |
| 861 |
<li> |
| 862 |
— Add icons to buttons |
| 863 |
</li> |
| 864 |
<li> |
| 865 |
— Icon size and spacing control |
| 866 |
</li> |
| 867 |
<li> |
| 868 |
— Flexible icon positioning |
| 869 |
</li> |
| 870 |
<li> |
| 871 |
— Normal and hover color styling |
| 872 |
</li> |
| 873 |
</ul> |
| 874 |
<a href="https://wpsmartpost.com/pricing/?ref=1" target="_blank" rel="noopener noreferrer" className="sp-smart-upgrade-btn">Upgrade to Pro</a> |
| 875 |
</ProInfo> |
| 876 |
</> |
| 877 |
); |
| 878 |
}; |
| 879 |
|