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 / news-ticker / dynamicCss.js

dynamicCss.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at src/blocks/news-ticker/dynamicCss.js

562 lines 16.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { boxCss, colorControls, objectToCssString, spacingGenerate, wrapInMediaQuery } from "../shared/helpFn";
2
3 const cacheCss = { desktop: "", mobile: "", tablet: "" };
4 const dynamicCss = (attributes, page = "frontend", currentDevice = "all") => {
5 const {
6 uniqueId,
7 tickerHeight,
8 tickerTitleGap,
9 contentBg,
10 ContentBorder,
11 ContentBorderWidth,
12 ContentBorderRadius,
13 gapBetweenHeadingContent,
14 newsTickerShadowEnable,
15 newsTickerBoxShadow,
16 headingStyle,
17 HeadingPosition,
18 displayStyle,
19 tickerHeadingBg,
20 headingColor,
21 headingTypography,
22 headingFontSize,
23 headingLatterSpacing,
24 headingLineHeight,
25 tickerTitleTypography,
26 tickerTitleFontSize,
27 tickerTitleLatterSpacing,
28 tickerTitleLineHeight,
29 tickerIconPosition,
30 tickertitleColor,
31 tickerDateStyle,
32 tickerDateColor,
33 tickerDateTypography,
34 tickerDateLineHeight,
35 tickerDateLatterSpacing,
36 tickerDateFontSize,
37 tickerDateBgColor,
38 tickerImageHeight,
39 tickerImageWidth,
40 tickerImgSize,
41 tickerImgShape,
42 tickerDisplaySticky,
43 tickerStickyTopPosition,
44 newsTickerArrowBgColor,
45 newsTickerCarouselArrowColor,
46 newsTickerCarouselArrowBorderRadius,
47 newsTickerCarouselArrowBorder,
48 newsTickerCarouselArrowWidth,
49 tickerNavigation,
50 newsCarouselArrowSpaceBetween,
51 carouselAnimationEffect,
52 tickerTitleWordSpacing,
53 tickerDateWordSpacing,
54 headingWordSpacing,
55 newsTickerIconSize,
56 newsTickerHeadingPadding,
57 titleListStyleIconSize,
58 titleListStyleIconGap,
59 newsTickerImageRadius,
60 newsTickerCarouselDividerColor,
61 hideOnDesktop,
62 hideOnTablet,
63 hideOnMobile,
64 carouselArrowHeight,
65 carouselArrowSize,
66 globalBreakPointData,
67 } = attributes;
68
69 const rangerCss = (attr, device = "Desktop") => {
70 const unit = attr?.unit?.[device] || "";
71
72 return `${attr?.device?.[device] ?? ""}${unit}`;
73 };
74
75 const typographyCss = (attr) => {
76 return {
77 "font-family": attr.typography.family,
78 "font-weight": attr.typography.fontWeight,
79 "font-style": attr.typography.style,
80 "text-decoration": attr.typography.decoration,
81 "text-transform": attr.typography.transform,
82 };
83 };
84
85 const carouselResponsiveCss = (deviceType) => {
86 const allResponsiveCss = [
87 {
88 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow-btn i`,
89 styles: {
90 color: newsTickerCarouselArrowColor.color,
91 background: newsTickerArrowBgColor.color,
92 "border-color": newsTickerCarouselArrowBorder.color,
93 "border-style": newsTickerCarouselArrowBorder.style,
94 "border-radius": spacingGenerate(newsTickerCarouselArrowBorderRadius, deviceType),
95 width: rangerCss(newsTickerCarouselArrowWidth, deviceType),
96 height: rangerCss(carouselArrowHeight, deviceType),
97 },
98 },
99 {
100 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow-btn i svg`,
101 styles: {
102 width: rangerCss(carouselArrowSize, deviceType),
103 height: rangerCss(carouselArrowSize, deviceType),
104 },
105 },
106
107 {
108 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow-btn .divider`,
109 styles: {
110 color: newsTickerCarouselDividerColor,
111 },
112 },
113
114 // {
115 // class: `#${uniqueId} .slider-class`,
116 // styles: {
117 // // width: tickerNavigation ? '57%' : '75%',
118 // width: "-webkit-fill-available",
119 // // "max-width": tickerNavigation ? "calc( 100% - 265px )" : "calc( 100% - 180px )",
120 // "max-width": tickerNavigation ? "calc( 100% - 265px )" : "calc( 100% - 180px )",
121 // },
122 // },
123 {
124 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow-btn i:hover`,
125 styles: {
126 color: newsTickerCarouselArrowColor.hoverColor,
127 background: newsTickerArrowBgColor.hoverColor,
128 "border-color": newsTickerCarouselArrowBorder.hoverColor,
129 },
130 },
131
132 {
133 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow`,
134 styles: {
135 // width: '17%',
136 width: "fit-content",
137 position: "relative",
138 "align-items": "center",
139 "justify-content": HeadingPosition === "right" ? "start" : "end",
140 "z-index": 2,
141 top: "50%",
142 gap:
143 newsCarouselArrowSpaceBetween.device?.[deviceType] +
144 newsCarouselArrowSpaceBetween.unit?.[deviceType],
145 },
146 },
147 {
148 class: `#${uniqueId} .rfm-marquee .rfm-initial-child-container, #${uniqueId} .rfm-marquee`,
149 styles: {
150 gap: tickerTitleGap.device?.[deviceType] + tickerTitleGap.unit?.[deviceType],
151 display: "flex",
152 },
153 },
154
155 {
156 class: `#${uniqueId} .sp-marquee-inner`,
157 styles: {
158 gap: tickerTitleGap.device?.[deviceType] + tickerTitleGap.unit?.[deviceType],
159 display: "flex",
160 },
161 },
162
163 {
164 class: `#${uniqueId}`,
165 styles: {
166 position: tickerDisplaySticky ? "sticky" : "static",
167 top: tickerDisplaySticky
168 ? tickerStickyTopPosition.device?.[deviceType] + tickerStickyTopPosition.unit?.[deviceType]
169 : "auto",
170 "z-index": 99999,
171 },
172 },
173
174 {
175 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading`,
176 styles: {
177 background: colorControls(
178 tickerHeadingBg.color.style,
179 tickerHeadingBg.color.solidColor,
180 tickerHeadingBg.color.gradient
181 ),
182 "margin-right":
183 gapBetweenHeadingContent.device?.[deviceType] + gapBetweenHeadingContent.unit?.[deviceType],
184 "border-radius":
185 // eslint-disable-next-line no-nested-ternary
186 headingStyle === "five"
187 ? HeadingPosition === "right"
188 ? "0 4px 4px 0" // rounded on right
189 : "4px 0 0 4px" // rounded on left
190 : "",
191 padding: spacingGenerate(newsTickerHeadingPadding, deviceType),
192 },
193 },
194 {
195 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading.sp-ticker-heading-six-${HeadingPosition} .ticker-heading-content`,
196 styles: {
197 background: colorControls(
198 tickerHeadingBg.color.style,
199 tickerHeadingBg.color.solidColor,
200 tickerHeadingBg.color.gradient
201 ),
202 padding: spacingGenerate(newsTickerHeadingPadding, deviceType),
203 },
204 },
205 {
206 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading.sp-ticker-heading-five-left::after, #${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading.sp-ticker-heading-five-right::after`,
207 styles: {
208 [`border-${HeadingPosition}`]: `12px solid ${tickerHeadingBg.color.solidColor}`,
209 },
210 },
211
212 {
213 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading .ticker-heading-content`,
214 styles: {
215 "margin-right": HeadingPosition === "left" ? "12px" : "-12px",
216 display: "flex",
217 "justify-content": "center",
218 "align-items": "center",
219 gap: "3px",
220 "flex-direction": tickerIconPosition === "right" ? "row-reverse" : "",
221 },
222 },
223
224 {
225 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading .ticker-heading-label`,
226 styles: {
227 color: headingColor.color,
228
229 ...typographyCss(headingTypography),
230 "font-size": rangerCss(headingFontSize, deviceType),
231 "line-height": headingLineHeight.device?.[deviceType],
232 "letter-spacing": rangerCss(headingLatterSpacing, deviceType),
233 "word-spacing": rangerCss(headingWordSpacing, deviceType),
234 },
235 },
236
237 {
238 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .rfm-marquee .rfm-child`,
239 styles: {
240 display: "flex",
241 },
242 },
243
244 {
245 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-ticker-img`,
246 styles: {
247 width: tickerImgSize === "custom" ? rangerCss(tickerImageWidth) : undefined,
248 height: tickerImgSize === "custom" ? rangerCss(tickerImageHeight) : undefined,
249 margin: "0px 7px",
250 },
251 },
252 {
253 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-ticker-img.sp-img-square`,
254 styles: {
255 "border-radius": spacingGenerate(newsTickerImageRadius, deviceType),
256 },
257 },
258 {
259 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-date`,
260 styles: {
261 color: tickerDateColor,
262 "margin-top": tickerDateStyle === "text" ? "5px" : "",
263 "margin-left": "5px",
264 ...typographyCss(tickerDateTypography),
265 "font-size": rangerCss(tickerDateFontSize, deviceType),
266 "line-height": tickerDateLineHeight.device?.[deviceType] ?? "",
267 "letter-spacing": rangerCss(tickerDateLatterSpacing, deviceType),
268 "word-spacing": rangerCss(tickerDateWordSpacing, deviceType),
269 display: "flex",
270 "align-items": "center",
271 ...(tickerDateStyle === "button" && {
272 background: tickerDateBgColor,
273 padding: "3px 8px",
274 "border-radius": "5px",
275 }),
276 },
277 },
278
279 {
280 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-smart-post-ticker-title`,
281
282 styles: {
283 color: tickertitleColor.color,
284 ...typographyCss(tickerTitleTypography),
285 "font-size": rangerCss(tickerTitleFontSize, deviceType),
286 "line-height": tickerTitleLineHeight.device?.[deviceType] ?? "",
287 "letter-spacing": rangerCss(tickerTitleLatterSpacing, deviceType),
288 "word-spacing": rangerCss(tickerTitleWordSpacing, deviceType),
289 display: "flex",
290 "align-items": "center",
291 },
292 },
293 {
294 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-smart-post-ticker-title:hover`,
295
296 styles: {
297 color: tickertitleColor.hoverColor,
298 },
299 },
300
301 // {
302 // class: `#${ uniqueId } .btn-prev i`,
303
304 // styles: {
305 // transform:
306 // displayStyle === 'slide' &&
307 // carouselAnimationEffect === 'fade'
308 // ? 'rotate(90deg)'
309 // : 'none',
310 // },
311 // },
312
313 // {
314 // class: `#${ uniqueId } .btn-next i`,
315
316 // styles: {
317 // transform:
318 // displayStyle === 'slide' &&
319 // carouselAnimationEffect === 'fade'
320 // ? 'rotate(90deg)'
321 // : 'none',
322 // },
323 // },
324
325 {
326 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper`,
327 styles: {
328 display: "flex",
329 height: rangerCss(tickerHeight, deviceType),
330 // "flex-direction": "row",
331 "align-items": "flex-start",
332 "justify-content": "stretch",
333 overflow: "hidden",
334 // gap:
335 // gapBetweenHeadingContent.device[ deviceType ] !== ''
336 // ? gapBetweenHeadingContent.device[ deviceType ] +
337 // gapBetweenHeadingContent.unit[ deviceType ]
338 // : '0px',
339 "border-style": ContentBorder.style,
340 "border-color": ContentBorder.color,
341 "border-width": spacingGenerate(ContentBorderWidth, deviceType),
342 "border-radius": spacingGenerate(ContentBorderRadius, deviceType),
343 background: colorControls(
344 contentBg.color.style,
345 contentBg.color.solidColor,
346 contentBg.color.gradient
347 ),
348 "box-shadow": boxCss(newsTickerShadowEnable, deviceType, newsTickerBoxShadow, "color"),
349 "flex-direction": HeadingPosition === "right" ? "row-reverse" : "",
350 },
351 },
352
353 {
354 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-smart-post-card-content`,
355 styles: {
356 "border-color": ContentBorder.hoverColor,
357 "text-align": displayStyle === "typewriter" ? "left" : "center",
358 "margin-left": displayStyle === "typewriter" ? "16px" : undefined,
359 display: "flex",
360 "align-items": "center",
361
362 // width: displayStyle !== 'typewriter' ? '100%' : '75%',
363 "justify-content": displayStyle === "typewriter" ? undefined : "center",
364 "flex-shrink": "0",
365 },
366 },
367 {
368 class: `#${uniqueId} .sp-smart-post-news-ticker .sps-news-ticker-wrapper .sps-news-ticker-vanilla-slide.sp-slide-fade`,
369 styles: {
370 width: "100%",
371 "justify-content": "space-around",
372 },
373 },
374
375 {
376 class: `#${uniqueId} .sp-smart-post-news-ticker:hover .sp-smart-post-swiper`,
377 styles: {
378 "border-color": ContentBorder.hoverColor,
379 },
380 },
381
382 {
383 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-smart-post-ticker`,
384 styles: {
385 display: "flex",
386 "align-items": "center",
387 gap: "32px",
388 // width: '80%',
389 "margin-left": HeadingPosition === "left" ? "-26px" : "",
390 "margin-right": HeadingPosition === "right" ? "-26px" : "",
391 overflow: "hidden",
392 },
393 },
394 {
395 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-ticker-item .ticker-separator`,
396 styles: {
397 "margin-right": `-${tickerTitleGap.device?.[deviceType] / 2 + tickerTitleGap.unit?.[deviceType]}`,
398 "margin-left": `${tickerTitleGap.device?.[deviceType] / 2 + tickerTitleGap.unit?.[deviceType]}`,
399 "font-size": tickerTitleFontSize.device?.[deviceType] + tickerTitleFontSize.unit?.[deviceType],
400 },
401 },
402 {
403 class: `#${uniqueId} .sp-smart-post-news-ticker .ticker-heading .ticker-heading-content svg`,
404 styles: {
405 width: rangerCss(newsTickerIconSize, deviceType),
406 height: rangerCss(newsTickerIconSize, deviceType),
407 },
408 },
409 {
410 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-ticker-item .sp-smart-post-ticker-title svg`,
411 styles: {
412 width: rangerCss(titleListStyleIconSize, deviceType),
413 height: rangerCss(titleListStyleIconSize, deviceType),
414 },
415 },
416 {
417 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-ticker-item .sp-smart-post-ticker-title`,
418 styles: {
419 "column-gap": rangerCss(titleListStyleIconGap, deviceType),
420 },
421 },
422 ];
423
424 return allResponsiveCss;
425 };
426
427 const desktopCss = [
428 ...carouselResponsiveCss("Desktop"),
429 {
430 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow-btn i svg`,
431 styles: {
432 fill: newsTickerCarouselArrowColor.color,
433 },
434 },
435
436 {
437 class: `#${uniqueId} .slider-class`,
438 styles: {
439 // width: tickerNavigation ? '57%' : '75%',
440 width: "-webkit-fill-available",
441 // "max-width": tickerNavigation ? "calc( 100% - 265px )" : "calc( 100% - 180px )",
442 "max-width": tickerNavigation ? "calc( 100% - 265px )" : "calc( 100% - 180px )",
443 },
444 },
445 {
446 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-swiper-slide .swiper-wrapper .sp-slide-item, #${uniqueId} .sps-news-ticker-wrapper .sps-news-ticker-vanilla-slide`,
447 styles: {
448 "align-items": "center",
449 display: "flex",
450 "justify-content": carouselAnimationEffect === "fade" ? "space-around" : "center",
451 },
452 }
453 ];
454
455 cacheCss.desktop = objectToCssString(desktopCss);
456
457 if ("Tablet" === currentDevice || "all" === currentDevice) {
458 const tabletCss = [
459 ...carouselResponsiveCss("Tablet"),
460 {
461 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-swiper-slide .swiper-wrapper .sp-slide-item`,
462 styles: {
463 "align-items": "center",
464 },
465 }
466 ];
467 cacheCss.tablet = wrapInMediaQuery(
468 objectToCssString(tabletCss),
469 `only screen and (max-width: ${globalBreakPointData?.tablet}px)`
470 );
471 }
472 if ("Mobile" === currentDevice || "all" === currentDevice) {
473 const mobileCss = [
474 ...carouselResponsiveCss("Mobile"),
475 {
476 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-swiper-slide .swiper-wrapper .sp-slide-item`,
477 styles: {
478 "align-items": "center",
479 },
480 },
481
482 {
483 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-swiper-slide .swiper-wrapper .sp-slide-item, #${uniqueId} .sps-news-ticker-wrapper .sps-news-ticker-vanilla-slide`,
484 styles: {
485 "align-items": "center",
486 display: "flex",
487 "justify-content": carouselAnimationEffect === "fade" ? "space-around" : "start",
488 },
489 },
490
491 {
492 class: `#${uniqueId} .slider-class`,
493 styles: {
494 width: "-webkit-fill-available",
495 "max-width": "calc( 100% - 92px )",
496 },
497 },
498
499 {
500 class: `#${uniqueId} .sp-smart-post-ticker-title`,
501 styles: {
502 display: "block !important",
503 width: "-webkit-fill-available",
504 "max-width": "calc(100% - 2%)",
505 "white-space": "nowrap",
506 overflow: "hidden",
507 "text-overflow": "ellipsis",
508 },
509 },
510
511 {
512 class: `#${uniqueId} .slider-class`,
513 styles: {
514 width: "78%",
515 },
516 },
517 {
518 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-pagination-dots.swiper-pagination-vertical`,
519 styles: {
520 "flex-direction": "column",
521 transform: "translateX(0px)",
522 top: "50%",
523 // eslint-disable-next-line no-dupe-keys
524 transform: "translateY(-50%)",
525 },
526 },
527
528 {
529 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .sp-smart-post-card-content`,
530 styles: {
531 "justify-content":
532 // eslint-disable-next-line no-nested-ternary
533 displayStyle === "typewriter" ? undefined : HeadingPosition === "left" ? "start" : "flex-start",
534 // "margin-left": "8px",
535 },
536 },
537
538 {
539 class: `#${uniqueId} .sp-smart-post-news-ticker .sp-smart-post-swiper .ticker-heading .ticker-heading-label`,
540 styles: {
541 display: "none",
542 },
543 },
544
545 {
546 class: `#${uniqueId} .sp-smart-post-swiper-nav-arrow`,
547 styles: {
548 display: "none",
549 },
550 }
551 ];
552 cacheCss.mobile = wrapInMediaQuery(
553 objectToCssString(mobileCss),
554 `only screen and (max-width: ${globalBreakPointData?.mobile}px)`
555 );
556 }
557
558 return `${cacheCss.desktop} ${cacheCss.tablet} ${cacheCss.mobile}`;
559 };
560
561 export default dynamicCss;
562