-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from Scout-NU/faq-page
Faq page
- Loading branch information
Showing
17 changed files
with
502 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react" | ||
import { ContactButton } from "../../contact/contact-styles" | ||
import { Banner, CTABackground, CTATitle } from "./FAQContact.styles" | ||
export const FAQContact = ({ | ||
imageUrl, | ||
ctaTitle, | ||
ctaLabel, | ||
ctaDestination, | ||
}) => ( | ||
<> | ||
<Banner imageUrl={imageUrl}> | ||
<CTABackground> | ||
<CTATitle>{ctaTitle}</CTATitle> | ||
<ContactButton href={ctaDestination}>{ctaLabel}</ContactButton> | ||
</CTABackground> | ||
</Banner> | ||
</> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import styled from "@emotion/styled" | ||
import colors from "../../../style/colors" | ||
import dimensions from "../../../style/dimensions" | ||
import { H3 } from "../../../style/type-styles" | ||
import { | ||
layoutPaddingDesktop, | ||
layoutPaddingMobile, | ||
} from "../../../style/variables" | ||
|
||
export const Banner = styled.div` | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
text-align: center; | ||
background-image: url(${props => props.imageUrl}); | ||
width: 100vw; | ||
padding: 40px 60px; | ||
margin: -${layoutPaddingDesktop}; | ||
height: 70vh; | ||
@media (max-width: ${dimensions.maxwidthMobile}px) { | ||
height: 40vh; | ||
margin: -${layoutPaddingMobile}; | ||
} | ||
` | ||
|
||
export const CTABackground = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
background-color: ${colors.white900}; | ||
` | ||
|
||
export const CTATitle = styled(H3)` | ||
color: ${colors.blue900}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { useState } from "react" | ||
import CloseIcon from "../../../vectors/close.svg" | ||
import OpenIcon from "../../../vectors/open.svg" | ||
import { | ||
FAQAnswer, | ||
FAQQuestionTitle, | ||
ToggleContainer, | ||
} from "./FAQQuestion.styles" | ||
|
||
export const FAQQuestion = ({ questionText, answerText }) => { | ||
const [isOpen, setOpen] = useState(false) | ||
|
||
return ( | ||
<> | ||
<ToggleContainer> | ||
<FAQQuestionTitle>{questionText}</FAQQuestionTitle> | ||
{isOpen ? ( | ||
<CloseIcon | ||
onClick={() => setOpen(false)} | ||
role="button" | ||
aria-label="Close FAQ question" | ||
/> | ||
) : ( | ||
<OpenIcon | ||
onClick={() => setOpen(true)} | ||
role="button" | ||
aria-label="Expand FAQ question" | ||
/> | ||
)} | ||
</ToggleContainer> | ||
{isOpen && <FAQAnswer>{answerText}</FAQAnswer>} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import styled from "@emotion/styled" | ||
import colors from "../../../style/colors" | ||
import { Body, H4 } from "../../../style/type-styles" | ||
|
||
export const ToggleContainer = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
width: 100%; | ||
` | ||
|
||
export const FAQQuestionTitle = styled(H4)` | ||
color: ${colors.blue900}; | ||
margin: 0; | ||
` | ||
|
||
export const FAQAnswer = styled(Body)` | ||
color: ${colors.blue900}; | ||
padding-left: 24px; | ||
width: 90%; | ||
line-height: 32px; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from "react" | ||
import { H3 } from "../../style/type-styles" | ||
import { FAQContact } from "./faq-contact/FAQContact" | ||
import { FAQQuestion } from "./faq-question/FAQQuestion" | ||
import { | ||
FAQContainer, | ||
FAQQuestionsContainer, | ||
FAQWrapper, | ||
TopicContainer, | ||
TopicFAQSection, | ||
} from "./faq.styles" | ||
import { TopicsPicker } from "./topics-picker/TopicsPicker" | ||
|
||
const FAQPage = ({ data }) => { | ||
const { | ||
main_section_heading, | ||
topics_section_heading, | ||
cta_button_destination, | ||
cta_button_text, | ||
cta_heading, | ||
ctabackground, | ||
frequently_asked_question, | ||
individual_topic, | ||
} = data | ||
|
||
const [selectedTopic, setSelected] = React.useState() | ||
|
||
return ( | ||
<FAQContainer> | ||
<H3>{main_section_heading}</H3> | ||
<TopicFAQSection> | ||
<TopicContainer> | ||
<TopicsPicker | ||
topics={individual_topic.map((t, i) => ({ | ||
...t, | ||
label: t.topic_heading, | ||
id: t.topic_heading + i, | ||
selected: t.topic_heading === selectedTopic, | ||
questions: frequently_asked_question.filter( | ||
faq => faq.topic === t.topic_heading | ||
), | ||
}))} | ||
onTopicPicked={t => | ||
setSelected( | ||
t.topic_heading === selectedTopic ? undefined : t.topic_heading | ||
) | ||
} | ||
/> | ||
</TopicContainer> | ||
|
||
<FAQQuestionsContainer> | ||
{frequently_asked_question | ||
.filter(fq => (selectedTopic ? fq.topic === selectedTopic : true)) | ||
.map(fq => ( | ||
<FAQWrapper key={fq.question}> | ||
<FAQQuestion | ||
questionText={fq.question} | ||
answerText={fq.answer} | ||
/> | ||
</FAQWrapper> | ||
))} | ||
</FAQQuestionsContainer> | ||
</TopicFAQSection> | ||
<FAQContact | ||
imageUrl={ctabackground.url} | ||
ctaTitle={cta_heading} | ||
ctaLabel={cta_button_text} | ||
ctaDestination={cta_button_destination.url} | ||
/> | ||
</FAQContainer> | ||
) | ||
} | ||
|
||
export default FAQPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import styled from "@emotion/styled" | ||
import dimensions from "../../style/dimensions" | ||
|
||
export const FAQContainer = styled.div` | ||
padding-top: 12vh; | ||
` | ||
export const TopicFAQSection = styled.section` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
@media (max-width: ${dimensions.maxwidthDesktop}px) { | ||
flex-direction: column-reverse; | ||
} | ||
margin-bottom: 20vh; | ||
@media (max-width: ${dimensions.maxwidthMobile}px) { | ||
margin-bottom: 10vh; | ||
} | ||
` | ||
|
||
export const TopicContainer = styled.div` | ||
flex: 4; | ||
` | ||
|
||
export const FAQQuestionsContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
flex: 6; | ||
@media (max-width: ${dimensions.maxwidthDesktop}px) { | ||
display: none; | ||
} | ||
` | ||
|
||
export const FAQWrapper = styled.div` | ||
margin-bottom: 20px; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { useState } from "react" | ||
import { FAQQuestion } from "../faq-question/FAQQuestion" | ||
import { | ||
TopicBox, | ||
TopicFAQContainer, | ||
TopicsContainer, | ||
} from "./TopicsPicker.styles" | ||
|
||
export const TopicsPicker = ({ topics, onTopicPicked }) => { | ||
const [openTopics, setOpen] = useState([]) | ||
const onTopicSelected = topic => { | ||
const { label } = topic | ||
onTopicPicked(topic) | ||
setOpen(prev => | ||
prev.includes(label) ? prev.filter(t => t !== label) : [...prev, label] | ||
) | ||
} | ||
|
||
return ( | ||
<TopicsContainer> | ||
{topics.map(t => ( | ||
<React.Fragment key={t.label}> | ||
<TopicBox | ||
role="button" | ||
aria-label="General FAQ Question topic filter" | ||
onClick={() => onTopicSelected(t)} | ||
selected={t.selected} | ||
> | ||
{t.label} | ||
</TopicBox> | ||
{openTopics.includes(t.label) && | ||
t.questions.map(fq => ( | ||
<TopicFAQContainer key={fq.question}> | ||
<FAQQuestion | ||
questionText={fq.question} | ||
answerText={fq.answer} | ||
/> | ||
</TopicFAQContainer> | ||
))} | ||
</React.Fragment> | ||
))} | ||
</TopicsContainer> | ||
) | ||
} |
Oops, something went wrong.