-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTitleParagraph.tsx
50 lines (45 loc) · 1.46 KB
/
TitleParagraph.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* eslint-disable @next/next/no-img-element */
import {motion} from "framer-motion";
import {FunctionComponent} from "react";
import DOMPurify from "isomorphic-dompurify";
import fadeInUp from "../animations/animations";
interface IProps {
title: string;
paragraph: string;
}
const TitleParagraph: FunctionComponent<IProps> = ({title, paragraph}) => {
/* Check if paragraph content is null
And Displays content if it null */
function isParagraphContent(isParagraphContent: string) {
let contentStyling: string;
if (isParagraphContent === null || isParagraphContent === undefined) {
contentStyling =
"hidden mt-4 w-full lg:max-w-[75rem] mx-auto py-8 px-4 text-center text-darkGrey text-medium";
} else {
contentStyling =
"block mt-4 w-full lg:max-w-[75rem] mx-auto py-8 px-4 text-center text-darkGrey text-medium";
}
return contentStyling;
}
function createParagraphMarkup(paragraphContent: string) {
return {
__html: DOMPurify.sanitize(paragraphContent),
};
}
return (
<section className="py-20 px-4 lg:px-0">
<div className="container p-0 mx-auto">
<motion.div variants={fadeInUp}>
<h2 className="text-black text-center tracking-normal leading-[2.75rem] font-[600] text-2xl sm:text-3xl lg:text-5xl">
{title}
</h2>
<div
className={isParagraphContent(paragraph)}
dangerouslySetInnerHTML={createParagraphMarkup(paragraph)}
/>
</motion.div>
</div>
</section>
);
};
export default TitleParagraph;