| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { Toggle, Layouts, SPRangeControl, SelectField, InputControl } from "../../components"; |
| 3 |
import { openLinksOptions } from "../../controls/constants"; |
| 4 |
import useLayouts from "../../hooks/useLayouts"; |
| 5 |
import { AlignCenter, AlignLeft, AlignRight } from "../../icons/icons"; |
| 6 |
import ContentOrientations from "../shared/templates/templates-parts/contentOrientations"; |
| 7 |
import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; |
| 8 |
import { useMemo } from "@wordpress/element"; |
| 9 |
import ProInfo from "../../components/proInfo/proInfo"; |
| 10 |
|
| 11 |
export const PostTimelineGeneralTab = ({ attributes, setAttributes }) => { |
| 12 |
const { |
| 13 |
equalHeightEnable, |
| 14 |
blockName, |
| 15 |
generalLinkOpen, |
| 16 |
carouselGap, |
| 17 |
timelineLayout, |
| 18 |
preloaderEnable, |
| 19 |
contentOrientation, |
| 20 |
contentAlignment, |
| 21 |
postCardPadding, |
| 22 |
postCardBorder, |
| 23 |
postCardBorderWidth, |
| 24 |
contentAreaPadding, |
| 25 |
liveFilterEnable, |
| 26 |
postLimit, |
| 27 |
} = attributes; |
| 28 |
const layouts = useLayouts(blockName, timelineLayout); |
| 29 |
|
| 30 |
const orientation_five = useMemo( |
| 31 |
() => ({ |
| 32 |
postCardPadding: { |
| 33 |
...postCardPadding, |
| 34 |
device: { |
| 35 |
...postCardPadding.device, |
| 36 |
Desktop: { |
| 37 |
top: 15, |
| 38 |
right: 15, |
| 39 |
bottom: 15, |
| 40 |
left: 15, |
| 41 |
}, |
| 42 |
}, |
| 43 |
}, |
| 44 |
postCardBorder: { |
| 45 |
...postCardBorder, |
| 46 |
style: "solid", |
| 47 |
color: "#dddddd", |
| 48 |
}, |
| 49 |
postCardBorderWidth: { |
| 50 |
...postCardBorderWidth, |
| 51 |
device: { |
| 52 |
...postCardBorderWidth.device, |
| 53 |
Desktop: { top: 1, right: 1, bottom: 1, left: 1 }, |
| 54 |
}, |
| 55 |
}, |
| 56 |
contentAlignment: "left", |
| 57 |
contentAreaPadding: { |
| 58 |
...contentAreaPadding, |
| 59 |
device: { |
| 60 |
...contentAreaPadding.device, |
| 61 |
Desktop: { top: "", right: "", bottom: "", left: "" }, |
| 62 |
}, |
| 63 |
}, |
| 64 |
}), |
| 65 |
[] |
| 66 |
); |
| 67 |
const orientation_other = useMemo( |
| 68 |
() => ({ |
| 69 |
postCardPadding: { |
| 70 |
...postCardPadding, |
| 71 |
device: { |
| 72 |
...postCardPadding.device, |
| 73 |
Desktop: { top: "", right: "", bottom: "", left: "" }, |
| 74 |
}, |
| 75 |
}, |
| 76 |
postCardBorder: { ...postCardBorder, style: "none" }, |
| 77 |
contentAlignment: "left", |
| 78 |
contentAreaPadding: { |
| 79 |
...contentAreaPadding, |
| 80 |
device: { |
| 81 |
...contentAreaPadding.device, |
| 82 |
Desktop: { top: 0, right: 20, bottom: 15, left: 20 }, |
| 83 |
}, |
| 84 |
}, |
| 85 |
}), |
| 86 |
[] |
| 87 |
); |
| 88 |
|
| 89 |
const orientationHandler = (newValue) => { |
| 90 |
if (newValue === contentOrientation) return; |
| 91 |
|
| 92 |
const newData = { |
| 93 |
...(newValue === "orientation_five" ? orientation_five : orientation_other), |
| 94 |
contentOrientation: newValue, |
| 95 |
}; |
| 96 |
setAttributes(newData); |
| 97 |
}; |
| 98 |
|
| 99 |
return ( |
| 100 |
<> |
| 101 |
<Layouts |
| 102 |
label={__("Timeline Layout", "post-carousel")} |
| 103 |
attributes={timelineLayout} |
| 104 |
attributesKey={"timelineLayout"} |
| 105 |
setAttributes={setAttributes} |
| 106 |
displayActive={true} |
| 107 |
showDemoTitle={true} |
| 108 |
grid={3} |
| 109 |
items={layouts} |
| 110 |
/> |
| 111 |
<ContentOrientations |
| 112 |
label={__("Content Orientation", "post-carousel")} |
| 113 |
attributes={contentOrientation} |
| 114 |
setAttributes={setAttributes} |
| 115 |
attributesKey={"contentOrientation"} |
| 116 |
blockName={blockName} |
| 117 |
onChange={orientationHandler} |
| 118 |
/> |
| 119 |
{/* <Toggle |
| 120 |
label={ __( 'Smart Frontend Filter', 'post-carousel' ) } |
| 121 |
attributes={ liveFilterEnable } |
| 122 |
setAttributes={ setAttributes } |
| 123 |
attributesKey={ 'liveFilterEnable' } |
| 124 |
/> */} |
| 125 |
<InputControl |
| 126 |
label={__("Number of Slides", "post-carousel")} |
| 127 |
className="sp-smart-limit-field" |
| 128 |
ajax={true} |
| 129 |
attributes={postLimit} |
| 130 |
min={1} |
| 131 |
attributesKey={"postLimit"} |
| 132 |
setAttributes={setAttributes} |
| 133 |
/> |
| 134 |
<SPRangeControl |
| 135 |
label={__("Gap Between Posts", "post-carousel")} |
| 136 |
attributes={carouselGap} |
| 137 |
attributesKey={"carouselGap"} |
| 138 |
setAttributes={setAttributes} |
| 139 |
max={150} |
| 140 |
min={0} |
| 141 |
units={["PX", "%", "EM"]} |
| 142 |
defaultValue={{ unit: "px", value: 32 }} |
| 143 |
/> |
| 144 |
<SPToggleGroupControl |
| 145 |
label={__("Content Alignment", "post-carousel")} |
| 146 |
attributes={contentAlignment} |
| 147 |
attributesKey={"contentAlignment"} |
| 148 |
setAttributes={setAttributes} |
| 149 |
items={[ |
| 150 |
{ label: <AlignLeft />, value: "left" }, |
| 151 |
{ label: <AlignCenter />, value: "center" }, |
| 152 |
{ label: <AlignRight />, value: "right" }, |
| 153 |
]} |
| 154 |
/> |
| 155 |
<SelectField |
| 156 |
label={__("Link Open In", "post-carousel")} |
| 157 |
attributes={generalLinkOpen} |
| 158 |
attributesKey={"generalLinkOpen"} |
| 159 |
setAttributes={setAttributes} |
| 160 |
items={openLinksOptions} |
| 161 |
/> |
| 162 |
<Toggle |
| 163 |
label={__("Preloader", "post-carousel")} |
| 164 |
attributes={preloaderEnable} |
| 165 |
attributesKey={"preloaderEnable"} |
| 166 |
setAttributes={setAttributes} |
| 167 |
/> |
| 168 |
<Toggle |
| 169 |
label={__("Enable Equal Height", "post-carousel")} |
| 170 |
attributes={equalHeightEnable} |
| 171 |
attributesKey={"equalHeightEnable"} |
| 172 |
setAttributes={setAttributes} |
| 173 |
pro={true} |
| 174 |
/> |
| 175 |
<ProInfo> |
| 176 |
<span>Unlock exclusive layouts and advanced display controls.</span> <a href="https://wpsmartpost.com/pricing/?ref=1" target="_blank" rel="noopener noreferrer">Upgrade to Pro!</a> |
| 177 |
</ProInfo> |
| 178 |
</> |
| 179 |
); |
| 180 |
}; |
| 181 |
|
| 182 |
export const PostTimelineConnectorTab = ({ attributes, setAttributes }) => { |
| 183 |
const { timelineSize, timelineWidth, timelineHeight, timelineConnectorWidth } = attributes; |
| 184 |
|
| 185 |
return ( |
| 186 |
<> |
| 187 |
<div> |
| 188 |
<strong>Icon Source</strong> |
| 189 |
</div> |
| 190 |
<SPRangeControl |
| 191 |
label={__("Size", "post-carousel")} |
| 192 |
attributes={timelineSize} |
| 193 |
attributesKey={"timelineSize"} |
| 194 |
setAttributes={setAttributes} |
| 195 |
max={60} |
| 196 |
defaultValue={{ unit: "px", value: 16 }} |
| 197 |
/> |
| 198 |
<SPRangeControl |
| 199 |
label={__("Width", "post-carousel")} |
| 200 |
attributes={timelineWidth} |
| 201 |
attributesKey={"timelineWidth"} |
| 202 |
setAttributes={setAttributes} |
| 203 |
max={80} |
| 204 |
defaultValue={{ unit: "px", value: 32 }} |
| 205 |
/> |
| 206 |
<SPRangeControl |
| 207 |
label={__("Height", "post-carousel")} |
| 208 |
attributes={timelineHeight} |
| 209 |
attributesKey={"timelineHeight"} |
| 210 |
setAttributes={setAttributes} |
| 211 |
max={80} |
| 212 |
defaultValue={{ unit: "px", value: 32 }} |
| 213 |
/> |
| 214 |
<SPRangeControl |
| 215 |
label={__("Connector Width", "post-carousel")} |
| 216 |
attributes={timelineConnectorWidth} |
| 217 |
attributesKey={"timelineConnectorWidth"} |
| 218 |
setAttributes={setAttributes} |
| 219 |
max={20} |
| 220 |
defaultValue={{ unit: "px", value: 32 }} |
| 221 |
/> |
| 222 |
</> |
| 223 |
); |
| 224 |
}; |
| 225 |
|
| 226 |
export const PostTimelineCarouselTab = ({ attributes, setAttributes }) => { |
| 227 |
const { |
| 228 |
// postTimelineNavArrow, |
| 229 |
postTimelineAutoPlay, |
| 230 |
postTimelineAutoPlayDelay, |
| 231 |
carouselPauseOnHover, |
| 232 |
carouselDirection, |
| 233 |
carouselStyle, |
| 234 |
carouselColumn, |
| 235 |
timelineLayout, |
| 236 |
carouselSpeed, |
| 237 |
postTimelineTickerSpeed, |
| 238 |
carouselNavArrow, |
| 239 |
} = attributes; |
| 240 |
|
| 241 |
return ( |
| 242 |
<> |
| 243 |
{timelineLayout !== "timeline-three-layout-two" && ( |
| 244 |
<SPToggleGroupControl |
| 245 |
label={__("Carousel Style", "post-carousel")} |
| 246 |
attributes={carouselStyle} |
| 247 |
attributesKey={"carouselStyle"} |
| 248 |
setAttributes={setAttributes} |
| 249 |
items={[ |
| 250 |
{ label: "Standard", value: "standard" }, |
| 251 |
{ label: "Ticker (Pro)", value: "ticker", disabled: true }, |
| 252 |
]} |
| 253 |
/> |
| 254 |
)} |
| 255 |
<SPRangeControl |
| 256 |
label={__("Columns", "post-carousel")} |
| 257 |
setAttributes={setAttributes} |
| 258 |
attributes={carouselColumn} |
| 259 |
max={10} |
| 260 |
min={1} |
| 261 |
attributesKey={"carouselColumn"} |
| 262 |
defaultValue={{ unit: "", value: 3 }} |
| 263 |
/> |
| 264 |
{carouselStyle === "standard" && ( |
| 265 |
<Toggle |
| 266 |
label={__("AutoPlay", "post-carousel")} |
| 267 |
attributes={postTimelineAutoPlay} |
| 268 |
attributesKey={"postTimelineAutoPlay"} |
| 269 |
setAttributes={setAttributes} |
| 270 |
/> |
| 271 |
)} |
| 272 |
{postTimelineAutoPlay && ( |
| 273 |
<> |
| 274 |
{carouselStyle === "standard" && ( |
| 275 |
<SPRangeControl |
| 276 |
label={__("AutoPlay Delay", "post-carousel")} |
| 277 |
attributes={postTimelineAutoPlayDelay} |
| 278 |
attributesKey={"postTimelineAutoPlayDelay"} |
| 279 |
setAttributes={setAttributes} |
| 280 |
units={["ms"]} |
| 281 |
max={5000} |
| 282 |
defaultValue={{ unit: "ms", value: 2000 }} |
| 283 |
step={50} |
| 284 |
/> |
| 285 |
)} |
| 286 |
</> |
| 287 |
)} |
| 288 |
{"ticker" !== carouselStyle && ( |
| 289 |
<SPRangeControl |
| 290 |
label={__("Carousel Speed", "post-carousel")} |
| 291 |
setAttributes={setAttributes} |
| 292 |
attributes={carouselSpeed} |
| 293 |
max={5000} |
| 294 |
attributesKey={"carouselSpeed"} |
| 295 |
defaultValue={{ unit: "ms", value: 2000 }} |
| 296 |
step={50} |
| 297 |
/> |
| 298 |
)} |
| 299 |
{"ticker" === carouselStyle && ( |
| 300 |
<SPRangeControl |
| 301 |
label={__("Carousel Speed", "post-carousel")} |
| 302 |
setAttributes={setAttributes} |
| 303 |
attributes={postTimelineTickerSpeed} |
| 304 |
max={5000} |
| 305 |
attributesKey={"postTimelineTickerSpeed"} |
| 306 |
defaultValue={{ unit: "ms", value: 3000 }} |
| 307 |
step={50} |
| 308 |
/> |
| 309 |
)} |
| 310 |
{(postTimelineAutoPlay || carouselStyle === "ticker") && ( |
| 311 |
<Toggle |
| 312 |
label={__("Pause on Hover", "post-carousel")} |
| 313 |
attributes={carouselPauseOnHover} |
| 314 |
setAttributes={setAttributes} |
| 315 |
attributesKey={"carouselPauseOnHover"} |
| 316 |
/> |
| 317 |
)} |
| 318 |
{postTimelineAutoPlay && ( |
| 319 |
<> |
| 320 |
<SPToggleGroupControl |
| 321 |
label={__("Carousel Direction", "post-carousel")} |
| 322 |
attributes={carouselDirection} |
| 323 |
attributesKey={"carouselDirection"} |
| 324 |
setAttributes={setAttributes} |
| 325 |
items={[ |
| 326 |
{ label: "Right to Left", value: "right_to_left" }, |
| 327 |
{ label: "Left to Right", value: "left_to_right" }, |
| 328 |
]} |
| 329 |
/> |
| 330 |
</> |
| 331 |
)} |
| 332 |
{(carouselStyle === "standard" || timelineLayout === "timeline-three-layout-two") && ( |
| 333 |
<Toggle |
| 334 |
label={__("Navigation Arrow", "post-carousel")} |
| 335 |
attributes={carouselNavArrow} |
| 336 |
attributesKey={"carouselNavArrow"} |
| 337 |
setAttributes={setAttributes} |
| 338 |
/> |
| 339 |
)} |
| 340 |
</> |
| 341 |
); |
| 342 |
}; |
| 343 |
|