Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FAQSection.tsx #1487

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions components/defaultLanding/FAQSection.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { useState } from 'react';
import { useTranslation } from 'next-i18next';
import { Card } from 'react-daisyui';

import faqs from './data/faq.json';

const FAQSection = () => {
const { t } = useTranslation('common');
const [openFAQ, setOpenFAQ] = useState(null);

const handleToggle = (index) => {
setOpenFAQ(openFAQ === index ? null : index);
};

return (
<section className="py-6">
<div className="flex flex-col justify-center space-y-6">
Expand All @@ -16,13 +23,31 @@ const FAQSection = () => {
industry.
</p>
<div className="flex items-center justify-center">
<div className="grid grid-cols-1 gap-2">
<div className="grid grid-cols-1 gap-2 w-full">
{faqs.map((faq, index) => {
const isOpen = openFAQ === index;
return (
<Card key={index} className="border-none">
<Card.Body className="items-left dark:border-gray-200 border border-gray-300">
<Card.Title tag="h2">Q. {faq.question}</Card.Title>
<p>A. {faq.answer}</p>
<Card
key={index}
className="border-none w-4/5 mx-auto hover:bg-[#2563eb] hover:text-white translate-x-1 duration-300 rounded-xl"
>
<Card.Body className="dark:border-gray-200 border-[2px] border-gray-400 text-center items-center">
<Card.Title
tag="h2"
className="cursor-pointer"
onClick={() => handleToggle(index)}
>
Q. {faq.question}
</Card.Title>
<div
className={`overflow-hidden transition-all duration-500 ${
isOpen ? 'max-h-full' : 'max-h-0'
}`}
>
<p className={`${isOpen ? 'block' : 'hidden'} mt-2`}>
A. {faq.answer}
</p>
</div>
</Card.Body>
</Card>
);
Expand Down