| 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 |
|