-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathFAQ.tsx
76 lines (69 loc) · 1.88 KB
/
FAQ.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
66
67
68
69
70
71
72
73
74
75
76
import Image from 'next/image';
import React, { useState } from 'react';
import { motion } from 'framer-motion';
import faqData from '@/lib/FAQ';
type Props = {};
type FAQ = {
question: string;
answer: string;
};
const FAQ = (props: Props) => {
const FAQCard = ({
faq,
number,
handleClick,
}: {
faq: FAQ;
number: number;
handleClick: () => void;
}) => {
const { answer, question } = faq;
return (
<details open={currentOpen === number} onClick={handleClick}>
<summary className="py-2 outline-none text-xl font-bold cursor-pointer focus:underline">
{question}
</summary>
<div className="px-4 pb-4">
<p>{answer}</p>
</div>
</details>
);
};
const [currentOpen, setCurrentOpen] = useState<number>();
return (
<main
id="faqs"
className="w-full sm:h-screen relative text-white p-10 sm:px-20"
>
<Image
src="/assets/background/FAQ.gif"
className="-z-10 object-cover"
alt="FAQ BG"
fill
/>
<div className="flex flex-col sm:flex-row justify-between items-center">
<div className="sm:w-1/2 flex flex-col sm:h-screen">
<h1 className="heading">Frequently</h1>
<h3 className="text-2xl sm:text-5xl">Asked Questions</h3>
</div>
<div className="sm:w-1/2 flex flex-col sm:h-screen py-10 sm:py-0">
<div className="flex flex-col divide-y sm:px-8 lg:px-12 xl:px-32 divide-gray-700">
{faqData.map((faq, idx) => {
return (
<FAQCard
faq={faq}
key={idx}
number={idx}
handleClick={() => {
setCurrentOpen(idx);
}}
/>
);
})}
</div>
</div>
</div>
</main>
);
};
export default FAQ;