PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
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 / admin / components / utils / moduleDynamicCss.js

moduleDynamicCss.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.3, at src/admin/components/utils/moduleDynamicCss.js

177 lines 4.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 } from "../../../blocks/shared/helpFn";
2
3 const moduleDynamicCss = (attributes) => {
4 const {
5 icon_size,
6 typography,
7 font_size,
8 line_height,
9 letter_spacing,
10 word_spacing,
11 color,
12 background_color,
13 border,
14 border_width,
15 border_radius,
16 box_shadow_enable,
17 box_shadow,
18 padding,
19 margin,
20 horizontal_position,
21 vertical_position,
22 box_shadow_enable_hover,
23 box_shadow_hover,
24 } = attributes;
25
26 const staticCss = [
27 {
28 class: `#sp-smart-post-back-to-top-btn.sp-smart-post-back-to-top-wrapper`,
29 styles: {
30 display: "inline-block",
31 background: colorControls(
32 background_color?.color?.style,
33 background_color?.color?.solidColor,
34 background_color?.color?.gradient
35 ),
36 "border-style": border?.style,
37 "border-color": border?.color,
38 "border-width": spacingGenerate(border_width),
39 "border-radius": spacingGenerate(border_radius),
40 padding: spacingGenerate(padding),
41 margin: spacingGenerate(margin),
42 position: "fixed",
43 bottom: 0,
44 cursor: "pointer",
45 "z-index": "999",
46 transition: "background 0.3s, border-color 0.3s, box-shadow 0.3s",
47 },
48 },
49 {
50 class: `#sp-smart-post-back-to-top-btn.sp-smart-post-back-to-top-wrapper:hover`,
51 styles: {
52 background: colorControls(
53 background_color?.hover?.style,
54 background_color?.hover?.solidColor,
55 background_color?.hover?.gradient
56 ),
57 "border-color": border?.hoverColor,
58 },
59 },
60 {
61 class: `#sp-smart-post-back-to-top-btn .sp-smart-post-back-to-top-icon`,
62 styles: {
63 display: "inline-block",
64 color: color?.color,
65 width: icon_size?.value + icon_size.unit,
66 height: icon_size?.value + icon_size.unit,
67 transition: "color 0.3s",
68 },
69 },
70 {
71 class: `#sp-smart-post-back-to-top-btn .sp-smart-post-back-to-top-text`,
72 styles: {
73 color: color?.color,
74 "font-family": typography.typography.family,
75 "font-style": typography.typography.style,
76 "font-weight": typography.typography.fontWeight,
77 "text-decoration": typography.typography.decoration,
78 "text-transform": typography.typography.transform,
79 "font-size": font_size?.value + font_size.unit,
80 "line-height": line_height?.value,
81 "letter-spacing": letter_spacing?.value + letter_spacing?.unit,
82 "word-spacing": word_spacing?.value + word_spacing?.unit,
83 transition: "color 0.3s",
84 },
85 },
86 {
87 class: `#sp-smart-post-back-to-top-btn:hover .sp-smart-post-back-to-top-icon, #sp-smart-post-back-to-top-btn:hover .sp-smart-post-back-to-top-text`,
88 styles: {
89 color: color.hoverColor,
90 },
91 },
92 {
93 class: `#sp-smart-post-back-to-top-btn.sp-smart-post-back-to-top-wrapper.sp-position-button-right`,
94 styles: {
95 left: "unset",
96 right: horizontal_position.value + horizontal_position.unit,
97 bottom: vertical_position.value + vertical_position.unit,
98 },
99 },
100 {
101 class: `#sp-smart-post-back-to-top-btn.sp-smart-post-back-to-top-wrapper.sp-position-button-left`,
102 styles: {
103 right: "unset",
104 left: horizontal_position.value + horizontal_position.unit,
105 bottom: vertical_position.value + vertical_position.unit,
106 },
107 },
108 // Static CSS.
109 {
110 class: `#sp-smart-post-back-to-top-btn .sp-smart-post-back-to-top-button`,
111 styles: {
112 display: "flex",
113 "align-items": "center",
114 "justify-content": "center",
115 gap: "8px",
116 },
117 },
118 {
119 class: `#sp-smart-post-back-to-top-btn .sp-smart-post-back-to-top-icon svg`,
120 styles: {
121 width: "inherit",
122 height: "inherit",
123 },
124 },
125 {
126 class: `#sp-smart-post-back-to-top-btn .sp-smart-post-back-to-top-btn-text .sp-hide-label`,
127 styles: {
128 display: "none",
129 visibility: "hidden",
130 opacity: "0",
131 width: "0",
132 height: "0",
133 transition: "all 0.9s ease",
134 },
135 },
136 {
137 class: `#sp-smart-post-back-to-top-btn .sp-smart-post-back-to-top-btn-text .sp-show-label`,
138 styles: {
139 display: "flex",
140 visibility: "visible",
141 opacity: "1",
142 width: "fit-content",
143 height: "fit-content",
144 transition: "all 0.9s ease",
145 },
146 },
147 ];
148 if (box_shadow_enable) {
149 staticCss.push(
150 ...[
151 {
152 class: `#sp-smart-post-back-to-top-btn.sp-smart-post-back-to-top-wrapper`,
153 styles: {
154 "box-shadow": boxCss(box_shadow_enable, "Desktop", box_shadow, "color"),
155 },
156 },
157 ]
158 );
159 }
160 if (box_shadow_enable_hover) {
161 staticCss.push(
162 ...[
163 {
164 class: `#sp-smart-post-back-to-top-btn.sp-smart-post-back-to-top-wrapper:hover`,
165 styles: {
166 "box-shadow": boxCss(box_shadow_enable_hover, "Desktop", box_shadow_hover, "color"),
167 },
168 },
169 ]
170 );
171 }
172 const dynamicStyle = objectToCssString(staticCss);
173
174 return dynamicStyle;
175 };
176 export default moduleDynamicCss;
177