| 1 |
import { RichText, useBlockProps } from "@wordpress/block-editor"; |
| 2 |
import HeadingWrapper from "./headingWrapper"; |
| 3 |
import { SectionNineteenImage } from "../../icons/icons"; |
| 4 |
import classNames from "classnames"; |
| 5 |
|
| 6 |
const SectionHeadingSave = ({ attributes }) => { |
| 7 |
const { |
| 8 |
uniqueId, |
| 9 |
sectionHeadingLabel, |
| 10 |
sectionHeadingLinkUrl, |
| 11 |
sectionHeadingStyle, |
| 12 |
showSectionHeading, |
| 13 |
sectionHeadingHTMLTag: HeadingTag, |
| 14 |
sectionHeadingStyleBackgroundColor, |
| 15 |
showSubHeading, |
| 16 |
sectionSubHeadingAliment, |
| 17 |
subHeadingLabel, |
| 18 |
additionalCssClass, |
| 19 |
sectionHeadingGlobalTypo, |
| 20 |
sectionSubHeadingGlobalTypography, |
| 21 |
} = attributes; |
| 22 |
|
| 23 |
const blockProps = useBlockProps.save(); |
| 24 |
const className = classNames("sp-section-heading-container", sectionHeadingStyle); |
| 25 |
const renderSectionNineteenImage = sectionHeadingStyle === "section-heading-nineteen" && ( |
| 26 |
<SectionNineteenImage sectionHeadingStyleBackgroundColor={sectionHeadingStyleBackgroundColor} /> |
| 27 |
); |
| 28 |
|
| 29 |
return ( |
| 30 |
<div {...blockProps}> |
| 31 |
{showSectionHeading && ( |
| 32 |
<div |
| 33 |
id={uniqueId} |
| 34 |
className={classNames("sp-smart-post-wrapper", "sp-section-heading-wrapper", additionalCssClass)} |
| 35 |
> |
| 36 |
<HeadingWrapper sectionHeadingLinkUrl={sectionHeadingLinkUrl} classNames={className}> |
| 37 |
<div className={"section-heading-tag"}> |
| 38 |
{sectionHeadingStyle === "section-heading-twentyOne" ? ( |
| 39 |
<span> |
| 40 |
<RichText.Content |
| 41 |
tagName={HeadingTag} |
| 42 |
className={classNames( |
| 43 |
"sp-heading-text", |
| 44 |
sectionHeadingGlobalTypo?.class ? sectionHeadingGlobalTypo.class : "" |
| 45 |
)} |
| 46 |
value={sectionHeadingLabel} |
| 47 |
/> |
| 48 |
</span> |
| 49 |
) : ( |
| 50 |
<RichText.Content |
| 51 |
tagName={HeadingTag} |
| 52 |
className={classNames( |
| 53 |
"sp-heading-text", |
| 54 |
sectionHeadingGlobalTypo?.class ? sectionHeadingGlobalTypo.class : "" |
| 55 |
)} |
| 56 |
value={sectionHeadingLabel} |
| 57 |
/> |
| 58 |
)} |
| 59 |
{renderSectionNineteenImage} |
| 60 |
</div> |
| 61 |
</HeadingWrapper> |
| 62 |
{showSubHeading && ( |
| 63 |
<div |
| 64 |
className={classNames( |
| 65 |
"sp-section-subheading-container", |
| 66 |
"sp-d-flex", |
| 67 |
"sp-justify-" + sectionSubHeadingAliment |
| 68 |
)} |
| 69 |
> |
| 70 |
<RichText.Content |
| 71 |
className={classNames( |
| 72 |
"sp-subheading-text", |
| 73 |
sectionSubHeadingGlobalTypography?.class |
| 74 |
? sectionSubHeadingGlobalTypography.class |
| 75 |
: "" |
| 76 |
)} |
| 77 |
tagName="span" |
| 78 |
value={subHeadingLabel} |
| 79 |
/> |
| 80 |
</div> |
| 81 |
)} |
| 82 |
</div> |
| 83 |
)} |
| 84 |
</div> |
| 85 |
); |
| 86 |
}; |
| 87 |
|
| 88 |
export default SectionHeadingSave; |
| 89 |
|