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

[FAQs] Structure on FAQs section #12

Merged
merged 11 commits into from
Feb 8, 2024
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# IDE
.idea/

130 changes: 130 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"html-react-parser": "^5.1.2",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18",
Expand Down
162 changes: 161 additions & 1 deletion src/app/components/FAQs.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,163 @@
import styled from "styled-components";
import {
applications_faqs,
hackupc_faqs,
teams_faqs,
travel_faqs,
} from "@/app/data/faqs_data";
import parse from "html-react-parser";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { useState } from "react";
import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
import {
MobileBreakpoint,
Primary100,
Secondary500,
SpacingL,
SpacingM,
SpacingS,
SpacingXS,
} from "@/app/genericComponents/tokens";
import { Section } from "@/app/genericComponents/General";
import { BlockTitle, Body, SectionTitle } from "@/app/genericComponents/Fonts";

const Split = styled.div`
display: flex;
justify-content: center;
gap: ${SpacingL};

@media (max-width: ${MobileBreakpoint}) {
flex-direction: column;
}
`;

const ColumnsQuestions = styled.div`
display: flex;
flex-direction: column;
gap: ${SpacingL};
width: 45%;

@media (max-width: ${MobileBreakpoint}) {
width: 100%;
}
`;

const QuestionsBlock = styled.div`
display: flex;
flex-direction: column;
gap: ${SpacingS};
`;

const Question = styled.div`
display: flex;
justify-content: flex-start;
gap: ${SpacingS};
`;

const QuestionTitle = styled(Body)`
margin-bottom: ${SpacingXS};
font-weight: 700;
`;

const LastBlock = styled.div`
text-align: center;
margin-top: ${SpacingM};
`;

export default function FAQs() {
return <div>This is the FAQs :)</div>;
const [activeFaqId, setActiveFaqId] = useState<null | number>(null);

const toggleFaq = (id: number) => {
// If the clicked FAQ is already active, close it, otherwise open the clicked FAQ
setActiveFaqId(activeFaqId === id ? null : id);
};

return (
<Section>
<SectionTitle>FAQs</SectionTitle>
<Split>
<ColumnsQuestions>
<QuestionsBlock>
<BlockTitle color={Secondary500}>About HackUPC</BlockTitle>
{hackupc_faqs.map((faq) => (
<Question key={faq.id} onClick={() => toggleFaq(faq.id)}>
<FontAwesomeIcon
icon={activeFaqId === faq.id ? faMinus : faPlus}
style={{ marginTop: 4 }}
color={activeFaqId === faq.id ? Secondary500 : Primary100}
/>
<div>
<QuestionTitle>{faq.question}</QuestionTitle>
{activeFaqId === faq.id && <Body>{parse(faq.answer)}</Body>}
</div>
</Question>
))}
</QuestionsBlock>
<QuestionsBlock>
<BlockTitle color={Secondary500}>Travel Reimbursement</BlockTitle>
{travel_faqs.map((faq) => (
<Question key={faq.id} onClick={() => toggleFaq(faq.id)}>
<FontAwesomeIcon
icon={activeFaqId === faq.id ? faMinus : faPlus}
style={{ marginTop: 4 }}
color={activeFaqId === faq.id ? Secondary500 : Primary100}
/>
<div>
<QuestionTitle>{faq.question}</QuestionTitle>
{activeFaqId === faq.id && <Body>{parse(faq.answer)}</Body>}
</div>
</Question>
))}
</QuestionsBlock>
</ColumnsQuestions>
<ColumnsQuestions>
<QuestionsBlock>
<BlockTitle color={Secondary500}>Applications</BlockTitle>
{applications_faqs.map((faq) => (
<Question key={faq.id} onClick={() => toggleFaq(faq.id)}>
<FontAwesomeIcon
icon={activeFaqId === faq.id ? faMinus : faPlus}
style={{ marginTop: 4 }}
color={activeFaqId === faq.id ? Secondary500 : Primary100}
/>
<div>
<QuestionTitle>{faq.question}</QuestionTitle>
{activeFaqId === faq.id && <Body>{parse(faq.answer)}</Body>}
</div>
</Question>
))}
</QuestionsBlock>
<QuestionsBlock>
<BlockTitle color={Secondary500}>Teams</BlockTitle>
{teams_faqs.map((faq) => (
<Question key={faq.id} onClick={() => toggleFaq(faq.id)}>
<FontAwesomeIcon
icon={activeFaqId === faq.id ? faMinus : faPlus}
style={{ marginTop: 4 }}
color={activeFaqId === faq.id ? Secondary500 : Primary100}
/>
<div>
<QuestionTitle>{faq.question}</QuestionTitle>
{activeFaqId === faq.id && <Body>{parse(faq.answer)}</Body>}
</div>
</Question>
))}
</QuestionsBlock>
</ColumnsQuestions>
</Split>
<LastBlock>
<BlockTitle color={Secondary500}>
What if I have another question?
</BlockTitle>
<Body style={{ paddingBottom: SpacingS }}>
DM or tag us on X @hackupc or, if you want to contact us via email,
drop us a line at [email protected].
</Body>
<Body>
If your issue is related to Travel Reimbursment, write us at
[email protected]
</Body>
</LastBlock>
</Section>
);
}
Loading
Loading