Skip to content

Commit

Permalink
feat: add bg to FAQ section
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Nov 9, 2023
1 parent 75c3160 commit c4320d6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 34 deletions.
Binary file added public/images/Campaigns/faq-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 46 additions & 34 deletions src/components/Campaign/Faq/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { TypeFaqSkeleton } from '@/contentful/types'
import type { Entry } from 'contentful'
import layoutCss from '@/components/common/styles.module.css'
import css from './styles.module.css'
import BackgroundImage from '@/public/images/Campaigns/faq-bg.png'
import Image from 'next/image'

type FaqEntry = Entry<TypeFaqSkeleton, undefined, string>

Expand All @@ -24,42 +26,52 @@ const Faq = (props: FaqEntry) => {
if (!Array.isArray(faqData)) return null

return (
<Container className={layoutCss.containerMedium}>
<Grid container position="relative">
<div className={css.spot} />
<Grid item md={1} />
<Grid item md={4}>
<Typography variant="h1">{props.fields.title}</Typography>
</Grid>
<Grid item md={7}>
{faqData.map((item, index) => {
const handleChange: AccordionProps['onChange'] = (_, expanded) => {
setOpenMap((prev) => ({
...prev,
[index]: expanded,
}))
}
<>
<Image className={css.bg} src={BackgroundImage} alt="blocks background" />
<Container className={layoutCss.containerMedium}>
<Grid container className={css.gridContainer}>
<div className={css.spot} />
<Grid item md={1} />

<Grid item md={2} width="100%">
<Typography variant="h1" className={css.title}>
{props.fields.title}
</Typography>
</Grid>

<Grid item md={2} />

<Grid item md={7}>
{faqData.map((item, index) => {
const handleChange: AccordionProps['onChange'] = (_, expanded) => {
setOpenMap((prev) => ({
...prev,
[index]: expanded,
}))
}

return (
<Accordion
className={css.accordion}
expanded={openMap?.[index] ?? false}
onChange={handleChange}
key={item.question}
disableGutters
>
<AccordionSummary expandIcon={openMap?.[index] ? <MinusIcon /> : <PlusIcon />}>
<Typography variant="h4">{item.question}</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography>{item.answer}</Typography>
</AccordionDetails>
</Accordion>
)
})}
return (
<Accordion
className={css.accordion}
expanded={openMap?.[index] ?? false}
onChange={handleChange}
key={item.question}
disableGutters
square
>
<AccordionSummary expandIcon={openMap?.[index] ? <MinusIcon /> : <PlusIcon />}>
<Typography variant="h4">{item.question}</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography>{item.answer}</Typography>
</AccordionDetails>
</Accordion>
)
})}
</Grid>
</Grid>
</Grid>
</Container>
</Container>
</>
)
}

Expand Down
20 changes: 20 additions & 0 deletions src/components/Campaign/Faq/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.bg {
margin-bottom: -225px;
}

.gridContainer {
position: relative;
}

.spot {
position: absolute;
left: -300px;
Expand All @@ -9,6 +17,10 @@
filter: blur(50px);
}

.title {
text-align: center;
}

.accordion {
background-color: unset;
box-shadow: none;
Expand All @@ -30,3 +42,11 @@
.accordion :global .MuiAccordionDetails-root {
padding: 0 0 32px;
}

@media (min-width: 900px) {
.bg {
position: absolute;
left: 0px;
width: 66%;
}
}

0 comments on commit c4320d6

Please sign in to comment.