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 / social-profile-item / dynamicCss.js

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

163 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { backgroundStyle, gradientHoverStyle } from "../../controls/controls";
2 import { colorControls, objectToCssString, spacingGenerate, wrapInMediaQuery } from "../shared/helpFn";
3
4 const cacheCss = { desktop: "", mobile: "", tablet: "" };
5 const dynamicCss = (attributes, page = "frontend", currentDevice = "all") => {
6 const {
7 uniqueId,
8 socialSingleIcon,
9 socialSingleColor,
10 socialSingleBG,
11 socialSingleBorder,
12 socialSingleBorderWidth,
13 socialSingleBorderRadius,
14 socialSingleBorderHover,
15 socialSingleBorderWidthHover,
16 socialSingleBorderRadiusHover,
17 socialSingleLabelColor,
18 socialSingleSubTextColor,
19 socialSingleAreaBG,
20 socialSingleAreaBorder,
21 socialSingleAreaBorderWidth,
22 socialSingleAreaBorderRadius,
23 socialSingleAreaBorderHover,
24 socialSingleAreaBorderWidthHover,
25 socialSingleAreaBorderRadiusHover,
26 socialSinglePadding,
27 socialSingleMargin,
28 hideOnDesktop,
29 hideOnTablet,
30 hideOnMobile,
31 globalBreakPointData,
32 } = attributes;
33
34 const responsiveCss = (deviceType) => {
35 return [];
36 };
37
38 const desktopCss = [
39 ...responsiveCss("Desktop"),
40 {
41 class: `#${uniqueId}.sp-social-profile-item-container .sp-social-profile-item-wrapper`,
42 styles: {
43 background: colorControls(
44 socialSingleAreaBG?.color?.style,
45 socialSingleAreaBG?.color?.solidColor,
46 socialSingleAreaBG?.color?.gradient
47 ),
48 "border-style": socialSingleAreaBorder.style,
49 "border-color": socialSingleAreaBorder.color,
50 "border-width": spacingGenerate(socialSingleAreaBorderWidth, "Desktop"),
51 "border-radius": spacingGenerate(socialSingleAreaBorderRadius, "Desktop"),
52 padding: spacingGenerate(socialSinglePadding, "Desktop"),
53 margin: spacingGenerate(socialSingleMargin, "Desktop"),
54 },
55 },
56 {
57 class: `#${uniqueId}.sp-social-profile-item-container:hover .sp-social-profile-item-wrapper`,
58 styles: {
59 background: colorControls(
60 socialSingleAreaBG?.hover?.style,
61 socialSingleAreaBG?.hover?.solidColor,
62 socialSingleAreaBG?.hover?.gradient
63 ),
64 "border-style": socialSingleAreaBorderHover.style,
65 "border-color": socialSingleAreaBorderHover.color,
66 "border-width": spacingGenerate(socialSingleAreaBorderWidthHover, "Desktop"),
67 "border-radius": spacingGenerate(socialSingleAreaBorderRadiusHover, "Desktop"),
68 },
69 },
70 {
71 class: `#${uniqueId} .sp-social-profile-item-icon .sp-social-profile-item-icon-class`,
72 styles: {
73 color: socialSingleColor.color,
74 transition: "color 0.3s ease-in-out",
75 },
76 },
77 {
78 class: `#${uniqueId} .sp-social-profile-item-icon .sp-social-profile-item-icon-class:hover`,
79 styles: {
80 color: socialSingleColor.hoverColor,
81 },
82 },
83 {
84 class: `#${uniqueId} .sp-social-profile-item-icon-wrapper`,
85 styles: {
86 background: colorControls(
87 socialSingleBG?.color?.style,
88 socialSingleBG?.color?.solidColor,
89 socialSingleBG?.color?.gradient
90 ),
91 "border-style": socialSingleBorder.style,
92 "border-color": socialSingleBorder.color,
93 "border-width": spacingGenerate(socialSingleBorderWidth, "Desktop"),
94 "border-radius": spacingGenerate(socialSingleBorderRadius, "Desktop"),
95 },
96 },
97 {
98 class: `#${uniqueId} .sp-social-profile-item-icon-wrapper:hover`,
99 styles: {
100 background: colorControls(
101 socialSingleBG?.hover?.style,
102 socialSingleBG?.hover?.solidColor,
103 socialSingleBG?.hover?.gradient
104 ),
105 "border-style": socialSingleBorderHover.style,
106 "border-color": socialSingleBorderHover.color,
107 "border-width": spacingGenerate(socialSingleBorderWidthHover, "Desktop"),
108 "border-radius": spacingGenerate(socialSingleBorderRadiusHover, "Desktop"),
109 },
110 },
111 {
112 class: `#${uniqueId} .sp-social-profile-item-label`,
113 styles: {
114 color: socialSingleLabelColor.color,
115 },
116 },
117 {
118 class: `#${uniqueId}.sp-social-profile-item-container:hover .sp-social-profile-item-label`,
119 styles: {
120 color: socialSingleLabelColor.hoverColor,
121 },
122 },
123 {
124 class: `#${uniqueId} .sp-social-profile-item-sub-text`,
125 styles: {
126 color: socialSingleSubTextColor.color,
127 },
128 },
129 {
130 class: `#${uniqueId}.sp-social-profile-item-container:hover .sp-social-profile-item-sub-text`,
131 styles: {
132 color: socialSingleSubTextColor.hoverColor,
133 },
134 }
135 ];
136
137 cacheCss.desktop = objectToCssString(desktopCss);
138
139 if ("Tablet" === currentDevice || "all" === currentDevice) {
140 const tabletCss = [
141 ...responsiveCss("Tablet")
142 ];
143 cacheCss.tablet = wrapInMediaQuery(
144 objectToCssString(tabletCss),
145 `only screen and (max-width: ${globalBreakPointData?.tablet}px)`
146 );
147 }
148 if ("Mobile" === currentDevice || "all" === currentDevice) {
149 const mobileCss = [
150 ...responsiveCss("Mobile")
151 ];
152
153 cacheCss.mobile = wrapInMediaQuery(
154 objectToCssString(mobileCss),
155 `only screen and (max-width: ${globalBreakPointData?.mobile}px)`
156 );
157 }
158
159 return `${cacheCss.desktop} ${cacheCss.tablet} ${cacheCss.mobile}`;
160 };
161
162 export default dynamicCss;
163