Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/codeforafrica get in touch #587

Merged
merged 11 commits into from
Sep 20, 2023
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions apps/codeforafrica/src/components/GetInTouch/GetInTouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TwoToneBackground from "@/codeforafrica/components/TwoToneBackground";

const GetInTouch = React.forwardRef(function GetInTouch(props, ref) {
const {
action: { href, content },
action: { href, label },
subtitle,
title,
sx,
Expand Down Expand Up @@ -59,7 +59,7 @@ const GetInTouch = React.forwardRef(function GetInTouch(props, ref) {
},
}}
>
{content}
{label}
</Button>
</Stack>
</Section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports[`<GetInTouch /> renders unchanged 1`] = `
viewbox="0 0 24 24"
/>
</span>
Get in touch
</a>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/getInTouch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { actionFromActionButton } from "@/codeforafrica/lib/data/utils";
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved

function getInTouch(block) {
const { actionButton, ...other } = block;

const action = actionFromActionButton({ ...actionButton });

return {
...other,
action,
slug: "get-in-touch",
};
}

export default getInTouch;
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 getInTouch from "./getInTouch";
import hero from "./hero";

const propsifyBlockBySlug = {
hero,
"get-in-touch": getInTouch,
};

async function blockify(blocks) {
Expand Down
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/rest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export const api = {
export async function getPageStaticProps(context) {
const props = await getPageProps(api, context);
return {
props,
props: props || {},
};
}
4 changes: 3 additions & 1 deletion apps/codeforafrica/src/lib/data/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export function imageFromMedia({ alt = null, url = null }) {
return { alt, src: url };
}

export function actionFromActionButton({ href, label, newTab = false }) {
return { href, label, newTab };
}
export default undefined;
3 changes: 3 additions & 0 deletions apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import { SWRConfig } from "swr";

import GetInTouch from "../components/GetInTouch/GetInTouch";

import CustomPageHeader from "@/codeforafrica/components/CustomPageHeader";
import FeaturedProjects from "@/codeforafrica/components/FeaturedProjects";
import GetInvolved from "@/codeforafrica/components/GetInvolved";
Expand All @@ -13,6 +15,7 @@ import { getPageServerSideProps } from "@/codeforafrica/lib/data";

const componentsBySlugs = {
hero: Hero,
"get-in-touch": GetInTouch,
"page-header": PageHeader,
"custom-page-header": CustomPageHeader,
"meet-our-team": MeetOurTeam,
Expand Down
37 changes: 37 additions & 0 deletions apps/codeforafrica/src/payload/blocks/GetInTouch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import link from "../fields/links/link";

const GetInTouch = {
slug: "get-in-touch",
imageURL: "/images/cms/blocks/get_in_touch.jpg",
imageAltText: "Display Get In Touch Call to Action",
fields: [
{
name: "title",
label: "Title",
required: true,
type: "text",
},
{
name: "subtitle",
label: "Sub Title",
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved
required: true,
type: "text",
},
{
name: "actionButton",
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved
label: "Action Button",
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved
type: "group",
fields: [
{
name: "label",
label: "Label",
type: "text",
required: true,
},
link({}),
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved
],
},
],
};

export default GetInTouch;
10 changes: 9 additions & 1 deletion apps/codeforafrica/src/payload/collections/Pages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CustomPageHeader from "../blocks/CustomPageHeader";
import Error from "../blocks/Error";
import GetInTouch from "../blocks/GetInTouch";
import Hero from "../blocks/Hero";
import OurPartners from "../blocks/OurPartners";
import PageHeader from "../blocks/PageHeader";
Expand Down Expand Up @@ -37,7 +38,14 @@ const Pages = {
// each other e.g. while alphabecially CustomPageHeader should be with C,
// it's functiaonally equivalent with PageHeader so we keep it next to
// PageHeader
blocks: [Error, Hero, PageHeader, CustomPageHeader, OurPartners],
blocks: [
Error,
GetInTouch,
Hero,
PageHeader,
CustomPageHeader,
OurPartners,
],
admin: {
initCollapsed: true,
},
Expand Down