-
Notifications
You must be signed in to change notification settings - Fork 153
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
feat(#775): now we see one a question at a time #785
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,33 +1,39 @@ | ||||||
import React, { useState } from "react" | ||||||
import React from "react" | ||||||
import { AnimatePresence, motion } from "framer-motion" | ||||||
|
||||||
import { IoIosArrowDown } from "react-icons/io" | ||||||
|
||||||
const FaqAccordian = ({ faq }) => { | ||||||
const [isOpen, setIsOpen] = useState(false) | ||||||
const FaqAccordian = ({ faq, currentQuestion, setCurrentQuestion }) => { | ||||||
const onClickHandler = () => { | ||||||
if (currentQuestion === faq.id) { | ||||||
return setCurrentQuestion(0) | ||||||
} | ||||||
|
||||||
setCurrentQuestion(faq.id) | ||||||
} | ||||||
|
||||||
return ( | ||||||
<li className="flex items-center justify-center w-9/12 mb-8 flex-column sm:w-9/12 md:w-8/12 lg:w-1/2"> | ||||||
<div | ||||||
onClick={() => setIsOpen(!isOpen)} | ||||||
onKeyDown={() => setIsOpen(!isOpen)} | ||||||
onClick={onClickHandler} | ||||||
onKeyDown={onClickHandler} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
tabIndex={0} | ||||||
role="button" | ||||||
className={`w-full p-8 rounded shadow cursor-pointer details backdrop-blur-lg ${ | ||||||
isOpen ? "bg-white/30" : "bg-white/20" | ||||||
currentQuestion === faq.id ? "bg-white/30" : "bg-white/20" | ||||||
}`} | ||||||
> | ||||||
<p className="relative flex items-center justify-between pr-4 text-base font-bold leading-none text-white list-none"> | ||||||
<span>{faq.questions}</span> | ||||||
<IoIosArrowDown | ||||||
className={`text-2xl duration-200 ${ | ||||||
isOpen && "rotate-180" | ||||||
currentQuestion === faq.id && "rotate-180" | ||||||
}`} | ||||||
/> | ||||||
</p> | ||||||
|
||||||
<AnimatePresence> | ||||||
{isOpen && ( | ||||||
{currentQuestion === faq.id && ( | ||||||
<motion.p | ||||||
initial={{ opacity: 0, height: 0, marginTop: 0 }} | ||||||
animate={{ opacity: 1, height: "auto", marginTop: 12 }} | ||||||
|
@@ -40,7 +46,7 @@ | |||||
</AnimatePresence> | ||||||
</div> | ||||||
</li> | ||||||
) | ||||||
); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
export default FaqAccordian |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,16 +1,20 @@ | ||||||
import Faqs from "data/faq.json" | ||||||
import FaqAccordian from "components/FaqAccordian" | ||||||
import Title from "components/Title" | ||||||
|
||||||
import { faqData } from "data/faq" | ||||||
import { useState } from "react" | ||||||
|
||||||
const Faq = () => { | ||||||
const [currentQuestion, setCurrentQuestion] = useState(1); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
return ( | ||||||
<div> | ||||||
<div className="page-title mb-16 mt-[30px] text-center text-white"> | ||||||
<Title heading="Frequently asked questions" /> | ||||||
</div> | ||||||
<ul className="flex flex-col items-center justify-center"> | ||||||
{Faqs.map((faq, idx) => ( | ||||||
<FaqAccordian key={idx} faq={faq} /> | ||||||
{faqData.map((faq) => ( | ||||||
<FaqAccordian key={faq.id} faq={faq} currentQuestion={currentQuestion} setCurrentQuestion={setCurrentQuestion} /> | ||||||
))} | ||||||
</ul> | ||||||
</div> | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,36 @@ | ||||||
export const faqData = [ | ||||||
{ | ||||||
id: 1, | ||||||
questions: 'What does "4C" stands for?', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
answers: '4C stands for "Cool Community of Content Creators".', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
{ | ||||||
id: 2, | ||||||
questions: 'What is the goal of "4C"? ', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
answers: | ||||||
"We discuss Content Creation using Videos, Articles and Social Media. Our goal is to create a decentralized community, where everyone can create some events related to the community on their channels.", | ||||||
}, | ||||||
{ | ||||||
id: 3, | ||||||
questions: 'Is "4C" open-source and how can I contribute?', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
answers: | ||||||
"4C is open source. All contributions are welcome. Visit our contributions page to learn how you can contribute.", | ||||||
}, | ||||||
{ | ||||||
id: 4, | ||||||
questions: "How can I join the community?", | ||||||
answers: "Join our Discord Server and visit the #start-here channel.", | ||||||
}, | ||||||
{ | ||||||
id: 5, | ||||||
questions: 'Is "4C" only for experienced content creators?', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
answers: | ||||||
"Absolutely no. The community fosters growth on all levels, irrespective of prior experience —a platform where you can talk about your ideas and get opinions on how to execute them.", | ||||||
}, | ||||||
{ | ||||||
id: 6, | ||||||
questions: 'What are the benefits of the "4C" community?', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
answers: | ||||||
"You get support, activities, collaborations, free dedicated content creation webinars (yes, you got it right ! 😄), coffee chat, and a meme channel! ", | ||||||
}, | ||||||
]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
onClickHandler
function is used for bothonClick
andonKeyDown
events. This means that any key press will trigger the function, which may not be the desired behavior. Consider checking the key code in theonKeyDown
event to ensure that the function is only triggered by specific keys (e.g., Enter or Space).