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

fix faq dropdown function #376

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
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
Binary file added public/hackcamp2023meta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/hc-og.png
Binary file not shown.
15 changes: 5 additions & 10 deletions src/components/FaqBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const Container = styled.div`
overflow:hidden;

${p => p.expanded
? `
? `
border-color: #C4B2F0;
`
: `
: `
border-color: #C4B2F0;
`}

Expand Down Expand Up @@ -75,15 +75,10 @@ const Arrow = ({ color }) => (
</svg>
)

const FaqBox = ({ question, answer }) => {
const [isExpanded, setIsExpanded] = useState(false)

const FaqBox = ({ question, answer, isExpanded, onExpand }) => {
return (
<Container
expanded={isExpanded}>
<Top
expanded={isExpanded}
onClick={() => setIsExpanded(!isExpanded)}>
<Container expanded={isExpanded}>
<Top expanded={isExpanded} onClick={onExpand}>
{question}
<TopExpand style={isExpanded ? { transform: 'rotate(0)' } : { transform: 'rotate(180deg)' }}>
<Arrow color={isExpanded ? '#2C2543' : '#2C2543'} />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Index ({ title }) {
participants can learn new skills, connect with fellow tech
enthusiasts, and build solutions to tackle challenges together."
/>
<meta property="og:image" content="/hc-og.png" />
<meta property="og:image" content="/hackcamp2023meta.png" />
</Head>

{/* Components Starts */}
Expand Down
41 changes: 31 additions & 10 deletions src/sections/Faq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const bobbing = keyframes`
50% {
transform: translateY(-20px);
}
`;
`

const Nugget = styled.div`
background: url('assets/background/faq/nugget.png') no-repeat;
Expand Down Expand Up @@ -211,16 +211,31 @@ display:none;
}
`

const FaqCollection = ({ category, faqs }) => (
const FaqCollection = ({ category, faqs, expandedQuestion, setExpandedQuestion }) => (
<CollectionContainer>
<CollectionName>{category}</CollectionName>

{faqs.map(q => <FaqBox key={q.question} question={q.question} answer={q.answer} />)}
{faqs.map(q =>
<FaqBox
key={q.question}
question={q.question}
answer={q.answer}
isExpanded={expandedQuestion === q.question}
onExpand={() => {
if (expandedQuestion === q.question) {
setExpandedQuestion(null)
} else {
setExpandedQuestion(q.question)
}
}}
/>
)}
</CollectionContainer>
)

const Faq = () => {
const [faqData, setFaqData] = useState(null)
const [expandedQuestion, setExpandedQuestion] = useState(null)

// (@htdf processData)
// (@signature (listof FAQ) -> Object)
Expand Down Expand Up @@ -249,7 +264,7 @@ const Faq = () => {
<Nugget></Nugget>
<BearArm />
<DeerArm></DeerArm>
<BgScroll/>
<BgScroll />
<Wrapper id="faq">
<StyledTitle>
FAQ
Expand All @@ -258,24 +273,30 @@ const Faq = () => {
{faqData
? (
<FaqGrid>

<FaqColumn>
{faqData.General &&
<FaqCollection category="General" faqs={faqData.General} />
<FaqCollection
category="General"
faqs={faqData.General}
expandedQuestion={expandedQuestion}
setExpandedQuestion={setExpandedQuestion}
/>
}
</FaqColumn>

<FaqColumn>
{faqData["Teams & Projects"] &&
<FaqCollection category="Projects" faqs={faqData["Teams & Projects"]} />
{faqData['Teams & Projects'] &&
<FaqCollection category="Projects" faqs={faqData['Teams & Projects']} expandedQuestion={expandedQuestion}
setExpandedQuestion={setExpandedQuestion} />
}
{faqData.Logistics &&
<FaqCollection category="Logistics" faqs={faqData.Logistics} />
<FaqCollection category="Logistics" faqs={faqData.Logistics} expandedQuestion={expandedQuestion}
setExpandedQuestion={setExpandedQuestion} />
}
</FaqColumn>

</FaqGrid>
)
)
: 'loading...'}

</Wrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/sections/Learn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const StyledText = styled.div`
z-index:4;

${(p) => p.theme.mediaQueries.mobile} {
flex-direction: column-reverse;
flex-direction: column;
align-items: center;
margin-top: 55vw;
gap: 80vw;
Expand Down
Loading