Skip to content

Commit

Permalink
Merge pull request #595 from CodeForAfrica/ft/codeforafrica-get-involved
Browse files Browse the repository at this point in the history
Ft/codeforafrica Get Involved block
  • Loading branch information
kelvinkipruto authored Sep 21, 2023
2 parents 59d0067 + e9361f4 commit f92cd24
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 22 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions apps/codeforafrica/src/components/GetInvolved/GetInvolved.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from "react";
import ImpactCardList from "@/codeforafrica/components/ImpactCardList";

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

if (!action?.href?.length) {
return null;
Expand All @@ -26,7 +26,7 @@ const GetInvolved = React.forwardRef(function GetInvolved(props, ref) {
py: { xs: 5, sm: 10, md: 4, lg: 12.5 },
}}
>
<ImpactCardList list={list} />
<ImpactCardList list={impacts} />
<Button
variant="contained"
component={Link}
Expand All @@ -39,20 +39,20 @@ const GetInvolved = React.forwardRef(function GetInvolved(props, ref) {
width: { xs: "100%", sm: "fit-content" },
}}
>
{action.content || action.href}
{action.label}
</Button>
</Section>
</Box>
);
});

GetInvolved.propTypes = {
list: PropTypes.arrayOf(PropTypes.shape({})),
impacts: PropTypes.arrayOf(PropTypes.shape({})),
action: PropTypes.shape({}),
};

GetInvolved.defaultProps = {
list: undefined,
impacts: undefined,
action: undefined,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ exports[`<GetInvolved /> renders unchanged 1`] = `
>
15000
</div>
<div
class="MuiBox-root css-2ligbh"
>
<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>
</div>
Expand Down
16 changes: 12 additions & 4 deletions apps/codeforafrica/src/components/GetInvolved/GetInvolved.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ import theme from "@/codeforafrica/theme";
const render = createRender({ theme });

const defaultProps = {
list: [
impacts: [
{
title: "Beneficiaries trained",
value: 15000,
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,
},
],
},
],
},
],
action: {
content: "Get Involved",
label: "Get Involved",
href: "/contact",
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ exports[`<ImpactCardList /> renders unchanged 1`] = `
>
15000
</div>
<div
class="MuiBox-root css-2ligbh"
>
<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>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,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,
},
],
},
],
},
],
};
Expand Down
14 changes: 14 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/get-involved.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import formatImpacts from "@/codeforafrica/lib/data/utils/impacts";

function getInvolved(block) {
const { impacts, ...other } = block;
const ourImpacts = formatImpacts(impacts);

return {
...other,
impacts: ourImpacts,
slug: "get-involved",
};
}

export default getInvolved;
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,9 +1,11 @@
import getInvolved from "./get-involved";
import hero from "./hero";
import ourImpact from "./our-impact";

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

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

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,
};
});
const ourImpacts = formatImpacts(impacts);

return {
...other,
Expand Down
13 changes: 13 additions & 0 deletions apps/codeforafrica/src/lib/data/utils/impacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { imageFromMedia } from "@/codeforafrica/lib/data/utils";

export default function formatImpacts(impacts) {
return impacts.map((impact) => {
const { icon: media, title, ...rest } = impact;
const image = imageFromMedia({ alt: title, ...media });
return {
...rest,
image,
title,
};
});
}
17 changes: 17 additions & 0 deletions apps/codeforafrica/src/payload/blocks/GetInvolved.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import impacts from "../fields/impacts";
import linkGroup from "../fields/links/linkGroup";

const GetInvolved = {
slug: "get-involved",
imageURL: "/images/cms/blocks/get_involved.jpg",
imageAltText: "Get Involved",
fields: [
impacts({
minRows: 3,
maxRows: 3,
}),
linkGroup({ overrides: { name: "action", label: "Action" } }),
],
};

export default GetInvolved;
4 changes: 3 additions & 1 deletion apps/codeforafrica/src/payload/collections/Pages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CustomPageHeader from "../blocks/CustomPageHeader";
import Error from "../blocks/Error";
import GetInTouch from "../blocks/GetInTouch";
import GetInvolved from "../blocks/GetInvolved";
import Hero from "../blocks/Hero";
import OurImpact from "../blocks/OurImpact";
import OurPartners from "../blocks/OurPartners";
Expand Down Expand Up @@ -42,10 +43,11 @@ const Pages = {
blocks: [
Error,
GetInTouch,
GetInvolved,
Hero,
OurImpact,
PageHeader,
CustomPageHeader,
OurImpact,
OurPartners,
],
admin: {
Expand Down

0 comments on commit f92cd24

Please sign in to comment.