| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { |
| 3 |
Layouts, |
| 4 |
SelectField, |
| 5 |
SPRangeControl, |
| 6 |
Toggle, |
| 7 |
SPToggleGroupControl, |
| 8 |
Background, |
| 9 |
InputControl, |
| 10 |
} from "../../components"; |
| 11 |
import { store as blockEditorStore } from "@wordpress/block-editor"; |
| 12 |
import useLayouts from "../../hooks/useLayouts"; |
| 13 |
import { useEffect, useRef, useState } from "@wordpress/element"; |
| 14 |
import { useDeviceType } from "../../controls/controls"; |
| 15 |
import { |
| 16 |
FlexAlignCenter, |
| 17 |
FlexAlignEnd, |
| 18 |
FlexAlignStart, |
| 19 |
FlexAlignStretch, |
| 20 |
FlexColumn, |
| 21 |
FlexColumnReverse, |
| 22 |
FlexJustifyCenter, |
| 23 |
FlexJustifyEnd, |
| 24 |
FlexJustifySpaceAround, |
| 25 |
FlexJustifySpaceBetween, |
| 26 |
FlexJustifySpaceEvenly, |
| 27 |
FlexJustifyStart, |
| 28 |
FlexNoWrap, |
| 29 |
FlexRow, |
| 30 |
FlexRowReverse, |
| 31 |
FlexWrap, |
| 32 |
} from "../../icons/icons"; |
| 33 |
import { BgIcon, GradientIcon } from "../../components/background/svgIcon"; |
| 34 |
import { layoutsColumnsWidth } from "./containerConstant"; |
| 35 |
import { useSelect, useDispatch, select } from "@wordpress/data"; |
| 36 |
import { createBlock } from "@wordpress/blocks"; |
| 37 |
import ProInfo from "../../components/proInfo/proInfo"; |
| 38 |
|
| 39 |
export const ContainerGeneralTab = ({ attributes, setAttributes }) => { |
| 40 |
const { |
| 41 |
columns, |
| 42 |
blockName, |
| 43 |
blockClientId, |
| 44 |
layerLayoutNo, |
| 45 |
layout, |
| 46 |
containerLayer, |
| 47 |
containerWidth, |
| 48 |
containerCustomWidth, |
| 49 |
contentWidth, |
| 50 |
contentHeightType, |
| 51 |
containerMinHeight, |
| 52 |
columnsGap, |
| 53 |
rowGap, |
| 54 |
equalHeight, |
| 55 |
htmlTag, |
| 56 |
containerOverflow, |
| 57 |
columnsTablet, |
| 58 |
columnsMobile, |
| 59 |
} = attributes; |
| 60 |
|
| 61 |
const deviceType = useDeviceType(); |
| 62 |
const deviceColumn = columns || "multi-row"; |
| 63 |
const layouts = useLayouts(`${blockName}-column-${deviceColumn}`, layout); |
| 64 |
const innerBlocks = useSelect( |
| 65 |
(select) => select(blockEditorStore).getBlocks(blockClientId), |
| 66 |
[blockClientId, columns, layout] |
| 67 |
); |
| 68 |
const { updateBlockAttributes, replaceInnerBlocks } = useDispatch(blockEditorStore); |
| 69 |
|
| 70 |
const layoutChangeHandler = (newValue) => { |
| 71 |
if (newValue === layout) { |
| 72 |
return; |
| 73 |
} |
| 74 |
|
| 75 |
setAttributes({ layout: newValue }); |
| 76 |
}; |
| 77 |
|
| 78 |
const onColumnsChangeHandler = (newValue, key) => { |
| 79 |
|
| 80 |
setAttributes({ [key]: newValue }); |
| 81 |
|
| 82 |
if (newValue === columns) { |
| 83 |
return; |
| 84 |
} |
| 85 |
// If child block is less then columns value then create and add a new child block. |
| 86 |
if (newValue > innerBlocks?.length && "Desktop" === deviceType) { |
| 87 |
const updatedBlocks = []; |
| 88 |
for (let index = 0; index < newValue; index++) { |
| 89 |
const existingBlock = innerBlocks[index]; |
| 90 |
if (existingBlock) { |
| 91 |
const updatedAttributes = { |
| 92 |
...existingBlock.attributes, |
| 93 |
}; |
| 94 |
const updatedBlock = createBlock( |
| 95 |
existingBlock.name, |
| 96 |
updatedAttributes, |
| 97 |
existingBlock.innerBlocks // preserve nested content. |
| 98 |
); |
| 99 |
updatedBlocks.push(updatedBlock); |
| 100 |
} else { |
| 101 |
updatedBlocks.push( |
| 102 |
createBlock("sp-smart-post-show/column", { |
| 103 |
id: `sp-smart-column-${101 + index}`, |
| 104 |
}) |
| 105 |
); |
| 106 |
} |
| 107 |
} |
| 108 |
replaceInnerBlocks(blockClientId, updatedBlocks, false); |
| 109 |
} |
| 110 |
}; |
| 111 |
|
| 112 |
useEffect(() => { |
| 113 |
const indexNo = layerLayoutNo !== "" ? layerLayoutNo : 0; |
| 114 |
if (containerLayer && layout === "") { |
| 115 |
setAttributes({ layout: layouts[indexNo]?.value }); |
| 116 |
} |
| 117 |
}, []); |
| 118 |
useEffect(() => { |
| 119 |
const matchLayout = layouts?.some((item) => item.value === layout); |
| 120 |
if (!matchLayout && layouts && columns) { |
| 121 |
setAttributes({ layout: layouts[0]?.value }); |
| 122 |
} |
| 123 |
}, [layouts]); |
| 124 |
|
| 125 |
|
| 126 |
const columnsKey = { |
| 127 |
Desktop: "columns", |
| 128 |
Tablet: "columnsTablet", |
| 129 |
Mobile: "columnsMobile", |
| 130 |
} |
| 131 |
|
| 132 |
const columnsValue = { |
| 133 |
Desktop: columns, |
| 134 |
Tablet: columnsTablet, |
| 135 |
Mobile: columnsMobile, |
| 136 |
} |
| 137 |
const onContainerWidthHandler = ( newValue ) => { |
| 138 |
if ( newValue === containerWidth ) { return; } |
| 139 |
const alignValue = newValue === "full-width" ? "full" : "none"; |
| 140 |
setAttributes({ |
| 141 |
containerWidth: newValue, |
| 142 |
align: alignValue, |
| 143 |
}) |
| 144 |
} |
| 145 |
|
| 146 |
return ( |
| 147 |
<> |
| 148 |
{!containerLayer.includes("layer-multi-row") && ( |
| 149 |
<SPRangeControl |
| 150 |
key={deviceType} |
| 151 |
label={__("Columns", "post-carousel")} |
| 152 |
attributes={columnsValue[deviceType]} |
| 153 |
attributesKey={columnsKey[deviceType]} |
| 154 |
setAttributes={setAttributes} |
| 155 |
max={12} |
| 156 |
min={1} |
| 157 |
// defaultValue={{ value: 3 }} |
| 158 |
resetIcon={false} |
| 159 |
onValueChange={({ value }) => onColumnsChangeHandler(value, columnsKey[deviceType])} |
| 160 |
responsiveIcon={true} |
| 161 |
/> |
| 162 |
)} |
| 163 |
{layouts?.length > 0 && ( |
| 164 |
<Layouts |
| 165 |
label={__("Layouts", "post-carousel")} |
| 166 |
attributes={layout} |
| 167 |
attributesKey={"layout"} |
| 168 |
setAttributes={setAttributes} |
| 169 |
items={layouts} |
| 170 |
grid={3} |
| 171 |
onChange={layoutChangeHandler} |
| 172 |
/> |
| 173 |
)} |
| 174 |
<SPToggleGroupControl |
| 175 |
label={__("Container Width", "post-carousel")} |
| 176 |
attributes={containerWidth} |
| 177 |
attributesKey={"containerWidth"} |
| 178 |
setAttributes={setAttributes} |
| 179 |
items={[ |
| 180 |
{ label: "Full Width", value: "full-width" }, |
| 181 |
{ label: "Boxed", value: "boxed" }, |
| 182 |
]} |
| 183 |
onClick={ onContainerWidthHandler } |
| 184 |
/> |
| 185 |
{"boxed" === containerWidth && ( |
| 186 |
<SPRangeControl |
| 187 |
label={__("Container Width", "post-carousel")} |
| 188 |
attributes={containerCustomWidth} |
| 189 |
attributesKey={"containerCustomWidth"} |
| 190 |
setAttributes={setAttributes} |
| 191 |
units={["px", "%", "em"]} |
| 192 |
max={1600} |
| 193 |
defaultValue={{ unit: "px", value: "" }} |
| 194 |
/> |
| 195 |
)} |
| 196 |
<SPRangeControl |
| 197 |
label={__("Content Width", "post-carousel")} |
| 198 |
attributes={contentWidth} |
| 199 |
attributesKey={"contentWidth"} |
| 200 |
setAttributes={setAttributes} |
| 201 |
units={["px", "%", "em"]} |
| 202 |
max={1400} |
| 203 |
defaultValue={{ unit: "px", value: "" }} |
| 204 |
/> |
| 205 |
<SelectField |
| 206 |
label={__("Container Height", "post-carousel")} |
| 207 |
attributes={contentHeightType} |
| 208 |
attributesKey={"contentHeightType"} |
| 209 |
setAttributes={setAttributes} |
| 210 |
defaultOption={true} |
| 211 |
items={[ |
| 212 |
{ label: "Fit to Screen", value: "fit-to-screen" }, |
| 213 |
{ label: "Min Height", value: "min-height" }, |
| 214 |
]} |
| 215 |
/> |
| 216 |
{contentHeightType === "min-height" && ( |
| 217 |
<SPRangeControl |
| 218 |
label={__("Container Min Height", "post-carousel")} |
| 219 |
attributes={containerMinHeight} |
| 220 |
attributesKey={"containerMinHeight"} |
| 221 |
setAttributes={setAttributes} |
| 222 |
units={["px", "%", "em"]} |
| 223 |
max={1400} |
| 224 |
defaultValue={{ unit: "px", value: 300 }} |
| 225 |
/> |
| 226 |
)} |
| 227 |
{innerBlocks.length > 1 && ( |
| 228 |
<> |
| 229 |
<SPRangeControl |
| 230 |
label={__("Column Gap", "post-carousel")} |
| 231 |
attributes={columnsGap} |
| 232 |
attributesKey={"columnsGap"} |
| 233 |
setAttributes={setAttributes} |
| 234 |
units={["px"]} |
| 235 |
max={200} |
| 236 |
defaultValue={{ unit: "px", value: 16 }} |
| 237 |
/> |
| 238 |
<SPRangeControl |
| 239 |
label={__("Row Gap", "post-carousel")} |
| 240 |
attributes={rowGap} |
| 241 |
attributesKey={"rowGap"} |
| 242 |
setAttributes={setAttributes} |
| 243 |
units={["px", "%", "em"]} |
| 244 |
max={200} |
| 245 |
defaultValue={{ unit: "px", value: 16 }} |
| 246 |
/> |
| 247 |
</> |
| 248 |
)} |
| 249 |
<Toggle |
| 250 |
label={__("Equal Height", "post-carousel")} |
| 251 |
attributes={equalHeight} |
| 252 |
attributesKey={"equalHeight"} |
| 253 |
setAttributes={setAttributes} |
| 254 |
/> |
| 255 |
<SelectField |
| 256 |
label={__("HTML Tag", "post-carousel")} |
| 257 |
attributes={htmlTag} |
| 258 |
attributesKey={"htmlTag"} |
| 259 |
setAttributes={setAttributes} |
| 260 |
items={[ |
| 261 |
{ label: "Div", value: "div" }, |
| 262 |
{ label: "Header", value: "header" }, |
| 263 |
{ label: "Footer", value: "footer" }, |
| 264 |
{ label: "Main", value: "main" }, |
| 265 |
{ label: "Article", value: "article" }, |
| 266 |
{ label: "Section", value: "section" }, |
| 267 |
{ label: "Aside", value: "aside" }, |
| 268 |
{ label: "Figure", value: "figure" }, |
| 269 |
{ label: "Figcaption", value: "figcaption" }, |
| 270 |
{ label: "Summary", value: "summary" }, |
| 271 |
{ label: "nav", value: "nav" }, |
| 272 |
]} |
| 273 |
/> |
| 274 |
<SPToggleGroupControl |
| 275 |
label={__("Overflow", "post-carousel")} |
| 276 |
attributes={containerOverflow} |
| 277 |
attributesKey={"containerOverflow"} |
| 278 |
setAttributes={setAttributes} |
| 279 |
items={[ |
| 280 |
{ label: "Visible", value: "visible" }, |
| 281 |
{ label: "Hidden", value: "hidden" }, |
| 282 |
{ label: "Auto", value: "auto" }, |
| 283 |
]} |
| 284 |
/> |
| 285 |
</> |
| 286 |
); |
| 287 |
}; |
| 288 |
|
| 289 |
export const ContainerFlexProperties = ({ attributes, setAttributes }) => { |
| 290 |
const { containerFlexDirection, containerJustifyContent, containerFlexWrap, containerAlignItem, blockClientId } = |
| 291 |
attributes; |
| 292 |
|
| 293 |
const deviceType = useDeviceType(); |
| 294 |
const { getBlockOrder } = useSelect((select) => select("core/block-editor")); |
| 295 |
const { updateBlockAttributes } = useDispatch("core/block-editor"); |
| 296 |
|
| 297 |
const handleFlexDir = (value) => { |
| 298 |
if (value === containerFlexDirection?.device?.[deviceType]) { |
| 299 |
return; |
| 300 |
} |
| 301 |
|
| 302 |
const childBlocks = getBlockOrder(blockClientId); |
| 303 |
|
| 304 |
if (["column", "column-reverse"].includes(value)) { |
| 305 |
childBlocks?.forEach((childBlock) => { |
| 306 |
updateBlockAttributes(childBlock, { |
| 307 |
// columnWidth: { |
| 308 |
// device: { Desktop: 100, Tablet: 100, Mobile: 100 }, |
| 309 |
// unit: { Desktop: "%", Tablet: "%", Mobile: "%" }, |
| 310 |
// }, |
| 311 |
}); |
| 312 |
}); |
| 313 |
} else { |
| 314 |
const colWidth = 100 / childBlocks?.length; |
| 315 |
childBlocks?.forEach((childBlock) => { |
| 316 |
updateBlockAttributes(childBlock, { |
| 317 |
// columnWidth: { |
| 318 |
// device: { |
| 319 |
// Desktop: colWidth, |
| 320 |
// Tablet: colWidth, |
| 321 |
// Mobile: 100, |
| 322 |
// }, |
| 323 |
// unit: { Desktop: "%", Tablet: "%", Mobile: "%" }, |
| 324 |
// }, |
| 325 |
}); |
| 326 |
}); |
| 327 |
} |
| 328 |
setAttributes({ |
| 329 |
containerFlexDirection: { |
| 330 |
...containerFlexDirection, |
| 331 |
device: { |
| 332 |
...containerFlexDirection.device, |
| 333 |
[deviceType]: value, |
| 334 |
}, |
| 335 |
}, |
| 336 |
}); |
| 337 |
}; |
| 338 |
|
| 339 |
const onFlexWarpHandler = (value) => { |
| 340 |
if (value === containerFlexWrap?.device?.[deviceType]) { |
| 341 |
return; |
| 342 |
} |
| 343 |
const childBlocks = getBlockOrder(blockClientId); |
| 344 |
const updateColWidth = parseFloat((100 / childBlocks?.length).toFixed(2)); |
| 345 |
|
| 346 |
if (["nowrap"].includes(value) && ["row", "row-reverse"].includes(containerFlexDirection?.device?.[deviceType])) { |
| 347 |
childBlocks?.forEach((childBlock) => { |
| 348 |
updateBlockAttributes(childBlock, { |
| 349 |
// columnWidth: { |
| 350 |
// device: { |
| 351 |
// Desktop: updateColWidth, |
| 352 |
// Tablet: updateColWidth, |
| 353 |
// Mobile: 100 |
| 354 |
// }, |
| 355 |
// unit: { Desktop: "%", Tablet: "%", Mobile: "%" }, |
| 356 |
// }, |
| 357 |
}); |
| 358 |
}); |
| 359 |
} |
| 360 |
setAttributes({ |
| 361 |
containerFlexWrap: { |
| 362 |
...containerFlexWrap, |
| 363 |
device: { |
| 364 |
...containerFlexWrap.device, |
| 365 |
[deviceType]: value, |
| 366 |
}, |
| 367 |
}, |
| 368 |
}); |
| 369 |
}; |
| 370 |
|
| 371 |
return ( |
| 372 |
<> |
| 373 |
<SPToggleGroupControl |
| 374 |
label={__("Flex Direction", "post-carousel")} |
| 375 |
attributes={containerFlexDirection} |
| 376 |
attributesKey={"containerFlexDirection"} |
| 377 |
setAttributes={setAttributes} |
| 378 |
onClick={(value) => handleFlexDir(value)} |
| 379 |
items={[ |
| 380 |
{ label: <FlexRow />, value: "row", tooltip: "Row" }, |
| 381 |
{ |
| 382 |
label: <FlexColumn />, |
| 383 |
value: "column", |
| 384 |
tooltip: "Column", |
| 385 |
}, |
| 386 |
{ |
| 387 |
label: <FlexRowReverse />, |
| 388 |
value: "row-reverse", |
| 389 |
tooltip: "Row Reverse", |
| 390 |
}, |
| 391 |
{ |
| 392 |
label: <FlexColumnReverse />, |
| 393 |
value: "column-reverse", |
| 394 |
tooltip: "Column Reverse", |
| 395 |
}, |
| 396 |
]} |
| 397 |
/> |
| 398 |
<SPToggleGroupControl |
| 399 |
label={__("Justify Content", "post-carousel")} |
| 400 |
attributes={containerJustifyContent} |
| 401 |
attributesKey={"containerJustifyContent"} |
| 402 |
setAttributes={setAttributes} |
| 403 |
extraClass={ |
| 404 |
["row", "row-reverse"].includes(containerFlexDirection?.device?.[deviceType]) |
| 405 |
? " sp-svg-rotate-90-reverse" |
| 406 |
: "" |
| 407 |
} |
| 408 |
items={[ |
| 409 |
{ |
| 410 |
label: <FlexJustifyStart />, |
| 411 |
value: "flex-start", |
| 412 |
tooltip: "Flex Start", |
| 413 |
}, |
| 414 |
{ |
| 415 |
label: <FlexJustifyCenter />, |
| 416 |
value: "center", |
| 417 |
tooltip: "Center", |
| 418 |
}, |
| 419 |
{ |
| 420 |
label: <FlexJustifyEnd />, |
| 421 |
value: "flex-end", |
| 422 |
tooltip: "Flex End", |
| 423 |
}, |
| 424 |
{ |
| 425 |
label: <FlexJustifySpaceBetween />, |
| 426 |
value: "space-between", |
| 427 |
tooltip: "Space Between", |
| 428 |
}, |
| 429 |
{ |
| 430 |
label: <FlexJustifySpaceAround />, |
| 431 |
value: "space-around", |
| 432 |
tooltip: "Space Around", |
| 433 |
}, |
| 434 |
{ |
| 435 |
label: <FlexJustifySpaceEvenly />, |
| 436 |
value: "space-evenly", |
| 437 |
tooltip: "Space Evenly", |
| 438 |
}, |
| 439 |
]} |
| 440 |
/> |
| 441 |
<SPToggleGroupControl |
| 442 |
label={__("Flex Wrap", "post-carousel")} |
| 443 |
attributes={containerFlexWrap} |
| 444 |
attributesKey={"containerFlexWrap"} |
| 445 |
setAttributes={setAttributes} |
| 446 |
onClick={(value) => onFlexWarpHandler(value)} |
| 447 |
items={[ |
| 448 |
{ label: <FlexWrap />, value: "wrap", tooltip: "Wrap" }, |
| 449 |
{ |
| 450 |
label: <FlexNoWrap />, |
| 451 |
value: "nowrap", |
| 452 |
tooltip: "No Wrap", |
| 453 |
}, |
| 454 |
// { |
| 455 |
// label: <FlexWrapReverse />, |
| 456 |
// value: 'wrap-reverse', |
| 457 |
// tooltip: 'Wrap Reverse', |
| 458 |
// }, |
| 459 |
]} |
| 460 |
/> |
| 461 |
<SPToggleGroupControl |
| 462 |
label={__("Align Items", "post-carousel")} |
| 463 |
attributes={containerAlignItem} |
| 464 |
attributesKey={"containerAlignItem"} |
| 465 |
setAttributes={setAttributes} |
| 466 |
extraClass={ |
| 467 |
["row", "row-reverse"].includes(containerFlexDirection?.device?.[deviceType]) |
| 468 |
? " sp-svg-rotate-90" |
| 469 |
: "" |
| 470 |
} |
| 471 |
items={[ |
| 472 |
{ |
| 473 |
label: <FlexAlignStart />, |
| 474 |
value: "flex-start", |
| 475 |
tooltip: "Flex Start", |
| 476 |
}, |
| 477 |
{ |
| 478 |
label: <FlexAlignCenter />, |
| 479 |
value: "center", |
| 480 |
tooltip: "Center", |
| 481 |
}, |
| 482 |
{ |
| 483 |
label: <FlexAlignEnd />, |
| 484 |
value: "flex-end", |
| 485 |
tooltip: "Flex End", |
| 486 |
}, |
| 487 |
{ |
| 488 |
label: <FlexAlignStretch />, |
| 489 |
value: "stretch", |
| 490 |
tooltip: "Stretch", |
| 491 |
}, |
| 492 |
]} |
| 493 |
/> |
| 494 |
</> |
| 495 |
); |
| 496 |
}; |
| 497 |
|
| 498 |
export const ContainerShapeDivider = ({ attributes, setAttributes }) => { |
| 499 |
const { |
| 500 |
containerShapeDivider, |
| 501 |
containerTopDividerType, |
| 502 |
containerBottomDividerType, |
| 503 |
shapeDividerBgColorTop, |
| 504 |
shapeDividerWidthTop, |
| 505 |
shapeDividerHeightTop, |
| 506 |
shapeDividerFlipTop, |
| 507 |
shapeDividerBringToFrontTop, |
| 508 |
shapeDividerBgColorBottom, |
| 509 |
shapeDividerWidthBottom, |
| 510 |
shapeDividerHeightBottom, |
| 511 |
shapeDividerFlipBottom, |
| 512 |
shapeDividerBringToFrontBottom, |
| 513 |
} = attributes; |
| 514 |
|
| 515 |
const dividerType = [ |
| 516 |
{ label: "None", value: "none" }, |
| 517 |
{ label: "Waves", value: "waves" }, |
| 518 |
{ label: "Mountains (Pro)", value: "mountains", disabled: true }, |
| 519 |
{ label: "Drops (Pro)", value: "drops", disabled: true }, |
| 520 |
{ label: "Clouds (Pro)", value: "clouds", disabled: true }, |
| 521 |
{ label: "Zigzag (Pro)", value: "zigzag", disabled: true }, |
| 522 |
{ label: "Pyramids (Pro)", value: "pyramids", disabled: true }, |
| 523 |
{ label: "Triangle (Pro)", value: "triangle", disabled: true }, |
| 524 |
{ label: "Triangle Asymmetrical (Pro)", value: "triangle-asymmetrical", disabled: true }, |
| 525 |
{ label: "Tilt (Pro)", value: "tilt", disabled: true }, |
| 526 |
{ label: "Tilt Opacity (Pro)", value: "tilt-opacity", disabled: true }, |
| 527 |
{ label: "Fan Opacity (Pro)", value: "fan-opacity", disabled: true }, |
| 528 |
{ label: "Curve (Pro)", value: "curve", disabled: true }, |
| 529 |
{ label: "Curve Asymmetrical (Pro)", value: "curve-asymmetrical", disabled: true }, |
| 530 |
{ label: "Waves Brush (Pro)", value: "waves-brush", disabled: true }, |
| 531 |
{ label: "Waves Pattern (Pro)", value: "waves-pattern", disabled: true }, |
| 532 |
{ label: "Arrow (Pro)", value: "arrow", disabled: true }, |
| 533 |
{ label: "Arrow Split (Pro)", value: "arrow-split", disabled: true }, |
| 534 |
{ label: "Book (Pro)", value: "book", disabled: true }, |
| 535 |
] |
| 536 |
|
| 537 |
return ( |
| 538 |
<> |
| 539 |
<SPToggleGroupControl |
| 540 |
label={__("Shape Divider", "post-carousel")} |
| 541 |
attributes={containerShapeDivider} |
| 542 |
attributesKey={"containerShapeDivider"} |
| 543 |
setAttributes={setAttributes} |
| 544 |
items={[ |
| 545 |
{ label: "Top", value: "top" }, |
| 546 |
{ label: "Bottom", value: "bottom" }, |
| 547 |
]} |
| 548 |
/> |
| 549 |
{"top" === containerShapeDivider && ( |
| 550 |
<SelectField |
| 551 |
label={__("Divider Type", "post-carousel")} |
| 552 |
attributes={containerTopDividerType} |
| 553 |
attributesKey={"containerTopDividerType"} |
| 554 |
setAttributes={setAttributes} |
| 555 |
items={dividerType} |
| 556 |
/> |
| 557 |
)} |
| 558 |
{"bottom" === containerShapeDivider && ( |
| 559 |
<SelectField |
| 560 |
label={__("Divider Type", "post-carousel")} |
| 561 |
attributes={containerBottomDividerType} |
| 562 |
attributesKey={"containerBottomDividerType"} |
| 563 |
setAttributes={setAttributes} |
| 564 |
items={dividerType} |
| 565 |
/> |
| 566 |
)} |
| 567 |
{"top" === containerShapeDivider && "none" !== containerTopDividerType && ( |
| 568 |
<> |
| 569 |
<Background |
| 570 |
label={__("Color Type", "post-carousel")} |
| 571 |
attributes={shapeDividerBgColorTop} |
| 572 |
attributesKey={"shapeDividerBgColorTop"} |
| 573 |
setAttributes={setAttributes} |
| 574 |
colorType={"color"} |
| 575 |
items={[ |
| 576 |
{ |
| 577 |
label: <BgIcon />, |
| 578 |
value: "bgColor", |
| 579 |
tooltip: "Solid", |
| 580 |
}, |
| 581 |
{ |
| 582 |
label: <GradientIcon />, |
| 583 |
value: "gradient", |
| 584 |
tooltip: "Gradient", |
| 585 |
}, |
| 586 |
]} |
| 587 |
/> |
| 588 |
<SPRangeControl |
| 589 |
label={__("Width", "post-carousel")} |
| 590 |
attributes={shapeDividerWidthTop} |
| 591 |
attributesKey={"shapeDividerWidthTop"} |
| 592 |
setAttributes={setAttributes} |
| 593 |
units={["px", "%", "em"]} |
| 594 |
max={1400} |
| 595 |
defaultValue={{ unit: "px", value: 100 }} |
| 596 |
pro={true} |
| 597 |
/> |
| 598 |
<SPRangeControl |
| 599 |
label={__("Height", "post-carousel")} |
| 600 |
attributes={shapeDividerHeightTop} |
| 601 |
attributesKey={"shapeDividerHeightTop"} |
| 602 |
setAttributes={setAttributes} |
| 603 |
units={["px", "%", "em"]} |
| 604 |
max={1400} |
| 605 |
defaultValue={{ unit: "px", value: 100 }} |
| 606 |
pro={true} |
| 607 |
/> |
| 608 |
<Toggle |
| 609 |
label={__("Flip", "post-carousel")} |
| 610 |
attributes={shapeDividerFlipTop} |
| 611 |
attributesKey={"shapeDividerFlipTop"} |
| 612 |
setAttributes={setAttributes} |
| 613 |
pro={true} |
| 614 |
/> |
| 615 |
<Toggle |
| 616 |
label={__("Bring to Front", "post-carousel")} |
| 617 |
attributes={shapeDividerBringToFrontTop} |
| 618 |
attributesKey={"shapeDividerBringToFrontTop"} |
| 619 |
setAttributes={setAttributes} |
| 620 |
pro={true} |
| 621 |
/> |
| 622 |
</> |
| 623 |
)} |
| 624 |
{"bottom" === containerShapeDivider && "none" !== containerBottomDividerType && ( |
| 625 |
<> |
| 626 |
<Background |
| 627 |
label={__("Color Type", "post-carousel")} |
| 628 |
attributes={shapeDividerBgColorBottom} |
| 629 |
attributesKey={"shapeDividerBgColorBottom"} |
| 630 |
setAttributes={setAttributes} |
| 631 |
colorType={"color"} |
| 632 |
items={[ |
| 633 |
{ |
| 634 |
label: <BgIcon />, |
| 635 |
value: "bgColor", |
| 636 |
tooltip: "Solid", |
| 637 |
}, |
| 638 |
{ |
| 639 |
label: <GradientIcon />, |
| 640 |
value: "gradient", |
| 641 |
tooltip: "Gradient", |
| 642 |
}, |
| 643 |
]} |
| 644 |
/> |
| 645 |
<SPRangeControl |
| 646 |
label={__("Width", "post-carousel")} |
| 647 |
attributes={shapeDividerWidthBottom} |
| 648 |
attributesKey={"shapeDividerWidthBottom"} |
| 649 |
setAttributes={setAttributes} |
| 650 |
units={["px", "%", "em"]} |
| 651 |
max={1400} |
| 652 |
defaultValue={{ unit: "px", value: 100 }} |
| 653 |
/> |
| 654 |
<SPRangeControl |
| 655 |
label={__("Height", "post-carousel")} |
| 656 |
attributes={shapeDividerHeightBottom} |
| 657 |
attributesKey={"shapeDividerHeightBottom"} |
| 658 |
setAttributes={setAttributes} |
| 659 |
units={["px", "%", "em"]} |
| 660 |
max={1400} |
| 661 |
defaultValue={{ unit: "px", value: 100 }} |
| 662 |
/> |
| 663 |
<Toggle |
| 664 |
label={__("Flip", "post-carousel")} |
| 665 |
attributes={shapeDividerFlipBottom} |
| 666 |
attributesKey={"shapeDividerFlipBottom"} |
| 667 |
setAttributes={setAttributes} |
| 668 |
/> |
| 669 |
<Toggle |
| 670 |
label={__("Bring to Front", "post-carousel")} |
| 671 |
attributes={shapeDividerBringToFrontBottom} |
| 672 |
attributesKey={"shapeDividerBringToFrontBottom"} |
| 673 |
setAttributes={setAttributes} |
| 674 |
/> |
| 675 |
</> |
| 676 |
)} |
| 677 |
<ProInfo> |
| 678 |
<h3>Premium Only</h3> |
| 679 |
<h4>Unlock advanced shape divider controls for more flexible section styling.</h4> |
| 680 |
<ul> |
| 681 |
<li> |
| 682 |
— 18+ Unique Divider Styles |
| 683 |
</li> |
| 684 |
<li> |
| 685 |
— Custom width and height adjustment |
| 686 |
</li> |
| 687 |
<li> |
| 688 |
— Flip shape orientation |
| 689 |
</li> |
| 690 |
<li> |
| 691 |
— Bring divider to front |
| 692 |
</li> |
| 693 |
<li> |
| 694 |
— Enhanced layout positioning |
| 695 |
</li> |
| 696 |
</ul> |
| 697 |
<a href="https://wpsmartpost.com/pricing/?ref=1" target="_blank" rel="noopener noreferrer" className="sp-smart-upgrade-btn">Upgrade to Pro</a> |
| 698 |
</ProInfo> |
| 699 |
</> |
| 700 |
); |
| 701 |
}; |
| 702 |
|
| 703 |
export const ContainerAdvancedGeneralTab = ({ attributes, setAttributes }) => { |
| 704 |
const { advanceZIndex, advanceWrapperLink, advanceWrapperLinkUrl, advanceWrapperLinkNewTab } = attributes; |
| 705 |
|
| 706 |
return ( |
| 707 |
<> |
| 708 |
<InputControl |
| 709 |
label={__("Z-Index", "post-carousel")} |
| 710 |
attributes={advanceZIndex} |
| 711 |
attributesKey={"advanceZIndex"} |
| 712 |
setAttributes={setAttributes} |
| 713 |
type="number" |
| 714 |
flex={true} |
| 715 |
/> |
| 716 |
<Toggle |
| 717 |
label={__("Wrapper Link", "post-carousel")} |
| 718 |
attributes={advanceWrapperLink} |
| 719 |
attributesKey={"advanceWrapperLink"} |
| 720 |
setAttributes={setAttributes} |
| 721 |
/> |
| 722 |
{advanceWrapperLink && ( |
| 723 |
<> |
| 724 |
<InputControl |
| 725 |
label={__("Wrapper Link URL", "post-carousel")} |
| 726 |
attributes={advanceWrapperLinkUrl} |
| 727 |
attributesKey={"advanceWrapperLinkUrl"} |
| 728 |
setAttributes={setAttributes} |
| 729 |
inputType="url" |
| 730 |
flex={false} |
| 731 |
placeholder={"https://example.com"} |
| 732 |
/> |
| 733 |
<Toggle |
| 734 |
label={__("Link Open in New Tab", "post-carousel")} |
| 735 |
attributes={advanceWrapperLinkNewTab} |
| 736 |
attributesKey={"advanceWrapperLinkNewTab"} |
| 737 |
setAttributes={setAttributes} |
| 738 |
/> |
| 739 |
</> |
| 740 |
)} |
| 741 |
</> |
| 742 |
); |
| 743 |
}; |
| 744 |
|