| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { |
| 4 |
Toggle, |
| 5 |
SPRangeControl, |
| 6 |
SpColorPicker, |
| 7 |
Spacing, |
| 8 |
SelectDropdown, |
| 9 |
TabControls, |
| 10 |
TypographyNew, |
| 11 |
} from "../../components"; |
| 12 |
import { |
| 13 |
SectionHeadingIconTwo, |
| 14 |
SectionHeadingIconThree, |
| 15 |
SectionHeadingIconFour, |
| 16 |
SectionHeadingIconSix, |
| 17 |
SectionHeadingIconFive, |
| 18 |
SectionHeadingIconSeven, |
| 19 |
SectionHeadingIconEight, |
| 20 |
SectionHeadingIconNine, |
| 21 |
SectionHeadingIconTen, |
| 22 |
SectionHeadingIconEleven, |
| 23 |
SectionHeadingIconTwelve, |
| 24 |
SectionHeadingIconThirteen, |
| 25 |
SectionHeadingIconFourteen, |
| 26 |
SectionHeadingIconFifteen, |
| 27 |
SectionHeadingIconSixteen, |
| 28 |
SectionHeadingIconSeventeen, |
| 29 |
SectionHeadingIconEightTeen, |
| 30 |
SectionHeadingIconNineteen, |
| 31 |
SectionHeadingIconTwenty, |
| 32 |
SectionHeadingIconTwentyOne, |
| 33 |
SectionHeadingIconTwentyTwo, |
| 34 |
SectionHeadingIconTwentyThree, |
| 35 |
SectionHeadingIconTwentyFour, |
| 36 |
AlignCenter, |
| 37 |
AlignLeft, |
| 38 |
AlignRight, |
| 39 |
} from "../../icons/icons"; |
| 40 |
import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; |
| 41 |
import { AdvancedTab, VisibilityTab } from "../shared/advancedTab"; |
| 42 |
|
| 43 |
const Inspector = ({ attributes, setAttributes }) => { |
| 44 |
const { |
| 45 |
sectionHeading, |
| 46 |
showSectionHeading, |
| 47 |
sectionHeadingStyle, |
| 48 |
sectionHeadingHTMLTag, |
| 49 |
sectionHeadingAliment, |
| 50 |
showSubHeading, |
| 51 |
sectionHeadingTypography, |
| 52 |
sectionHeadingFontSize, |
| 53 |
sectionHeadingFontSpacing, |
| 54 |
sectionHeadingLineHeight, |
| 55 |
sectionHeadingColor, |
| 56 |
sectionHeadingMargin, |
| 57 |
sectionSubHeadingAliment, |
| 58 |
sectionSubHeadingTypography, |
| 59 |
sectionSubHeadingFontSize, |
| 60 |
sectionSubHeadingFontSpacing, |
| 61 |
sectionSubHeadingLineHeight, |
| 62 |
sectionSubHeadingColor, |
| 63 |
sectionSubHeadingMargin, |
| 64 |
sectionHeadingStyleBackgroundColor, |
| 65 |
sectionHeadingPadding, |
| 66 |
sectionHeadingBorderRadius, |
| 67 |
sectionHeadingWordSpacing, |
| 68 |
sectionSubHeadingWordSpacing, |
| 69 |
headingLineThickness, |
| 70 |
} = attributes; |
| 71 |
|
| 72 |
const showRadius = [ |
| 73 |
"section-heading-two", |
| 74 |
"section-heading-three", |
| 75 |
"section-heading-five", |
| 76 |
"section-heading-eleven", |
| 77 |
"section-heading-twelve", |
| 78 |
"section-heading-fourteen", |
| 79 |
"section-heading-twentyTwo", |
| 80 |
"section-heading-twentyThree", |
| 81 |
"section-heading-twentyFour", |
| 82 |
].includes(sectionHeadingStyle); |
| 83 |
|
| 84 |
const updateHeadingStyle = (newValue) => { |
| 85 |
if (newValue === sectionHeadingStyle) return; |
| 86 |
setAttributes({ sectionHeadingStyle: newValue }); |
| 87 |
}; |
| 88 |
|
| 89 |
return ( |
| 90 |
<> |
| 91 |
<PanelBody |
| 92 |
initialOpen={true} |
| 93 |
title={__("General", "post-carousel")} |
| 94 |
className="sp-smart-post-section-heading-block-panel-body" |
| 95 |
> |
| 96 |
<SPToggleGroupControl |
| 97 |
attributes={sectionHeading} |
| 98 |
attributesKey={"sectionHeading"} |
| 99 |
setAttributes={setAttributes} |
| 100 |
items={[ |
| 101 |
{ label: "Heading", value: "heading" }, |
| 102 |
{ label: "Sub Heading", value: "sub_heading" }, |
| 103 |
]} |
| 104 |
/> |
| 105 |
{sectionHeading == "heading" && ( |
| 106 |
<Toggle |
| 107 |
label={__("Show Heading", "post-carousel")} |
| 108 |
attributes={showSectionHeading} |
| 109 |
setAttributes={setAttributes} |
| 110 |
attributesKey={"showSectionHeading"} |
| 111 |
/> |
| 112 |
)} |
| 113 |
{sectionHeading == "sub_heading" && ( |
| 114 |
<Toggle |
| 115 |
label={__("Show Sub Heading", "post-carousel")} |
| 116 |
attributes={showSubHeading} |
| 117 |
setAttributes={setAttributes} |
| 118 |
attributesKey={"showSubHeading"} |
| 119 |
/> |
| 120 |
)} |
| 121 |
{sectionHeading == "heading" && showSectionHeading && ( |
| 122 |
<> |
| 123 |
<SelectDropdown |
| 124 |
label={__("Heading Style", "post-carousel")} |
| 125 |
attributes={sectionHeadingStyle} |
| 126 |
attributesKey={"sectionHeadingStyle"} |
| 127 |
setAttributes={setAttributes} |
| 128 |
className="sp-smart-section-heading-dropdown" |
| 129 |
onClick={(newValue) => updateHeadingStyle(newValue)} |
| 130 |
options={[ |
| 131 |
{ |
| 132 |
label: "Section Heading 01", |
| 133 |
value: "section-heading-one", |
| 134 |
}, |
| 135 |
{ |
| 136 |
icon: <SectionHeadingIconTwo />, |
| 137 |
value: "section-heading-two", |
| 138 |
}, |
| 139 |
{ |
| 140 |
icon: <SectionHeadingIconThree />, |
| 141 |
value: "section-heading-three", |
| 142 |
}, |
| 143 |
{ |
| 144 |
icon: <SectionHeadingIconFour />, |
| 145 |
value: "section-heading-four", |
| 146 |
}, |
| 147 |
{ |
| 148 |
icon: <SectionHeadingIconFive />, |
| 149 |
value: "section-heading-five", |
| 150 |
}, |
| 151 |
{ |
| 152 |
icon: <SectionHeadingIconSix />, |
| 153 |
value: "section-heading-six", |
| 154 |
}, |
| 155 |
{ |
| 156 |
icon: <SectionHeadingIconSeven />, |
| 157 |
value: "section-heading-seven", |
| 158 |
}, |
| 159 |
{ |
| 160 |
icon: <SectionHeadingIconEight />, |
| 161 |
value: "section-heading-eight", |
| 162 |
}, |
| 163 |
{ |
| 164 |
icon: <SectionHeadingIconNine />, |
| 165 |
value: "section-heading-nine", |
| 166 |
}, |
| 167 |
{ |
| 168 |
icon: <SectionHeadingIconTen />, |
| 169 |
value: "section-heading-ten", |
| 170 |
}, |
| 171 |
{ |
| 172 |
icon: <SectionHeadingIconEleven />, |
| 173 |
value: "section-heading-eleven", |
| 174 |
}, |
| 175 |
{ |
| 176 |
icon: <SectionHeadingIconTwelve />, |
| 177 |
value: "section-heading-twelve", |
| 178 |
}, |
| 179 |
{ |
| 180 |
icon: <SectionHeadingIconThirteen />, |
| 181 |
value: "section-heading-thirteen", |
| 182 |
}, |
| 183 |
{ |
| 184 |
icon: <SectionHeadingIconFourteen />, |
| 185 |
value: "section-heading-fourteen", |
| 186 |
}, |
| 187 |
{ |
| 188 |
icon: <SectionHeadingIconFifteen />, |
| 189 |
value: "section-heading-fifteen", |
| 190 |
}, |
| 191 |
{ |
| 192 |
icon: <SectionHeadingIconSixteen />, |
| 193 |
value: "section-heading-sixteen", |
| 194 |
}, |
| 195 |
{ |
| 196 |
icon: <SectionHeadingIconSeventeen />, |
| 197 |
value: "section-heading-seventeen", |
| 198 |
}, |
| 199 |
{ |
| 200 |
icon: <SectionHeadingIconEightTeen />, |
| 201 |
value: "section-heading-eightTeen", |
| 202 |
}, |
| 203 |
{ |
| 204 |
icon: <SectionHeadingIconNineteen />, |
| 205 |
value: "section-heading-nineteen", |
| 206 |
}, |
| 207 |
{ |
| 208 |
icon: <SectionHeadingIconTwenty />, |
| 209 |
value: "section-heading-twenty", |
| 210 |
}, |
| 211 |
{ |
| 212 |
icon: <SectionHeadingIconTwentyOne />, |
| 213 |
value: "section-heading-twentyOne", |
| 214 |
}, |
| 215 |
{ |
| 216 |
icon: <SectionHeadingIconTwentyTwo />, |
| 217 |
value: "section-heading-twentyTwo", |
| 218 |
}, |
| 219 |
{ |
| 220 |
icon: <SectionHeadingIconTwentyThree />, |
| 221 |
value: "section-heading-twentyThree", |
| 222 |
}, |
| 223 |
{ |
| 224 |
icon: <SectionHeadingIconTwentyFour />, |
| 225 |
value: "section-heading-twentyFour", |
| 226 |
}, |
| 227 |
]} |
| 228 |
/> |
| 229 |
{![ |
| 230 |
"section-heading-one", |
| 231 |
"section-heading-two", |
| 232 |
"section-heading-eleven", |
| 233 |
"section-heading-twelve", |
| 234 |
"section-heading-twentyThree", |
| 235 |
"section-heading-twentyFour", |
| 236 |
].includes(sectionHeadingStyle) && ( |
| 237 |
<SPRangeControl |
| 238 |
label={ __("Heading Line Thickness", "post-carousel") } |
| 239 |
attributes={ headingLineThickness } |
| 240 |
attributesKey={ "headingLineThickness" } |
| 241 |
setAttributes={ setAttributes } |
| 242 |
units={["px"]} |
| 243 |
defaultValue={{ unit: "px", value: 2 }} |
| 244 |
min={1} |
| 245 |
max={10} |
| 246 |
/> |
| 247 |
) } |
| 248 |
<SPToggleGroupControl |
| 249 |
label={__("HTML Tag", "post-carousel")} |
| 250 |
attributes={sectionHeadingHTMLTag} |
| 251 |
attributesKey={"sectionHeadingHTMLTag"} |
| 252 |
setAttributes={setAttributes} |
| 253 |
items={[ |
| 254 |
{ label: "H1", value: "h1" }, |
| 255 |
{ label: "H2", value: "h2" }, |
| 256 |
{ label: "H3", value: "h3" }, |
| 257 |
{ label: "H4", value: "h4" }, |
| 258 |
{ label: "H5", value: "h5" }, |
| 259 |
{ label: "H6", value: "h6" }, |
| 260 |
{ label: "P", value: "p" }, |
| 261 |
]} |
| 262 |
/> |
| 263 |
{!["section-heading-nine", "section-heading-twentyOne"].includes(sectionHeadingStyle) && ( |
| 264 |
<SPToggleGroupControl |
| 265 |
attributes={sectionHeadingAliment} |
| 266 |
attributesKey={"sectionHeadingAliment"} |
| 267 |
label={__("Alignment", "post-carousel")} |
| 268 |
setAttributes={setAttributes} |
| 269 |
items={[ |
| 270 |
{ label: <AlignLeft />, value: "left" }, |
| 271 |
{ label: <AlignCenter />, value: "center" }, |
| 272 |
{ label: <AlignRight />, value: "right" }, |
| 273 |
]} |
| 274 |
/> |
| 275 |
)} |
| 276 |
<TypographyNew |
| 277 |
attributes={{ |
| 278 |
family: sectionHeadingTypography, |
| 279 |
familyKey: "sectionHeadingTypography", |
| 280 |
fontSize: sectionHeadingFontSize, |
| 281 |
fontSizeKey: "sectionHeadingFontSize", |
| 282 |
fontSpacing: sectionHeadingFontSpacing, |
| 283 |
fontSpacingKey: "sectionHeadingFontSpacing", |
| 284 |
lineHeight: sectionHeadingLineHeight, |
| 285 |
lineHeightKey: "sectionHeadingLineHeight", |
| 286 |
wordSpacing: sectionHeadingWordSpacing, |
| 287 |
wordSpacingKey: "sectionHeadingWordSpacing", |
| 288 |
globalTypo: attributes.sectionHeadingGlobalTypo, |
| 289 |
globalTypoKey: "sectionHeadingGlobalTypo", |
| 290 |
}} |
| 291 |
setAttributes={setAttributes} |
| 292 |
spacingDefaultValue={{ unit: "px", value: 0 }} |
| 293 |
fontSizeDefault={{ unit: "px", value: 32 }} |
| 294 |
lineDefaultValue={""} |
| 295 |
fontSizePresetType="heading" |
| 296 |
/> |
| 297 |
{sectionHeadingStyle !== "section-heading-one" && ( |
| 298 |
<SpColorPicker |
| 299 |
label={__("Heading Background Color", "post-carousel")} |
| 300 |
value={sectionHeadingStyleBackgroundColor.color} |
| 301 |
onChange={(newColor) => |
| 302 |
setAttributes({ |
| 303 |
sectionHeadingStyleBackgroundColor: { |
| 304 |
...sectionHeadingStyleBackgroundColor, |
| 305 |
color: newColor, |
| 306 |
}, |
| 307 |
}) |
| 308 |
} |
| 309 |
defaultColor="#2271B1" |
| 310 |
/> |
| 311 |
)} |
| 312 |
<SpColorPicker |
| 313 |
label={__("Color", "post-carousel")} |
| 314 |
value={sectionHeadingColor.color} |
| 315 |
defaultColor={"#222222"} |
| 316 |
onChange={(newColor) => |
| 317 |
setAttributes({ |
| 318 |
sectionHeadingColor: { |
| 319 |
...sectionHeadingColor, |
| 320 |
color: newColor, |
| 321 |
}, |
| 322 |
}) |
| 323 |
} |
| 324 |
/> |
| 325 |
{showRadius && ( |
| 326 |
<SPRangeControl |
| 327 |
label={__("Border Radius", "post-carousel")} |
| 328 |
attributes={sectionHeadingBorderRadius} |
| 329 |
attributesKey={"sectionHeadingBorderRadius"} |
| 330 |
setAttributes={setAttributes} |
| 331 |
units={["px", "%", "Em"]} |
| 332 |
defaultValue={{ unit: "px", value: 0 }} |
| 333 |
max="100" |
| 334 |
/> |
| 335 |
)} |
| 336 |
<Spacing |
| 337 |
label={__("Padding", "post-carousel")} |
| 338 |
attributes={sectionHeadingPadding} |
| 339 |
attributesKey={"sectionHeadingPadding"} |
| 340 |
setAttributes={setAttributes} |
| 341 |
units={["px", "%", "em"]} |
| 342 |
labelItem={{ |
| 343 |
top: __("Top", "post-carousel"), |
| 344 |
right: __("Right", "post-carousel"), |
| 345 |
bottom: __("Bottom", "post-carousel"), |
| 346 |
left: __("Left", "post-carousel"), |
| 347 |
}} |
| 348 |
defaultValue={{ |
| 349 |
unit: "px", |
| 350 |
value: { |
| 351 |
top: "", |
| 352 |
right: "", |
| 353 |
bottom: "", |
| 354 |
left: "", |
| 355 |
}, |
| 356 |
}} |
| 357 |
/> |
| 358 |
<Spacing |
| 359 |
label={__("Margin", "post-carousel")} |
| 360 |
attributes={sectionHeadingMargin} |
| 361 |
attributesKey={"sectionHeadingMargin"} |
| 362 |
setAttributes={setAttributes} |
| 363 |
units={["px", "%", "em"]} |
| 364 |
labelItem={{ |
| 365 |
top: __("Top", "post-carousel"), |
| 366 |
right: __("Right", "post-carousel"), |
| 367 |
bottom: __("Bottom", "post-carousel"), |
| 368 |
left: __("Left", "post-carousel"), |
| 369 |
}} |
| 370 |
defaultValue={{ |
| 371 |
unit: "px", |
| 372 |
value: { |
| 373 |
top: "", |
| 374 |
right: "", |
| 375 |
bottom: "", |
| 376 |
left: "", |
| 377 |
}, |
| 378 |
}} |
| 379 |
/> |
| 380 |
</> |
| 381 |
)} |
| 382 |
{sectionHeading == "sub_heading" && showSubHeading && ( |
| 383 |
<> |
| 384 |
<SPToggleGroupControl |
| 385 |
attributes={sectionSubHeadingAliment} |
| 386 |
attributesKey={"sectionSubHeadingAliment"} |
| 387 |
label={__("Alignment", "post-carousel")} |
| 388 |
setAttributes={setAttributes} |
| 389 |
items={[ |
| 390 |
{ label: <AlignLeft />, value: "left" }, |
| 391 |
{ label: <AlignCenter />, value: "center" }, |
| 392 |
{ label: <AlignRight />, value: "right" }, |
| 393 |
]} |
| 394 |
/> |
| 395 |
<TypographyNew |
| 396 |
attributes={{ |
| 397 |
family: sectionSubHeadingTypography, |
| 398 |
familyKey: "sectionSubHeadingTypography", |
| 399 |
fontSize: sectionSubHeadingFontSize, |
| 400 |
fontSizeKey: "sectionSubHeadingFontSize", |
| 401 |
fontSpacing: sectionSubHeadingFontSpacing, |
| 402 |
fontSpacingKey: "sectionSubHeadingFontSpacing", |
| 403 |
lineHeight: sectionSubHeadingLineHeight, |
| 404 |
lineHeightKey: "sectionSubHeadingLineHeight", |
| 405 |
wordSpacing: sectionSubHeadingWordSpacing, |
| 406 |
wordSpacingKey: "sectionSubHeadingWordSpacing", |
| 407 |
globalTypo: attributes.sectionSubHeadingGlobalTypography, |
| 408 |
globalTypoKey: "sectionSubHeadingGlobalTypography", |
| 409 |
}} |
| 410 |
setAttributes={setAttributes} |
| 411 |
spacingDefaultValue={{ unit: "px", value: 0 }} |
| 412 |
fontSizeDefault={{ unit: "px", value: 18 }} |
| 413 |
lineDefaultValue={""} |
| 414 |
fontSizePresetType="body" |
| 415 |
/> |
| 416 |
<SpColorPicker |
| 417 |
label={__("Color", "post-carousel")} |
| 418 |
value={sectionSubHeadingColor.color} |
| 419 |
onChange={(newColor) => |
| 420 |
setAttributes({ |
| 421 |
sectionSubHeadingColor: { |
| 422 |
...sectionSubHeadingColor, |
| 423 |
color: newColor, |
| 424 |
}, |
| 425 |
}) |
| 426 |
} |
| 427 |
/> |
| 428 |
<Spacing |
| 429 |
label={__("Margin", "post-carousel")} |
| 430 |
attributes={sectionSubHeadingMargin} |
| 431 |
attributesKey={"sectionSubHeadingMargin"} |
| 432 |
setAttributes={setAttributes} |
| 433 |
units={["px", "%", "em"]} |
| 434 |
labelItem={{ |
| 435 |
top: __("Top", "post-carousel"), |
| 436 |
right: __("Right", "post-carousel"), |
| 437 |
bottom: __("Bottom", "post-carousel"), |
| 438 |
left: __("Left", "post-carousel"), |
| 439 |
}} |
| 440 |
defaultValue={{ |
| 441 |
unit: "px", |
| 442 |
value: { |
| 443 |
top: "12", |
| 444 |
right: "0", |
| 445 |
bottom: "0", |
| 446 |
left: "0", |
| 447 |
}, |
| 448 |
}} |
| 449 |
/> |
| 450 |
</> |
| 451 |
)} |
| 452 |
</PanelBody> |
| 453 |
<PanelBody initialOpen={false} title={__("Advanced", "post-carousel")}> |
| 454 |
<TabControls |
| 455 |
attributes={attributes} |
| 456 |
setAttributes={setAttributes} |
| 457 |
AdvancedTab={AdvancedTab} |
| 458 |
VisibilityTab={VisibilityTab} |
| 459 |
displayIcon={false} |
| 460 |
initialTab={"visibility"} |
| 461 |
/> |
| 462 |
</PanelBody> |
| 463 |
</> |
| 464 |
); |
| 465 |
}; |
| 466 |
|
| 467 |
export default Inspector; |
| 468 |
|