From ad3d2a198dc0b7b52f5ba13e436f14b80a47dc33 Mon Sep 17 00:00:00 2001 From: ajeeshRS Date: Tue, 17 Sep 2024 20:20:19 +0530 Subject: [PATCH] Updates faq-section --- src/app/faqs/page.tsx | 19 ------ src/app/globals.css | 4 ++ src/app/page.tsx | 2 + src/components/Faqs.tsx | 89 ++++++++++++++++++++++++--- src/components/FaqsGetintouchCard.tsx | 4 +- src/lib/constant/app.constant.ts | 2 +- 6 files changed, 88 insertions(+), 32 deletions(-) delete mode 100644 src/app/faqs/page.tsx diff --git a/src/app/faqs/page.tsx b/src/app/faqs/page.tsx deleted file mode 100644 index 5ff61030..00000000 --- a/src/app/faqs/page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import Faqs from '@/components/Faqs'; -import FaqsGetintouchCard from '@/components/FaqsGetintouchCard'; - -export default function Page() { - return ( -
-
-

- Frequently Asked Questions -

-

- Quick answers to your questions you may have. -

-
- - -
- ); -} diff --git a/src/app/globals.css b/src/app/globals.css index 301c0d12..1ed50e36 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -372,3 +372,7 @@ .pac-logo.hdpi::after { content: none; } + +html { + scroll-behavior: smooth; +} \ No newline at end of file diff --git a/src/app/page.tsx b/src/app/page.tsx index d207eec6..aeb0c4e6 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,5 @@ import BackgroundSvg from '@/components/BackgroundSvg'; +import Faqs from '@/components/Faqs'; import HalfCircleGradient from '@/components/HalfCircleGradient'; import HeroSection from '@/components/hero-section'; import { JobLanding } from '@/components/job-landing'; @@ -19,6 +20,7 @@ const HomePage = async ({
+ ); diff --git a/src/components/Faqs.tsx b/src/components/Faqs.tsx index f6d6f6fa..6d83850a 100644 --- a/src/components/Faqs.tsx +++ b/src/components/Faqs.tsx @@ -1,18 +1,87 @@ +'use client'; import { faqData } from '@/lib/constant/faqs.constants'; +import { ChevronDown } from 'lucide-react'; +import { useEffect, useRef, useState } from 'react'; +import FaqsGetintouchCard from './FaqsGetintouchCard'; export default function Faqs() { + const [expandedIndex, setExpandedIndex] = useState(null); + + const expandRef = useRef<(HTMLDivElement | null)[]>([]); + + const toggleExpand = (index: number | null) => { + setExpandedIndex(index === expandedIndex ? null : index); + }; + + const handleClickOutside = (event: MouseEvent) => { + if ( + expandedIndex !== null && + expandRef.current[expandedIndex] && + !expandRef.current[expandedIndex].contains(event.target as Node) + ) { + setExpandedIndex(null); + } + }; + + useEffect(() => { + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, [expandedIndex]); + return ( -
-
- {faqData.map((faq, i) => ( -
-

{`Q. ${faq.question}`}

-

- {faq.answer} -

-
- ))} +
+
+

FAQs

+

+ Quick answers to any questions you may have.{' '} +

+
+ +
+
+ {faqData.map((faq, i) => ( +
{ + expandRef.current[i] = el; + }} + className={`w-full flex h-fit flex-col items-start md:p-6 p-4 ${i !== faqData.length - 1 && 'border-b'}`} + > +
toggleExpand(i)} + > +
+

+ {faq.question} +

+ +
+
+ +

+ {faq.answer} +

+
+ ))} +
+
); } diff --git a/src/components/FaqsGetintouchCard.tsx b/src/components/FaqsGetintouchCard.tsx index 07eaa9f3..fbe1937c 100644 --- a/src/components/FaqsGetintouchCard.tsx +++ b/src/components/FaqsGetintouchCard.tsx @@ -2,9 +2,9 @@ import { Button } from './ui/button'; export default function FaqsGetintouchCard() { return ( -
+

- Can't find what you are looking ? + Can't find what you're looking for?

diff --git a/src/lib/constant/app.constant.ts b/src/lib/constant/app.constant.ts index 300c8ea2..9de956c7 100644 --- a/src/lib/constant/app.constant.ts +++ b/src/lib/constant/app.constant.ts @@ -14,7 +14,7 @@ export const navbar = [ { id: 3, label: 'Internship', path: '/' }, { id: 4, label: 'Testimonials', path: '/' }, - { id: 5, label: 'FAQs', path: '/faqs' }, + { id: 5, label: 'FAQs', path: '#faq' }, { id: 6, label: 'Post a Job', path: APP_PATHS.POST_JOB },