Skip to content

Commit

Permalink
Merge branch 'develop' into ft/codeforafrica-get-involved
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Sep 20, 2023
2 parents 3ec6849 + ef2435c commit c632af0
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 35 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ exports[`<GetInvolved /> renders unchanged 1`] = `
>
15000
</div>
<div
class="MuiTypography-root MuiTypography-body3 css-51w9j7-MuiTypography-root"
>
In 10 years, 15 000 trainees have learned new skills and knowledge within the civic tech and media space.
</div>
</div>
</div>
</div>
Expand Down
15 changes: 8 additions & 7 deletions apps/codeforafrica/src/components/ImpactCard/ImpactCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { styled } from "@mui/material/styles";
import PropTypes from "prop-types";
import React from "react";

import RichText from "@/codeforafrica/components/RichText";

const ImpactCardRoot = styled(Card, {
slot: "Root",
})(({ theme: { breakpoints } }) => ({
Expand All @@ -19,7 +21,7 @@ const ImpactCardRoot = styled(Card, {
}));

const ImpactCard = React.forwardRef(function ImpactCard(props, ref) {
const { image, title, value, content } = props;
const { image, title, value, description } = props;

if (!(image && title)) {
return null;
Expand Down Expand Up @@ -72,22 +74,21 @@ const ImpactCard = React.forwardRef(function ImpactCard(props, ref) {
>
{value}
</RichTypography>
<RichTypography
<RichText
elements={description}
sx={{
display: "block",
pt: "10px",
}}
variant="body3"
>
{content}
</RichTypography>
/>
</CardContent>
</ImpactCardRoot>
);
});

ImpactCard.propTypes = {
content: PropTypes.string,
description: PropTypes.arrayOf(PropTypes.shape({})),
title: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
image: PropTypes.shape({
Expand All @@ -97,7 +98,7 @@ ImpactCard.propTypes = {
};

ImpactCard.defaultProps = {
content: undefined,
description: undefined,
title: undefined,
value: undefined,
image: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ exports[`<ImpactCard /> renders unchanged 1`] = `
15000
</div>
<div
class="MuiTypography-root MuiTypography-body3 css-51w9j7-MuiTypography-root"
class="MuiBox-root css-2ligbh"
>
In 10 years, 15 000 trainees have learned new skills and knowledge within the civic tech and media space.
<span
class="MuiTypography-root MuiTypography-body3 css-s9m4rs-MuiTypography-root"
>
Our team makes an impact in more than 20 countries where members are present.
</span>
</div>
</div>
</div>
Expand Down
12 changes: 10 additions & 2 deletions apps/codeforafrica/src/components/ImpactCard/ImpactCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ const defaultProps = {
image: {
src: "/images/Type=layout,%20Size=32,%20Color=1020E1.svg",
},
content:
"In 10 years, 15 000 trainees have learned new skills and knowledge within the civic tech and media space.",
description: [
{
children: [
{
text: "Our team makes an impact in more than 20 countries where members are present.",
children: null,
},
],
},
],
};

describe("<ImpactCard />", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ exports[`<ImpactCardList /> renders unchanged 1`] = `
>
15000
</div>
<div
class="MuiTypography-root MuiTypography-body3 css-51w9j7-MuiTypography-root"
>
In 10 years, 15 000 trainees have learned new skills and knowledge within the civic tech and media space.
</div>
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions apps/codeforafrica/src/components/OurImpact/OurImpact.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import React from "react";
import ImpactCardList from "@/codeforafrica/components/ImpactCardList";

const OurImpact = React.forwardRef(function OurImpact(props, ref) {
const { list, title, sx } = props;
const { impacts, title, sx } = props;

if (!list?.length) {
if (!impacts?.length) {
return null;
}
return (
Expand All @@ -36,19 +36,19 @@ const OurImpact = React.forwardRef(function OurImpact(props, ref) {
{title}
</RichTypography>
)}
<ImpactCardList list={list} />
<ImpactCardList list={impacts} />
</Section>
</Box>
);
});

OurImpact.propTypes = {
list: PropTypes.arrayOf(PropTypes.shape({})),
impacts: PropTypes.arrayOf(PropTypes.shape({})),
title: PropTypes.string,
};

OurImpact.defaultProps = {
list: undefined,
impacts: undefined,
title: undefined,
};

Expand Down
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import hero from "./hero";
import ourImpact from "./our-impact";

const propsifyBlockBySlug = {
hero,
"our-impact": ourImpact,
};

async function blockify(blocks) {
Expand Down
22 changes: 22 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/our-impact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { imageFromMedia } from "@/codeforafrica/lib/data/utils";

function ourImpact(block) {
const { impacts, ...other } = block;
const ourImpacts = impacts.map((impact) => {
const { icon: media, title, ...rest } = impact;
const image = imageFromMedia({ alt: title, ...media });
return {
...rest,
image,
title,
};
});

return {
...other,
impacts: ourImpacts,
slug: "our-impact",
};
}

export default ourImpact;
4 changes: 3 additions & 1 deletion apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GetInvolved from "@/codeforafrica/components/GetInvolved";
import Hero from "@/codeforafrica/components/Hero";
import MeetOurTeam from "@/codeforafrica/components/MeetOurTeam";
import NewsAndStories from "@/codeforafrica/components/NewsAndStories";
import OurImpact from "@/codeforafrica/components/OurImpact";
import OurPartners from "@/codeforafrica/components/OurPartners";
import PageHeader from "@/codeforafrica/components/PageHeader";
import { getPageServerSideProps } from "@/codeforafrica/lib/data";
Expand All @@ -17,7 +18,8 @@ const componentsBySlugs = {
"custom-page-header": CustomPageHeader,
"meet-our-team": MeetOurTeam,
"news-stories": NewsAndStories,
"our-impact": GetInvolved,
"get-involved": GetInvolved,
"our-impact": OurImpact,
"our-partners": OurPartners,
projects: FeaturedProjects,
};
Expand Down
20 changes: 20 additions & 0 deletions apps/codeforafrica/src/payload/blocks/OurImpact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import impacts from "../fields/impacts";

const OurImpact = {
slug: "our-impact",
imageURL: "/images/cms/blocks/our_impact.jpg",
imageAltText: "Show Our Impact",
fields: [
{
name: "title",
label: "Title",
type: "text",
required: true,
},
impacts({
minRows: 1,
}),
],
};

export default OurImpact;
9 changes: 3 additions & 6 deletions apps/codeforafrica/src/payload/collections/Impact.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import image from "../fields/image";
import richText from "../fields/richText";

const Impact = {
slug: "impact",
Expand All @@ -9,20 +10,16 @@ const Impact = {
access: {
read: () => true,
},

fields: [
{
name: "title",
label: "Title",
type: "text",
required: true,
},
{
richText({
name: "description",
label: "Description",
type: "text",
required: true,
},
}),
{
name: "value",
label: "Value",
Expand Down
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/payload/collections/Pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import CustomPageHeader from "../blocks/CustomPageHeader";
import Error from "../blocks/Error";
import GetInvolved from "../blocks/GetInvolved";
import Hero from "../blocks/Hero";
import OurImpact from "../blocks/OurImpact";
import OurPartners from "../blocks/OurPartners";
import PageHeader from "../blocks/PageHeader";
import fullTitle from "../fields/fullTitle";
Expand Down Expand Up @@ -44,6 +45,7 @@ const Pages = {
Hero,
PageHeader,
CustomPageHeader,
OurImpact,
OurPartners,
],
admin: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepmerge } from "@mui/utils";

const authors = (overrides) =>
const impacts = (overrides) =>
deepmerge(
{
name: "impacts",
Expand All @@ -11,4 +11,4 @@ const authors = (overrides) =>
overrides,
);

export default authors;
export default impacts;

0 comments on commit c632af0

Please sign in to comment.