| 1 |
import { swiperPaddingForBoxShadow } from "../../controls/controls"; |
| 2 |
import sharedDynamicCss from "../shared/dynamicCss"; |
| 3 |
import { objectToCssString, wrapInMediaQuery } from "../shared/helpFn"; |
| 4 |
|
| 5 |
const cacheCss = { desktop: "", mobile: "", tablet: "" }; |
| 6 |
const dynamicCss = (attributes, page = "frontend", currentDevice = "all") => { |
| 7 |
const { |
| 8 |
uniqueId, |
| 9 |
gapBetweenPosts, |
| 10 |
equalHeightEnable, |
| 11 |
postCardBoxShadowEnable, |
| 12 |
postCardBoxShadow, |
| 13 |
postCardHoverBoxShadowEnable, |
| 14 |
postCardHoverBoxShadow, |
| 15 |
globalBreakPointData, |
| 16 |
} = attributes; |
| 17 |
|
| 18 |
const { sharedDesktopCss, sharedTabletCss, sharedMobileCss } = sharedDynamicCss(attributes, page); |
| 19 |
|
| 20 |
const responsiveCss = (deviceType) => { |
| 21 |
return [ |
| 22 |
// { |
| 23 |
// class: `#${ uniqueId } .sp-smart-post-swiper-nav-arrow`, |
| 24 |
// styles: { |
| 25 |
// right: `${ |
| 26 |
// carouselArrowHorizontal.device[ deviceType ] < 3 |
| 27 |
// ? carouselArrowHorizontal.device[ deviceType ] + |
| 28 |
// carouselArrowHorizontal.unit[ deviceType ] |
| 29 |
// : 0 |
| 30 |
// } !important`, |
| 31 |
// }, |
| 32 |
// }, |
| 33 |
// { |
| 34 |
// class: `#${ uniqueId } .sp-smart-post-swiper-nav-arrow .sp-smart-post-swiper-nav-arrow-btn.btn-next`, |
| 35 |
// styles: { |
| 36 |
// transform: |
| 37 |
// carouselArrowSpaceBetween.unit[ deviceType ] === '%' |
| 38 |
// ? `translateX(calc(-${ |
| 39 |
// carouselArrowSpaceBetween.device[ |
| 40 |
// deviceType |
| 41 |
// ] + |
| 42 |
// carouselArrowSpaceBetween.unit[ deviceType ] |
| 43 |
// } - ${ |
| 44 |
// carouselArrowWidth.device[ deviceType ] + |
| 45 |
// carouselArrowWidth.unit[ deviceType ] |
| 46 |
// })) !important` |
| 47 |
// : 'none', |
| 48 |
// }, |
| 49 |
// }, |
| 50 |
// { |
| 51 |
// class: `body.rtl #${ uniqueId } .sp-smart-post-swiper-nav-arrow .sp-smart-post-swiper-nav-arrow-btn.btn-next`, |
| 52 |
// styles: { |
| 53 |
// transform: |
| 54 |
// carouselArrowSpaceBetween.unit[ deviceType ] === '%' |
| 55 |
// ? `translateX(calc(${ |
| 56 |
// carouselArrowSpaceBetween.device[ |
| 57 |
// deviceType |
| 58 |
// ] + |
| 59 |
// carouselArrowSpaceBetween.unit[ deviceType ] |
| 60 |
// } + ${ |
| 61 |
// carouselArrowWidth.device[ deviceType ] + |
| 62 |
// carouselArrowWidth.unit[ deviceType ] |
| 63 |
// })) !important` |
| 64 |
// : 'none', |
| 65 |
// }, |
| 66 |
// }, |
| 67 |
// { |
| 68 |
// class: `#${ uniqueId } .swiper .sp-smart-post-card`, |
| 69 |
// styles: { |
| 70 |
// margin: `${ |
| 71 |
// ( postCardBoxShadowEnable || postCardHoverBoxShadowEnable ? '5px' : '' ) |
| 72 |
// }`, |
| 73 |
// }, |
| 74 |
// }, |
| 75 |
{ |
| 76 |
class: `#${uniqueId} .rfm-marquee .rfm-child`, |
| 77 |
styles: { |
| 78 |
"margin-right": gapBetweenPosts.device?.[deviceType] |
| 79 |
? gapBetweenPosts.device?.[deviceType] + gapBetweenPosts.unit?.[deviceType] |
| 80 |
: "", |
| 81 |
}, |
| 82 |
}, |
| 83 |
{ |
| 84 |
class: `#${uniqueId} .timeline-three-layout-two .sp-smart-post-timeline-three-post-container:nth-child(even) .sp-smart-post-card`, |
| 85 |
styles: { |
| 86 |
"margin-bottom": "0 !important", |
| 87 |
}, |
| 88 |
}, |
| 89 |
]; |
| 90 |
}; |
| 91 |
|
| 92 |
const desktopCss = [ |
| 93 |
...sharedDesktopCss, |
| 94 |
...responsiveCss("Desktop"), |
| 95 |
{ |
| 96 |
class: `#${uniqueId} .sp-smart-post-timeline-one-post-container .sp-smart-post-card`, |
| 97 |
styles: { |
| 98 |
height: equalHeightEnable ? "100%" : "auto", |
| 99 |
}, |
| 100 |
}, |
| 101 |
{ |
| 102 |
class: `#${uniqueId} .sp-smart-post-timeline-three-container`, |
| 103 |
styles: { |
| 104 |
gap: gapBetweenPosts.device.Desktop + gapBetweenPosts.unit.Desktop, |
| 105 |
}, |
| 106 |
}, |
| 107 |
// { |
| 108 |
// class: `#${ uniqueId } .post-timeline-three.timeline-three-layout-one .sp-smart-post-swiper-nav-arrow.sp-vertical-none`, |
| 109 |
// styles: { |
| 110 |
// top: '2%', |
| 111 |
// }, |
| 112 |
// }, |
| 113 |
// { |
| 114 |
// class: `#${ uniqueId } .post-timeline-three.timeline-three-layout-two .sp-smart-post-swiper-nav-arrow.sp-vertical-none`, |
| 115 |
// styles: { |
| 116 |
// top: '51.55%', |
| 117 |
// }, |
| 118 |
// }, |
| 119 |
{ |
| 120 |
class: `#${uniqueId} .sp-smart-post-show-equal-height .post-timeline-three.timeline-three-layout-two .sp-smart-post-card-content`, |
| 121 |
styles: { |
| 122 |
height: "100%", |
| 123 |
}, |
| 124 |
}, |
| 125 |
]; |
| 126 |
|
| 127 |
cacheCss.desktop = objectToCssString(desktopCss); |
| 128 |
|
| 129 |
if ("Tablet" === currentDevice || "all" === currentDevice) { |
| 130 |
const tabletCss = [ |
| 131 |
...sharedTabletCss, |
| 132 |
...responsiveCss("Tablet"), |
| 133 |
{ |
| 134 |
class: `#${uniqueId} .sp-smart-post-timeline-three-container .swiper`, |
| 135 |
styles: { |
| 136 |
padding: `${swiperPaddingForBoxShadow( |
| 137 |
postCardBoxShadowEnable, |
| 138 |
postCardBoxShadow.device?.Tablet, |
| 139 |
postCardHoverBoxShadowEnable, |
| 140 |
postCardHoverBoxShadow.device?.Tablet |
| 141 |
)} !important`, |
| 142 |
}, |
| 143 |
}, |
| 144 |
]; |
| 145 |
cacheCss.tablet = wrapInMediaQuery( |
| 146 |
objectToCssString(tabletCss), |
| 147 |
`only screen and (max-width: ${globalBreakPointData?.tablet}px)` |
| 148 |
); |
| 149 |
} |
| 150 |
if ("Mobile" === currentDevice || "all" === currentDevice) { |
| 151 |
// Mobile styles |
| 152 |
const mobileCss = [ |
| 153 |
...sharedMobileCss, |
| 154 |
...responsiveCss("Mobile"), |
| 155 |
{ |
| 156 |
class: `#${uniqueId} .sp-smart-post-timeline-three-container .swiper`, |
| 157 |
styles: { |
| 158 |
padding: `${swiperPaddingForBoxShadow( |
| 159 |
postCardBoxShadowEnable, |
| 160 |
postCardBoxShadow.device?.Mobile, |
| 161 |
postCardHoverBoxShadowEnable, |
| 162 |
postCardHoverBoxShadow.device?.Mobile |
| 163 |
)} !important`, |
| 164 |
}, |
| 165 |
}, |
| 166 |
// { |
| 167 |
// class: `#${ uniqueId } .sp-smart-post-swiper-nav-arrow`, |
| 168 |
// styles: { |
| 169 |
// 'column-gap': `${ |
| 170 |
// carouselArrowSpaceBetween.device.Mobile + |
| 171 |
// carouselArrowSpaceBetween.unit.Mobile |
| 172 |
// } !important`, |
| 173 |
// }, |
| 174 |
// }, |
| 175 |
]; |
| 176 |
cacheCss.mobile = wrapInMediaQuery( |
| 177 |
objectToCssString(mobileCss), |
| 178 |
`only screen and (max-width: ${globalBreakPointData?.mobile}px)` |
| 179 |
); |
| 180 |
} |
| 181 |
|
| 182 |
return `${cacheCss.desktop} ${cacheCss.tablet} ${cacheCss.mobile}`; |
| 183 |
}; |
| 184 |
|
| 185 |
export default dynamicCss; |
| 186 |
|