PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / blocks / post-slider-two / generalTab.js

generalTab.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/blocks/post-slider-two/generalTab.js

446 lines 11.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from "@wordpress/i18n";
2 import { Toggle, Layouts, SPRangeControl, SelectField, InputControl } from "../../components";
3 import useLayouts from "../../hooks/useLayouts";
4 import { AlignCenter, AlignLeft, AlignRight } from "../../icons/icons";
5 import { openLinksOptions } from "../../controls/constants";
6 import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl";
7 import { useDeviceType } from "../../controls/controls";
8 import ProInfo from "../../components/proInfo/proInfo";
9
10 export const PostSliderTwoLayoutTab = ({ attributes, setAttributes }) => {
11 const {
12 blockName,
13 postSliderTwoLayout,
14 postSliderTwoHeight,
15 contentAreaWidth,
16 contentAreaHeight,
17 contentAreaBg,
18 contentAreaBorder,
19 liveFilterEnable,
20 generalLinkOpen,
21 postSliderGeneralPreloader,
22 contentAlignment,
23 postLimit,
24 carouselArrowSpaceBetween,
25 carouselArrowBorderRadius,
26 } = attributes;
27 const layouts = useLayouts(blockName, postSliderTwoLayout);
28 const deviceType = useDeviceType();
29
30 const layoutChange = (newValue) => {
31 if (newValue === postSliderTwoLayout) {
32 return;
33 }
34
35 const layoutDefault = {
36 "post-slider-two-layout-one": {
37 contentHorizontalPosition: "center",
38 contentVerticalPosition: "center",
39 contentAlignment: "center",
40 contentAreaWidth: {
41 ...contentAreaWidth,
42 device: {
43 ...contentAreaWidth.device,
44 [deviceType]: 580,
45 },
46 unit: { ...contentAreaWidth.unit, [deviceType]: "px" },
47 },
48 contentAreaHeight: {
49 ...contentAreaHeight,
50 device: {
51 ...contentAreaHeight.device,
52 [deviceType]: 280,
53 },
54 unit: {
55 ...contentAreaHeight.unit,
56 [deviceType]: "px",
57 },
58 },
59 contentAreaBg: {
60 ...contentAreaBg,
61 color: {
62 ...contentAreaBg.color,
63 solidColor: "#ffffffe6",
64 },
65 },
66 carouselArrowSpaceBetween: {
67 ...carouselArrowSpaceBetween,
68 device: {
69 ...carouselArrowSpaceBetween.device,
70 [deviceType]: 100,
71 },
72 },
73 carouselArrowBorderRadius: {
74 ...carouselArrowBorderRadius,
75 device: {
76 ...carouselArrowBorderRadius.device,
77 [deviceType]: {
78 top: 50,
79 right: 50,
80 bottom: 50,
81 left: 50,
82 },
83 },
84 },
85 },
86 "post-slider-two-layout-two": {
87 contentHorizontalPosition: "center",
88 contentVerticalPosition: "bottom",
89 contentAlignment: "center",
90 contentAreaWidth: {
91 ...contentAreaWidth,
92 device: {
93 ...contentAreaWidth.device,
94 [deviceType]: 70,
95 },
96 unit: { ...contentAreaWidth.unit, [deviceType]: "%" },
97 },
98 contentAreaHeight: {
99 ...contentAreaHeight,
100 device: {
101 ...contentAreaHeight.device,
102 [deviceType]: 50,
103 },
104 unit: {
105 ...contentAreaHeight.unit,
106 [deviceType]: "%",
107 },
108 },
109 contentAreaBg: {
110 ...contentAreaBg,
111 color: {
112 ...contentAreaBg.color,
113 solidColor: "#ffffffe6",
114 },
115 },
116 carouselArrowSpaceBetween: {
117 ...carouselArrowSpaceBetween,
118 device: {
119 ...carouselArrowSpaceBetween.device,
120 [deviceType]: 100,
121 },
122 },
123 carouselArrowBorderRadius: {
124 ...carouselArrowBorderRadius,
125 device: {
126 ...carouselArrowBorderRadius.device,
127 [deviceType]: {
128 top: 50,
129 right: 50,
130 bottom: 50,
131 left: 50,
132 },
133 },
134 },
135 },
136 "post-slider-two-layout-three": {
137 contentHorizontalPosition: "right",
138 contentVerticalPosition: "center",
139 contentAlignment: "left",
140 contentAreaWidth: {
141 ...contentAreaWidth,
142 device: {
143 ...contentAreaWidth.device,
144 [deviceType]: 60,
145 },
146 unit: { ...contentAreaWidth.unit, [deviceType]: "%" },
147 },
148 contentAreaHeight: {
149 ...contentAreaHeight,
150 device: {
151 ...contentAreaHeight.device,
152 [deviceType]: 280,
153 },
154 unit: {
155 ...contentAreaHeight.unit,
156 [deviceType]: "px",
157 },
158 },
159 contentAreaBg: {
160 ...contentAreaBg,
161 color: {
162 ...contentAreaBg.color,
163 solidColor: "#ffffff",
164 },
165 },
166 contentAreaBorder: {
167 ...contentAreaBorder,
168 style: "solid",
169 },
170 carouselArrowSpaceBetween: {
171 ...carouselArrowSpaceBetween,
172 device: {
173 ...carouselArrowSpaceBetween.device,
174 Desktop: 0,
175 Tablet: 0,
176 Mobile: 0,
177 },
178 },
179 carouselArrowBorderRadius: {
180 ...carouselArrowBorderRadius,
181 device: {
182 ...carouselArrowBorderRadius.device,
183 [deviceType]: {
184 top: 0,
185 right: 0,
186 bottom: 0,
187 left: 0,
188 },
189 },
190 },
191 },
192 };
193
194 const newData = {
195 postSliderTwoLayout: newValue,
196 ...layoutDefault?.[newValue],
197 blockLayoutName: newValue,
198 };
199 setAttributes(newData);
200 };
201
202 return (
203 <>
204 {layouts?.length > 0 && (
205 <Layouts
206 label={__("Post Slider Layout", "post-carousel")}
207 attributes={postSliderTwoLayout}
208 attributesKey={"postSliderTwoLayout"}
209 setAttributes={setAttributes}
210 displayActive={true}
211 showDemoTitle={true}
212 onChange={layoutChange}
213 grid={3}
214 items={layouts}
215 />
216 )}
217 <Toggle
218 label={__("Smart Frontend Filter", "post-carousel")}
219 attributes={liveFilterEnable}
220 setAttributes={setAttributes}
221 attributesKey={"liveFilterEnable"}
222 />
223 <InputControl
224 label={__("Number of Slides", "post-carousel")}
225 className="sp-smart-limit-field"
226 ajax={true}
227 attributes={postLimit}
228 min={1}
229 attributesKey={"postLimit"}
230 setAttributes={setAttributes}
231 />
232 <SPRangeControl
233 label={__("Height", "post-carousel")}
234 attributes={postSliderTwoHeight}
235 attributesKey={"postSliderTwoHeight"}
236 setAttributes={setAttributes}
237 max={900}
238 units={["px", "%", "em"]}
239 defaultValue={{ unit: "px", value: 620 }}
240 />
241 <SPToggleGroupControl
242 label={__("Content Alignment", "post-carousel")}
243 attributes={contentAlignment}
244 attributesKey={"contentAlignment"}
245 setAttributes={setAttributes}
246 items={[
247 { label: <AlignLeft />, value: "left" },
248 { label: <AlignCenter />, value: "center" },
249 { label: <AlignRight />, value: "right" },
250 ]}
251 />
252 <SelectField
253 label={__("Link Open In", "post-carousel")}
254 attributes={generalLinkOpen}
255 attributesKey={"generalLinkOpen"}
256 setAttributes={setAttributes}
257 items={openLinksOptions}
258 />
259 <Toggle
260 label={__("Preloader", "post-carousel")}
261 attributes={postSliderGeneralPreloader}
262 attributesKey={"postSliderGeneralPreloader"}
263 setAttributes={setAttributes}
264 />
265 <ProInfo>
266 <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>
267 </ProInfo>
268 </>
269 );
270 };
271
272 export const PostSliderTwoSliderTab = ({ attributes, setAttributes }) => {
273 const {
274 carouselAutoPlay,
275 carouselAutoPlayDelay,
276 carouselSpeed,
277 carouselDirection,
278 postSliderTwoSlideToScroll,
279 carouselPauseOnHover,
280 postSliderTwoAnimationEffect,
281 postSliderTwoAdaptiveHeight,
282 infiniteLoop,
283 postSliderTwoTabKeyNavigation,
284 postSliderTwoMouseWheelControl,
285 postSliderTwoFreeScrollMode,
286 // postSliderTwoNavArrow,
287 // postSliderTwoPaginationDot,
288 carouselNavArrow,
289 carouselPaginationDot,
290 } = attributes;
291
292 return (
293 <>
294 <Toggle
295 label={__("AutoPlay", "post-carousel")}
296 attributes={carouselAutoPlay}
297 attributesKey={"carouselAutoPlay"}
298 setAttributes={setAttributes}
299 />
300 {carouselAutoPlay && (
301 <SPRangeControl
302 label={__("AutoPlay Delay", "post-carousel")}
303 attributes={carouselAutoPlayDelay}
304 attributesKey={"carouselAutoPlayDelay"}
305 setAttributes={setAttributes}
306 min={0}
307 max={6000}
308 units={["ms"]}
309 defaultValue={{ unit: "ms", value: 2000 }}
310 />
311 )}
312 <SPRangeControl
313 label={__("Slider Speed", "post-carousel")}
314 attributes={carouselSpeed}
315 attributesKey={"carouselSpeed"}
316 setAttributes={setAttributes}
317 min={0}
318 max={3000}
319 units={["ms"]}
320 defaultValue={{ unit: "ms", value: 600 }}
321 />
322 <SPToggleGroupControl
323 label={__("Slider Direction", "post-carousel")}
324 attributes={carouselDirection}
325 attributesKey={"carouselDirection"}
326 setAttributes={setAttributes}
327 items={[
328 {
329 label: __("Right To Left", "post-carousel"),
330 value: "right_to_left",
331 },
332 {
333 label: __("Left To Right", "post-carousel"),
334 value: "left_to_right",
335 },
336 ]}
337 />
338 <InputControl
339 label={__("Slide to Scroll", "post-carousel")}
340 attributes={postSliderTwoSlideToScroll}
341 attributesKey={"postSliderTwoSlideToScroll"}
342 setAttributes={setAttributes}
343 type="number"
344 min={1}
345 max={10}
346 flex={true}
347 />
348 <Toggle
349 label={__("Pause on Hover", "post-carousel")}
350 attributes={carouselPauseOnHover}
351 attributesKey={"carouselPauseOnHover"}
352 setAttributes={setAttributes}
353 />
354 <SelectField
355 label={__("Animation Effect", "post-carousel")}
356 attributes={postSliderTwoAnimationEffect}
357 attributesKey={"postSliderTwoAnimationEffect"}
358 setAttributes={setAttributes}
359 items={[
360 { label: "Slide", value: "slide" },
361 { label: "Cube", value: "cube" },
362 { label: "Flip", value: "flip" },
363 { label: "Coverflow", value: "coverflow", disabled: "disabled" },
364 { label: "Fade (Pro)", value: "fade", disabled: "disabled" },
365 ]}
366 flexStyle={true}
367 />
368 <Toggle
369 label={__("Adaptive Height", "post-carousel")}
370 attributes={postSliderTwoAdaptiveHeight}
371 attributesKey={"postSliderTwoAdaptiveHeight"}
372 setAttributes={setAttributes}
373 />
374 <Toggle
375 label={__("Infinite Loop", "post-carousel")}
376 attributes={infiniteLoop}
377 attributesKey={"infiniteLoop"}
378 setAttributes={setAttributes}
379 />
380 <Toggle
381 label={__("Tab and Key Navigation", "post-carousel")}
382 attributes={postSliderTwoTabKeyNavigation}
383 attributesKey={"postSliderTwoTabKeyNavigation"}
384 setAttributes={setAttributes}
385 />
386 <Toggle
387 label={__("MouseWheel Control", "post-carousel")}
388 attributes={postSliderTwoMouseWheelControl}
389 attributesKey={"postSliderTwoMouseWheelControl"}
390 setAttributes={setAttributes}
391 />
392 <Toggle
393 label={__("Free Scroll Mode", "post-carousel")}
394 attributes={postSliderTwoFreeScrollMode}
395 attributesKey={"postSliderTwoFreeScrollMode"}
396 setAttributes={setAttributes}
397 />
398 <Toggle
399 label={__("Navigation Arrow", "post-carousel")}
400 attributes={carouselNavArrow}
401 attributesKey={"carouselNavArrow"}
402 setAttributes={setAttributes}
403 />
404 <Toggle
405 label={__("Pagination Dots", "post-carousel")}
406 attributes={carouselPaginationDot}
407 attributesKey={"carouselPaginationDot"}
408 setAttributes={setAttributes}
409 />
410 </>
411 );
412 };
413
414 export const PostSliderTwoGeneralTab = ({ attributes, setAttributes }) => {
415 const { generalLinkOpen, postSliderGeneralPreloader, contentAlignment } = attributes;
416
417 return (
418 <>
419 <SPToggleGroupControl
420 label={__("Content Alignment", "post-carousel")}
421 attributes={contentAlignment}
422 attributesKey={"contentAlignment"}
423 setAttributes={setAttributes}
424 items={[
425 { label: <AlignLeft />, value: "left" },
426 { label: <AlignCenter />, value: "center" },
427 { label: <AlignRight />, value: "right" },
428 ]}
429 />
430 <SelectField
431 label={__("Link Open In", "post-carousel")}
432 attributes={generalLinkOpen}
433 attributesKey={"generalLinkOpen"}
434 setAttributes={setAttributes}
435 items={openLinksOptions}
436 />
437 <Toggle
438 label={__("Preloader", "post-carousel")}
439 attributes={postSliderGeneralPreloader}
440 attributesKey={"postSliderGeneralPreloader"}
441 setAttributes={setAttributes}
442 />
443 </>
444 );
445 };
446