-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeroSectionTwo.tsx
65 lines (61 loc) · 1.73 KB
/
HeroSectionTwo.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {motion} from "framer-motion";
import {FunctionComponent} from "react";
import DOMPurify from "isomorphic-dompurify";
import {fadeInUp} from "../animations/animations";
import styles from "../styles/components/HeroSection.module.scss";
interface IProps {
title: string;
subtitle: string;
backgroundImage: string;
}
const HeroSectionTwo: FunctionComponent<IProps> = ({
title,
subtitle,
backgroundImage,
}) => {
/* Check if Subtitle content is null
And Displays content if it null */
function isSubtitleContent(isSubtitleContent) {
let contentStyling: string;
if (isSubtitleContent === null) {
contentStyling =
"hidden mt-4 max-w-[65rem] mx-auto mb-5 md:mb-10 font-[400] text-medium sm:text-lg text-center text-white tracking-[0.10rem]";
} else {
contentStyling =
"block mt-4 max-w-[65rem] mx-auto mb-5 md:mb-10 font-[400] text-medium sm:text-lg text-center text-white tracking-[0.10rem]";
}
return contentStyling;
}
function createSubtitleMarkup() {
return {
__html: DOMPurify.sanitize(`${subtitle}`),
};
}
return (
<section
className={styles.heroSectionTwo}
style={{
backgroundImage: `linear-gradient(
0deg,
rgba(0, 0, 0, 0.30),
rgba(0, 0, 0, 0.30)
),url("${backgroundImage}")`,
}}
>
<div className="container p-0 mx-auto">
<div className="flex flex-col items-center justify-center">
<motion.div variants={fadeInUp} className="px-8 py-5">
<h1 className="text-white text-center text-4xl font-[600] sm:text-6xl">
{title}
</h1>
<div
className={isSubtitleContent(subtitle)}
dangerouslySetInnerHTML={createSubtitleMarkup()}
/>
</motion.div>
</div>
</div>
</section>
);
};
export default HeroSectionTwo;