PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.7
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.7
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-carousel / dynamicCss.js

dynamicCss.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.7, at src/blocks/post-carousel/dynamicCss.js

205 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import sharedDynamicCss from "../shared/dynamicCss";
2 import { objectToCssString, rangerCss, wrapInMediaQuery } from "../shared/helpFn";
3
4 const cacheCss = { desktop: "", mobile: "", tablet: "" };
5 const dynamicCss = (attributes, page = "frontend", currentDevice = "all") => {
6 const {
7 uniqueId,
8 carouselHeight,
9 carouselGap,
10 equalHeightEnable,
11 carouselColumn,
12 carouselPaginationStyle,
13 carouselPaginationVertical,
14 globalBreakPointData,
15 } = attributes;
16 const { sharedDesktopCss, sharedTabletCss, sharedMobileCss } = sharedDynamicCss(attributes, page);
17
18 const carouselResponsiveCss = (deviceType) => {
19 const allResponsiveCss = [
20 equalHeightEnable
21 ? {}
22 : {
23 class: `#${uniqueId}.sp-smart-post-carousel .sp-smart-post-card`,
24 styles: {
25 height: rangerCss(carouselHeight, deviceType),
26 },
27 },
28 "scrollbar" !== carouselPaginationStyle
29 ? {}
30 : {
31 class: `#${uniqueId}.sp-smart-post-carousel .swiper`,
32 styles: {
33 "padding-bottom":
34 Math.abs(carouselPaginationVertical.device?.[deviceType]) +
35 carouselPaginationVertical.unit?.[deviceType],
36 },
37 },
38 {
39 class: `#${uniqueId} .rfm-marquee .rfm-child`,
40 styles: {
41 "margin-right": carouselGap.device?.[deviceType] + carouselGap.unit?.[deviceType],
42 },
43 },
44 {
45 class: `#${uniqueId} .sp-smart-post-carousel .swiper-cube .swiper-slide, #${uniqueId} .sp-smart-post-carousel .swiper-fade .swiper-slide, #${uniqueId} .sp-smart-post-carousel .swiper-flip .swiper-slide`,
46 styles: {
47 gap: carouselGap.device?.[deviceType] + carouselGap.unit?.[deviceType],
48 },
49 },
50 {
51 class: `#${uniqueId} .sp-smart-post-carousel .swiper-fade .swiper-slide,
52 #${uniqueId} .sp-smart-post-carousel .swiper-cube .swiper-slide,#${uniqueId} .sp-smart-post-carousel .swiper-flip .swiper-slide`,
53 styles: {
54 "grid-template-columns": `repeat(${carouselColumn.device?.[deviceType]}, 1fr)`,
55 },
56 },
57 // {
58 // class: `#${ uniqueId } .sp-smart-post-carousel .sp-smart-post-card.template-two`,
59 // styles: {
60 // 'min-height': carouselHeight.device[ deviceType ]
61 // ? ''
62 // : '244px',
63 // },
64 // },
65 // {
66 // class: `#${ uniqueId } .sp-smart-post-carousel .sp-smart-post-swiper-nav-arrow`,
67 // styles: {
68 // opacity: '0',
69 // right: navArrowVisibilityOnHover
70 // ? `${
71 // carouselArrowHorizontal.device[ deviceType ] < 0
72 // ? carouselArrowHorizontal.device[
73 // deviceType
74 // ] -
75 // ( carouselArrowHorizontal.unit[
76 // deviceType
77 // ] === '%'
78 // ? 2
79 // : 10 ) +
80 // carouselArrowHorizontal.unit[ deviceType ]
81 // : 0
82 // }`
83 // : `${
84 // carouselArrowHorizontal.device[ deviceType ] < 0
85 // ? carouselArrowHorizontal.device[
86 // deviceType
87 // ] +
88 // carouselArrowHorizontal.unit[ deviceType ]
89 // : 0
90 // }`,
91 // transition: 'all 0.3s ease-in-out',
92 // },
93 // },
94 // {
95 // class: `#${ uniqueId } .sp-smart-post-carousel:hover .sp-smart-post-swiper-nav-arrow`,
96 // styles: {
97 // opacity: '1',
98 // right: `${
99 // carouselArrowHorizontal.device[ deviceType ] < 0
100 // ? carouselArrowHorizontal.device[ deviceType ] +
101 // carouselArrowHorizontal.unit[ deviceType ]
102 // : 0
103 // }`,
104 // },
105 // },
106 // {
107 // class: `#${ uniqueId } .sp-smart-post-swiper-nav-arrow .sp-smart-post-swiper-nav-arrow-btn.btn-next`,
108 // styles: {
109 // transform:
110 // carouselArrowSpaceBetween.unit[ deviceType ] === '%'
111 // ? `translateX(calc(-${
112 // carouselArrowSpaceBetween.device[
113 // deviceType
114 // ] +
115 // carouselArrowSpaceBetween.unit[ deviceType ]
116 // } - ${
117 // carouselArrowWidth.device[ deviceType ] +
118 // carouselArrowWidth.unit[ deviceType ]
119 // })) !important`
120 // : 'none',
121 // },
122 // },
123 // {
124 // class: `body.rtl #${ uniqueId } .sp-smart-post-swiper-nav-arrow .sp-smart-post-swiper-nav-arrow-btn.btn-next`,
125 // styles: {
126 // transform:
127 // carouselArrowSpaceBetween.unit[ deviceType ] === '%'
128 // ? `translateX(calc(${
129 // carouselArrowSpaceBetween.device[
130 // deviceType
131 // ] +
132 // carouselArrowSpaceBetween.unit[ deviceType ]
133 // } + ${
134 // carouselArrowWidth.device[ deviceType ] +
135 // carouselArrowWidth.unit[ deviceType ]
136 // })) !important`
137 // : 'none',
138 // },
139 // },
140 ];
141
142 return allResponsiveCss;
143 };
144
145 const desktopCss = [
146 ...sharedDesktopCss,
147 ...carouselResponsiveCss("Desktop"),
148 // {
149 // class: `#${ uniqueId } .sp-smart-post-carousel .sp-swiper-slide .swiper-wrapper .sp-slide-item`,
150 // styles: {
151 // 'padding-bottom': '10px',
152 // },
153 // },
154 ];
155
156 cacheCss.desktop = objectToCssString(desktopCss);
157
158 if ("Tablet" === currentDevice || "all" === currentDevice) {
159 const tabletCss = [
160 ...sharedTabletCss,
161 ...carouselResponsiveCss("Tablet"),
162 // {
163 // class: `#${ uniqueId } .sp-smart-post-carousel .sp-swiper-slide .swiper-wrapper .sp-slide-item`,
164 // styles: {
165 // 'padding-bottom': '10px',
166 // },
167 // },
168 ];
169
170 cacheCss.tablet = wrapInMediaQuery(
171 objectToCssString(tabletCss),
172 `only screen and (max-width: ${globalBreakPointData?.tablet}px)`
173 );
174 }
175 if ("Mobile" === currentDevice || "all" === currentDevice) {
176 const mobileCss = [
177 ...sharedMobileCss,
178 ...carouselResponsiveCss("Mobile"),
179 // {
180 // class: `#${ uniqueId } .sp-smart-post-carousel .sp-swiper-slide .swiper-wrapper .sp-slide-item`,
181 // styles: {
182 // 'padding-bottom': '10px',
183 // },
184 // },
185 {
186 class: `#${uniqueId} .sp-smart-post-carousel .sp-smart-post-pagination-dots.swiper-pagination-vertical`,
187 styles: {
188 "flex-direction": "column",
189 transform: "translateX(0px)",
190 top: "50%",
191 // transform: "translateY(-50%)",
192 },
193 },
194 ];
195 cacheCss.mobile = wrapInMediaQuery(
196 objectToCssString(mobileCss),
197 `only screen and (max-width: ${globalBreakPointData?.mobile}px)`
198 );
199 }
200
201 return `${cacheCss.desktop} ${cacheCss.tablet} ${cacheCss.mobile}`;
202 };
203
204 export default dynamicCss;
205