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

feat(#775): now we see one a question at a time #785

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# #!/usr/bin/env sh
# . "$(dirname -- "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# npx --no -- commitlint --edit "$1"
npx --no -- commitlint --edit "$1"
24 changes: 15 additions & 9 deletions src/components/FaqAccordian.js
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}
Comment on lines +18 to +19
Copy link

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 both onClick and onKeyDown events. This means that any key press will trigger the function, which may not be the desired behavior. Consider checking the key code in the onKeyDown event to ensure that the function is only triggered by specific keys (e.g., Enter or Space).

- onKeyDown={onClickHandler}
+ onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') onClickHandler() }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onKeyDown={onClickHandler}
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') onClickHandler() }}

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 }}
Expand All @@ -40,7 +46,7 @@
</AnimatePresence>
</div>
</li>
)
);

Check failure on line 49 in src/components/FaqAccordian.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Extra semicolon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
);
)

}

export default FaqAccordian
10 changes: 7 additions & 3 deletions src/components/faq.js
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);

Check failure on line 8 in src/components/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Extra semicolon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [currentQuestion, setCurrentQuestion] = useState(1);
const [currentQuestion, setCurrentQuestion] = useState(1)


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>
Expand Down
36 changes: 36 additions & 0 deletions src/data/faq.js
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?',

Check warning on line 4 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Strings must use doublequote

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
questions: 'What does "4C" stands for?',
questions: "What does "4C" stands for?",

answers: '4C stands for "Cool Community of Content Creators".',

Check warning on line 5 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Strings must use doublequote

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
answers: '4C stands for "Cool Community of Content Creators".',
answers: "4C stands for \"Cool Community of Content Creators\".",

},
{
id: 2,
questions: 'What is the goal of "4C"? ',

Check warning on line 9 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Strings must use doublequote

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
questions: 'What is the goal of "4C"? ',
questions: "What is the goal of "4C"?",

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?',

Check warning on line 15 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Strings must use doublequote

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
questions: 'Is "4C" open-source and how can I contribute?',
questions: "Is \"4C\" open-source and how can I contribute?",

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?',

Check warning on line 26 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Strings must use doublequote

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
questions: 'Is "4C" only for experienced content creators?',
questions: "Is \"4C\" only for experienced content creators?",

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?',

Check warning on line 32 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Strings must use doublequote

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
questions: 'What are the benefits of the "4C" community?',
questions: 'What are the benefits of the \"4C\" community?',

answers:
"You get support, activities, collaborations, free dedicated content creation webinars (yes, you got it right ! 😄), coffee chat, and a meme channel! ",
},
];

Check failure on line 36 in src/data/faq.js

View workflow job for this annotation

GitHub Actions / Lint Before Release

Extra semicolon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
];
]

26 changes: 0 additions & 26 deletions src/data/faq.json

This file was deleted.

Loading