Skip to content

Commit

Permalink
feat: add Testimonials section to About page (#266)
Browse files Browse the repository at this point in the history
Co-authored-by: Klaudia <[email protected]>
  • Loading branch information
paulgrym and imklau authored May 6, 2024
1 parent 5d00206 commit 2d2c0dc
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Typography from "design-system/components/typography"
import { string } from "prop-types"
import * as Styled from "./TestimonialCard.styled"

const TestimonialCard = ({ title, excerpt, author, authorDetails }) => {
const TestimonialCard = ({ title, excerpt, author, authorDetails, as }) => {
const theme = useTheme()

return (
Expand All @@ -17,7 +17,7 @@ const TestimonialCard = ({ title, excerpt, author, authorDetails }) => {
<Icon name="quote" />
</Styled.Icon>
<Styled.Title>
<Title variant="h6" text={title} line={false}>
<Title variant="h6" text={title} line={false} as={as}>
{title}
</Title>
</Styled.Title>
Expand All @@ -26,7 +26,9 @@ const TestimonialCard = ({ title, excerpt, author, authorDetails }) => {
{excerpt}
</Styled.Description>
<div>
<Typography variant="h6">{author}</Typography>
<Typography variant="h6" as={as}>
{author}
</Typography>
<Typography variant="bodyTiny" color={theme.colors.gray[500]}>
{authorDetails}
</Typography>
Expand All @@ -40,8 +42,9 @@ TestimonialCard.propTypes = {
excerpt: string.isRequired,
author: string.isRequired,
authorDetails: string.isRequired,
as: string,
}

TestimonialCard.defaultProps = {}
TestimonialCard.defaultProps = { as: "h6" }

export default TestimonialCard
12 changes: 12 additions & 0 deletions packages/frontend/app/lib/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,15 @@ export const GET_FINANCIAL_STATEMENTS = gql`
}
}
`
export const GET_TESTIMONIALS = gql`
query GetTestimonials {
testimonialCollection(limit: 8) {
items {
author
authorDescription
description
title
}
}
}
`
13 changes: 13 additions & 0 deletions packages/frontend/app/lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@ export const financialStatementsType = shape({
})
),
})

export const testimonialItemsType = arrayOf(
shape({
author: string,
authorDescription: string,
description: string,
title: string,
})
)

export const testimonialType = shape({
items: testimonialItemsType,
})
17 changes: 15 additions & 2 deletions packages/frontend/app/pages/fundacja.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import AboutPage from "../templates/About"

import { supportingType, animalsType, adoptedAnimalsType } from "../lib/types"
import {
supportingType,
animalsType,
adoptedAnimalsType,
testimonialType,
} from "../lib/types"

import client from "../lib/api"
import {
GET_ADOPTED_ANIMALS,
GET_ANIMALS,
GET_SUPPORTING,
GET_TESTIMONIALS,
} from "../lib/queries"

const About = ({ animals, supporting, adoptedAnimals }) => (
const About = ({ animals, supporting, adoptedAnimals, testimonials }) => (
<AboutPage
animals={animals}
supporting={supporting}
adoptedAnimals={adoptedAnimals}
testimonials={testimonials}
/>
)

Expand All @@ -30,11 +37,16 @@ export async function getStaticProps() {
query: GET_ADOPTED_ANIMALS,
})

const { data: testimonials } = await client.query({
query: GET_TESTIMONIALS,
})

return {
props: {
animals: animals.animalCollection,
adoptedAnimals: adoptedAnimals.animalCollection,
supporting: supporting.supportingCollection,
testimonials: testimonials.testimonialCollection,
fallback: true,
},
}
Expand All @@ -44,6 +56,7 @@ About.propTypes = {
animals: animalsType.isRequired,
supporting: supportingType.isRequired,
adoptedAnimals: adoptedAnimalsType.isRequired,
testimonials: testimonialType.isRequired,
}

export default About
6 changes: 5 additions & 1 deletion packages/frontend/app/templates/About/About.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import {
supportingType,
animalsType,
adoptedAnimalsType,
testimonialType,
} from "../../lib/types"

import * as Styled from "./About.styled"
import Testimonials from "./components/Testimonials"

const About = ({ animals, supporting, adoptedAnimals }) => (
const About = ({ animals, supporting, adoptedAnimals, testimonials }) => (
<Page title="O nas">
<SupportBanner />
<Navigation />
Expand All @@ -41,6 +43,7 @@ const About = ({ animals, supporting, adoptedAnimals }) => (
adoptedAnimalsNumber={adoptedAnimals.total}
/>
</Container>
<Testimonials data={testimonials.items} />
</Styled.Main>
<Footer />
</Page>
Expand All @@ -50,6 +53,7 @@ About.propTypes = {
animals: animalsType.isRequired,
supporting: supportingType.isRequired,
adoptedAnimals: adoptedAnimalsType.isRequired,
testimonials: testimonialType.isRequired,
}

export default About
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Typography from "design-system/components/typography"
import Slider from "design-system/components/slider"
import Container from "design-system/components/container"
import TextBanner from "design-system/patterns/textBanner"

import TestimonialCard from "design-system/patterns/testimonialCard"

import * as Styled from "./Testimonials.styled"
import { testimonialItemsType } from "../../../../lib/types"

const Testimonials = ({ data }) => (
<Styled.Wrapper>
<Container>
<TextBanner
heading="Co o nas mówią?"
subtitle="Fundacja w opinii rodzin adopcyjnych"
tabletLayout="left"
mobileLayout="left"
>
<Styled.Description>
<Typography variant="bodyTitle">
Poniżej przeczytasz wybrane opinie napisane przez rodziny adopcyjne,
które szcześliwie odnalazły swoich przyjaciół w Fundacji Sterczące
Uszy. Zadowolonych rodzin jest znacznie więcej i stale ich przybywa.
</Typography>
</Styled.Description>
</TextBanner>
<Styled.Slider>
<Slider pagination navigation slidesPerViewDesktop={2}>
{data.map((item) => (
<TestimonialCard
key={item.description}
title={item.title}
excerpt={item.description}
author={item.author}
authorDetails={item.authorDescription}
as="h3"
/>
))}
</Slider>
</Styled.Slider>
</Container>
</Styled.Wrapper>
)

Testimonials.propTypes = {
data: testimonialItemsType.isRequired,
}

export default Testimonials
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import styled from "@emotion/styled"

export const Wrapper = styled.div`
padding: 120px 0;
${({ theme }) => theme.breakpoints.tabletLg} {
padding: 100px 0;
}
${({ theme }) => theme.breakpoints.mobileLg} {
padding: 60px 0;
background: none;
}
`

export const Slider = styled.div`
margin-top: 40px;
${({ theme }) => theme.breakpoints.tabletLg} {
margin-top: 20px;
width: 100vw;
position: relative;
left: 50%;
transform: translateX(-50%);
}
`

export const Description = styled.div`
margin: 0 auto;
width: 606px;
${({ theme }) => theme.breakpoints.tabletLg} {
width: 566px;
text-align: left;
}
${({ theme }) => theme.breakpoints.mobileLg} {
width: 100%;
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Testimonials from "./Testimonials"

export default Testimonials

0 comments on commit 2d2c0dc

Please sign in to comment.