MCPcopy Create free account
hub / github.com/chiragksharma/BuildFast / FAQ

Function FAQ

src/components/FAQ.tsx:8–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import FaqConfig from '@config/FAQ/faq.json';
7
8const FAQ: React.FC = () => {
9
10 const { questions } = FaqConfig;
11
12 const [expanded, setExpanded] = useState<number | null>(null);
13
14 const toggleExpand = (index: number) => {
15 setExpanded(expanded === index ? null : index);
16 };
17
18
19 return (
20 <section className='bg-background-secondary' id='faq'>
21 <div className='flex flex-col overflow-hidden align-middle items-center max-w-sm py-11 px-10 md:py-24 md:px-24 md:max-w-5xl mx-auto rounded-3xl border border-elements-secondary'>
22 <div className='flex flex-col text-center basis-1/2'>
23 <p className='sm:text-4xl text-3xl font-extrabold mb-8'>
24 Frequently Asked Questions
25 </p>
26 <div className='font-normal'>
27 Have another question? Contact me on <a href="">Twitter</a> or by <a href="">email</a>
28 </div>
29 </div>
30 <div className='w-full'>
31 <ul className='mt-9'>
32 {questions.map((item, index) => (
33 <li key={index} className='w-full'>
34 <button
35 className='relative flex gap-2 justify-between items-center w-full py-5 px-4 text-base font-semibold text-left border-t border-t-elements-secondary md:text-lg'
36 onClick={() => toggleExpand(index)}
37 >
38 {item.question}
39 {expanded === index ? <CaretUp /> : <CaretDown />}
40 </button>
41 {expanded === index && (
42 <motion.div
43 initial={{ height: 0 }}
44 animate={{ height: 'auto' }}
45 className='overflow-hidden'
46 >
47 <p className='py-2 px-4'>{item.answer}</p>
48 </motion.div>
49 )}
50 </li>
51 ))}
52 </ul>
53 </div>
54
55 </div>
56 </section>
57);
58};
59
60export default FAQ;

Callers

nothing calls this directly

Calls 1

toggleExpandFunction · 0.85

Tested by

no test coverage detected