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

Conversation

alisamadiii
Copy link
Contributor

@alisamadiii alisamadiii commented Oct 16, 2023

Closes #775

Summary by CodeRabbit

  • New Feature: Enhanced the FAQ section with an interactive accordion feature. Users can now click on a question to view the answer, providing a more streamlined and intuitive experience.
  • Refactor: Updated the data source for FAQs, improving the ease of updating and managing FAQ content.
  • Chore: Improved code quality and maintainability by enforcing commit message standards using a commit linter. This ensures more readable and consistent commit messages, aiding team collaboration.

@vercel
Copy link

vercel bot commented Oct 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
4c-site ❌ Failed (Inspect) Oct 24, 2023 9:51am

@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2023


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between 77ee9ab and 6ad983e.
Files ignored due to filter (1)
  • src/data/faq.json
Files selected for processing (4)
  • .husky/commit-msg (1 hunks)
  • src/components/FaqAccordian.js (2 hunks)
  • src/components/faq.js (1 hunks)
  • src/data/faq.js (1 hunks)
Files skipped from review due to trivial changes (1)
  • .husky/commit-msg
Additional comments (Suppressed): 9
src/data/faq.js (1)
  • 1-36: The data structure and content of the FAQs look good. The id field is unique for each FAQ, which is important for identifying each FAQ uniquely in the UI. The questions and answers fields are self-explanatory and contain the necessary information.
src/components/faq.js (4)
  • 1-4: The import statements have been updated to import faqData from "data/faq" instead of Faqs from "data/faq.json". This change implies that the data source for FAQs has been updated. Please ensure that the new data source is correctly set up and contains the expected data structure.

  • 8-8: The useState hook is used to manage the currentQuestion state. This is a new addition to the component and it's used to track the currently selected FAQ question.

  • 16-18: The FaqAccordian component now receives two additional props: currentQuestion and setCurrentQuestion. Ensure that the FaqAccordian component has been updated to handle these new props correctly.

  • 16-18: The key prop for the FaqAccordian component has been changed from idx to faq.id. This change assumes that each FAQ object has a unique id property. Please verify that this is the case to avoid potential issues with React's reconciliation process.

src/components/FaqAccordian.js (4)
  • 6-13: The onClickHandler function has been modified to set the currentQuestion to the faq.id of the clicked FAQ item. If the clicked FAQ item is already the currentQuestion, it resets the currentQuestion to 0. This change allows only one FAQ item to be open at a time. Ensure that this behavior is intended and that the currentQuestion state is properly managed in the parent component.

  • 22-24: The conditional class assignment based on whether currentQuestion equals faq.id has been correctly updated from the previous isOpen state. This change is consistent with the new behavior of allowing only one FAQ item to be open at a time.

  • 29-31: The rotation of the arrow icon is now based on whether currentQuestion equals faq.id, which is consistent with the new behavior of allowing only one FAQ item to be open at a time.

  • 36-39: The conditional rendering of the answer paragraph is now based on whether currentQuestion equals faq.id, which is consistent with the new behavior of allowing only one FAQ item to be open at a time.

Comment on lines +18 to +19
onClick={onClickHandler}
onKeyDown={onClickHandler}
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() }}

@tobySolutions
Copy link
Collaborator

Hey there @AliReza1083, can you check your Linting issues here? There seems to be an error.

Copy link

@kkrishguptaa kkrishguptaa left a comment

Choose a reason for hiding this comment

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

Please run eslint once and check out the comment by @coderabbitai

@alisamadiii
Copy link
Contributor Author

I am doing it but I keep getting the same issues.
image

onClick={() => setIsOpen(!isOpen)}
onKeyDown={() => setIsOpen(!isOpen)}
onClick={onClickHandler}
onKeyDown={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() }}

@@ -40,7 +46,7 @@ const FaqAccordian = ({ faq }) => {
</AnimatePresence>
</div>
</li>
)
);

Choose a reason for hiding this comment

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

Suggested change
);
)

const Faq = () => {
const [currentQuestion, setCurrentQuestion] = useState(1);

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)

export const faqData = [
{
id: 1,
questions: 'What does "4C" stands for?',

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

{
id: 1,
questions: 'What does "4C" stands for?',
answers: '4C stands for "Cool Community of Content Creators".',

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

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

},
{
id: 3,
questions: 'Is "4C" open-source and how can I contribute?',

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

},
{
id: 5,
questions: 'Is "4C" only for experienced content creators?',

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

},
{
id: 6,
questions: 'What are the benefits of the "4C" community?',

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! ",
},
];

Choose a reason for hiding this comment

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

Suggested change
];
]

@FrancescoXX
Copy link
Owner

@AliReza1083 @tobySolutions I am closing this

@FrancescoXX FrancescoXX closed this Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat]: Seeing one Question at a time
4 participants