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-timeline-one / dynamicCss.js

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

152 lines 5.7 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 { convertToClassName, objectToCssString, wrapInMediaQuery } from "../shared/helpFn";
3
4 const cacheCss = { desktop: "", mobile: "", tablet: "" };
5 const dynamicCss = (attributes, page = "frontend", currentDevice = "all") => {
6 const {
7 uniqueId,
8 gapBetweenPosts,
9 equalHeightEnable,
10 timelineIndicatorColor,
11 timelineCircleBgColor,
12 timelineConnectorBorder,
13 timelineLayout,
14 advancedPadding,
15 globalBreakPointData,
16 } = attributes;
17
18 const { sharedDesktopCss, sharedTabletCss, sharedMobileCss } = sharedDynamicCss(attributes, page);
19
20 const responsiveCss = (deviceType) => {
21 return [
22 {
23 class: `#${uniqueId}:has(.post-timeline-one)`,
24 styles: {
25 "padding-left": advancedPadding.device?.[deviceType].left
26 ? advancedPadding.device?.[deviceType].left + advancedPadding.unit?.[deviceType] + " !important"
27 : "",
28 "padding-right": advancedPadding.device?.[deviceType].right
29 ? advancedPadding.device?.[deviceType].right +
30 advancedPadding.unit?.[deviceType] +
31 " !important"
32 : "",
33 },
34 },
35 ];
36 };
37
38 const timelineCss = [
39 {
40 class: `#${uniqueId} .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container .sp-smart-indicator-circle.active`,
41 styles: {
42 "Background-color": `${timelineCircleBgColor.active} !important`,
43 "border-color": `${timelineConnectorBorder.activeColor} !important`,
44 },
45 },
46 {
47 class: `#${uniqueId} .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container .sp-smart-indicator-arrow.active`,
48 styles: {
49 "border-left-color": `${timelineIndicatorColor.active} !important`,
50 "border-right-color": `${timelineIndicatorColor.active} !important`,
51 },
52 },
53 {
54 class: `
55 #${uniqueId} .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:first-child .sp-smart-indicator-circle`,
56 styles: {
57 "Background-color": `${timelineCircleBgColor.active} !important`,
58 "border-color": `${timelineConnectorBorder.activeColor} !important`,
59 },
60 },
61 {
62 class: `#${uniqueId} .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:first-child .sp-smart-indicator-arrow`,
63 styles: {
64 "border-left-color": `${timelineIndicatorColor.active} !important`,
65 "border-right-color": `${timelineIndicatorColor.active} !important`,
66 },
67 },
68 ];
69
70 const desktopCss = [
71 ...sharedDesktopCss,
72 ...timelineCss,
73 ...responsiveCss("Desktop"),
74 {
75 class: `.sp-gap-${convertToClassName(gapBetweenPosts.device.Desktop + gapBetweenPosts.unit.Desktop)}`,
76 property: "row-gap",
77 value: gapBetweenPosts.device.Desktop + gapBetweenPosts.unit.Desktop,
78 },
79 {
80 class: `#${uniqueId} .sp-smart-post-timeline-one-post-container .sp-smart-post-card`,
81 styles: {
82 height: equalHeightEnable ? "100%" : "auto",
83 },
84 },
85 {
86 class: `#${uniqueId} .post-timeline-one .sp-smart-post-timeline-container`,
87 styles: {
88 "row-gap": gapBetweenPosts.device.Desktop + gapBetweenPosts.unit.Desktop,
89 },
90 },
91 ];
92
93 cacheCss.desktop = objectToCssString(desktopCss);
94
95 if ("Tablet" === currentDevice || "all" === currentDevice) {
96 const tabletCss = [...sharedTabletCss, ...timelineCss, ...responsiveCss("Tablet")];
97 cacheCss.tablet = wrapInMediaQuery(
98 objectToCssString(tabletCss),
99 `only screen and (max-width: ${globalBreakPointData?.tablet}px)`
100 );
101 }
102 if ("Mobile" === currentDevice || "all" === currentDevice) {
103 const mobileCss = [
104 ...sharedMobileCss,
105 ...timelineCss,
106 ...responsiveCss("Mobile"),
107 // Timeline bubble speech ( indicator )
108 {
109 class: `#${uniqueId} .post-timeline-one .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:nth-of-type(odd) .sp-smart-indicator-arrow, #${uniqueId} .post-timeline-two .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:nth-of-type(odd) .sp-smart-indicator-arrow, #${uniqueId} .post-timeline-one .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:nth-of-type(even) .sp-smart-indicator-arrow, #${uniqueId} .post-timeline-two .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:nth-of-type(even) .sp-smart-indicator-arrow`,
110 styles: {
111 border: `medium solid ${timelineIndicatorColor.color}`,
112 "border-color": `${
113 timelineLayout !== "timeline-one-layout-six"
114 ? "transparent transparent transparent " + timelineIndicatorColor.color
115 : "transparent " + timelineIndicatorColor.color + " transparent transparent"
116 }`,
117 "border-width": `${
118 timelineLayout !== "timeline-one-layout-six" ? "15px 0 15px 15px" : "15px 15px 15px 0"
119 }`,
120 },
121 },
122 // {
123 // class: `#${ uniqueId } .post-timeline-one .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:nth-of-type(even) .sp-smart-indicator-arrow, #${ uniqueId } .post-timeline-two .sp-smart-post-timeline-container .sp-smart-post-timeline-one-post-container:nth-of-type(even) .sp-smart-indicator-arrow`,
124 // styles: {
125 // border: `medium solid ${ timelineIndicatorColor.color }`,
126 // 'border-color': `${
127 // timelineLayout !== 'timeline-one-layout-five'
128 // ? 'transparent ' +
129 // timelineIndicatorColor.color +
130 // ' transparent transparent'
131 // : 'transparent transparent transparent ' +
132 // timelineIndicatorColor.color
133 // } `,
134 // 'border-width': `${
135 // timelineLayout !== 'timeline-one-layout-five'
136 // ? '15px 15px 15px 0'
137 // : '15px 0 15px 15px'
138 // }`,
139 // },
140 // },
141 ];
142 cacheCss.mobile = wrapInMediaQuery(
143 objectToCssString(mobileCss),
144 `only screen and (max-width: ${globalBreakPointData?.mobile}px)`
145 );
146 }
147
148 return `${cacheCss.desktop} ${cacheCss.tablet} ${cacheCss.mobile}`;
149 };
150
151 export default dynamicCss;
152