| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { useState } from "@wordpress/element"; |
| 3 |
import { Background, Border, Spacing, SpColorPicker, SPToggleGroupControl } from "../../components"; |
| 4 |
import { jsonParse } from "../shared/helpFn"; |
| 5 |
import { BgIcon, GradientIcon, TransparentIcon } from "../../components/background/svgIcon"; |
| 6 |
|
| 7 |
export const SocialSingleIconStyleTab = ({ attributes, setAttributes }) => { |
| 8 |
const { |
| 9 |
socialSingleColor, |
| 10 |
socialSingleBG, |
| 11 |
socialSingleBorder, |
| 12 |
socialSingleBorderWidth, |
| 13 |
socialSingleBorderRadius, |
| 14 |
socialSingleBorderHover, |
| 15 |
socialSingleBorderWidthHover, |
| 16 |
socialSingleBorderRadiusHover, |
| 17 |
socialSingleIconType, |
| 18 |
} = attributes; |
| 19 |
const [colorState, setColorState] = useState("color"); |
| 20 |
|
| 21 |
return ( |
| 22 |
<> |
| 23 |
<SPToggleGroupControl |
| 24 |
attributes={colorState} |
| 25 |
onClick={(newValue) => setColorState(newValue)} |
| 26 |
items={[ |
| 27 |
{ label: "Normal", value: "color" }, |
| 28 |
{ label: "Hover", value: "hover" }, |
| 29 |
]} |
| 30 |
/> |
| 31 |
{"icon" === socialSingleIconType && ( |
| 32 |
<> |
| 33 |
{"color" === colorState ? ( |
| 34 |
<> |
| 35 |
<SpColorPicker |
| 36 |
label={__("Icon Color", "post-carousel")} |
| 37 |
value={socialSingleColor?.color} |
| 38 |
onChange={(newValue) => |
| 39 |
setAttributes({ |
| 40 |
socialSingleColor: { |
| 41 |
...socialSingleColor, |
| 42 |
color: newValue, |
| 43 |
}, |
| 44 |
}) |
| 45 |
} |
| 46 |
/> |
| 47 |
</> |
| 48 |
) : ( |
| 49 |
<> |
| 50 |
<SpColorPicker |
| 51 |
label={__("Icon Color", "post-carousel")} |
| 52 |
value={socialSingleColor?.hover} |
| 53 |
onChange={(newValue) => |
| 54 |
setAttributes({ |
| 55 |
socialSingleColor: { |
| 56 |
...socialSingleColor, |
| 57 |
hover: newValue, |
| 58 |
}, |
| 59 |
}) |
| 60 |
} |
| 61 |
/> |
| 62 |
</> |
| 63 |
)} |
| 64 |
</> |
| 65 |
)} |
| 66 |
<Background |
| 67 |
label={__("Background Type", "post-carousel")} |
| 68 |
attributes={socialSingleBG} |
| 69 |
attributesKey={"socialSingleBG"} |
| 70 |
setAttributes={setAttributes} |
| 71 |
colorType={colorState} |
| 72 |
items={[ |
| 73 |
{ |
| 74 |
label: <TransparentIcon />, |
| 75 |
value: "transparent", |
| 76 |
tooltip: "Transparent", |
| 77 |
}, |
| 78 |
{ |
| 79 |
label: <BgIcon />, |
| 80 |
value: "bgColor", |
| 81 |
tooltip: "Solid", |
| 82 |
}, |
| 83 |
{ |
| 84 |
label: <GradientIcon />, |
| 85 |
value: "gradient", |
| 86 |
tooltip: "Gradient", |
| 87 |
}, |
| 88 |
]} |
| 89 |
/> |
| 90 |
{"color" === colorState ? ( |
| 91 |
<> |
| 92 |
<Border |
| 93 |
attributes={{ |
| 94 |
border: socialSingleBorder, |
| 95 |
borderWidth: socialSingleBorderWidth, |
| 96 |
}} |
| 97 |
attributesKey={{ |
| 98 |
border: "socialSingleBorder", |
| 99 |
borderWidth: "socialSingleBorderWidth", |
| 100 |
}} |
| 101 |
setAttributes={setAttributes} |
| 102 |
btnType={"normal"} |
| 103 |
/> |
| 104 |
<Spacing |
| 105 |
label={__("Border Radius", "post-carousel")} |
| 106 |
attributes={socialSingleBorderRadius} |
| 107 |
attributesKey={"socialSingleBorderRadius"} |
| 108 |
setAttributes={setAttributes} |
| 109 |
units={["px", "%", "em"]} |
| 110 |
defaultValue={{ |
| 111 |
unit: "%", |
| 112 |
value: { top: 0, right: 0, bottom: 0, left: 0 }, |
| 113 |
}} |
| 114 |
indicator={"radius"} |
| 115 |
/> |
| 116 |
</> |
| 117 |
) : ( |
| 118 |
<> |
| 119 |
<Border |
| 120 |
label={__("Border on Hover", "post-carousel")} |
| 121 |
attributes={{ |
| 122 |
border: socialSingleBorderHover, |
| 123 |
borderWidth: socialSingleBorderWidthHover, |
| 124 |
}} |
| 125 |
attributesKey={{ |
| 126 |
border: "socialSingleBorderHover", |
| 127 |
borderWidth: "socialSingleBorderWidthHover", |
| 128 |
}} |
| 129 |
setAttributes={setAttributes} |
| 130 |
btnType={"normal"} |
| 131 |
/> |
| 132 |
<Spacing |
| 133 |
label={__("Border Radius on Hover", "post-carousel")} |
| 134 |
attributes={socialSingleBorderRadiusHover} |
| 135 |
attributesKey={"socialSingleBorderRadiusHover"} |
| 136 |
setAttributes={setAttributes} |
| 137 |
units={["px", "%", "em"]} |
| 138 |
defaultValue={{ |
| 139 |
unit: "%", |
| 140 |
value: { top: 0, right: 0, bottom: 0, left: 0 }, |
| 141 |
}} |
| 142 |
indicator={"radius"} |
| 143 |
/> |
| 144 |
</> |
| 145 |
)} |
| 146 |
</> |
| 147 |
); |
| 148 |
}; |
| 149 |
|
| 150 |
export const SocialSingleLabelStyleTab = ({ attributes, setAttributes }) => { |
| 151 |
const { socialSingleLabelColor, socialSingleSubTextColor } = attributes; |
| 152 |
const [colorState, setColorState] = useState("color"); |
| 153 |
|
| 154 |
return ( |
| 155 |
<> |
| 156 |
<SPToggleGroupControl |
| 157 |
attributes={colorState} |
| 158 |
onClick={(newValue) => setColorState(newValue)} |
| 159 |
items={[ |
| 160 |
{ label: "Normal", value: "color" }, |
| 161 |
{ label: "Hover", value: "hover" }, |
| 162 |
]} |
| 163 |
/> |
| 164 |
{"color" === colorState ? ( |
| 165 |
<> |
| 166 |
<SpColorPicker |
| 167 |
label={__("Color", "post-carousel")} |
| 168 |
value={socialSingleLabelColor.color} |
| 169 |
onChange={(newValue) => |
| 170 |
setAttributes({ |
| 171 |
socialSingleLabelColor: { |
| 172 |
...socialSingleLabelColor, |
| 173 |
color: newValue, |
| 174 |
}, |
| 175 |
}) |
| 176 |
} |
| 177 |
/> |
| 178 |
<SpColorPicker |
| 179 |
label={__("Sub Text Color", "post-carousel")} |
| 180 |
value={socialSingleSubTextColor.color} |
| 181 |
onChange={(newValue) => |
| 182 |
setAttributes({ |
| 183 |
socialSingleSubTextColor: { |
| 184 |
...socialSingleSubTextColor, |
| 185 |
color: newValue, |
| 186 |
}, |
| 187 |
}) |
| 188 |
} |
| 189 |
/> |
| 190 |
</> |
| 191 |
) : ( |
| 192 |
<> |
| 193 |
<SpColorPicker |
| 194 |
label={__("Color", "post-carousel")} |
| 195 |
value={socialSingleLabelColor.hoverColor} |
| 196 |
onChange={(newValue) => |
| 197 |
setAttributes({ |
| 198 |
socialSingleLabelColor: { |
| 199 |
...socialSingleLabelColor, |
| 200 |
hoverColor: newValue, |
| 201 |
}, |
| 202 |
}) |
| 203 |
} |
| 204 |
/> |
| 205 |
<SpColorPicker |
| 206 |
label={__("Sub Text Color", "post-carousel")} |
| 207 |
value={socialSingleSubTextColor.hoverColor} |
| 208 |
onChange={(newValue) => |
| 209 |
setAttributes({ |
| 210 |
socialSingleSubTextColor: { |
| 211 |
...socialSingleSubTextColor, |
| 212 |
hoverColor: newValue, |
| 213 |
}, |
| 214 |
}) |
| 215 |
} |
| 216 |
/> |
| 217 |
</> |
| 218 |
)} |
| 219 |
</> |
| 220 |
); |
| 221 |
}; |
| 222 |
|