Skip to content

Commit

Permalink
Merge pull request #600 from CodeForAfrica/feature/guiding-principles…
Browse files Browse the repository at this point in the history
…-cfa

Add Guiding Principles
  • Loading branch information
koechkevin authored Sep 22, 2023
2 parents 147b431 + 8d09303 commit 488a9a9
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 5 deletions.
9 changes: 8 additions & 1 deletion apps/codeforafrica/payload.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";

import { buildConfig } from "payload/config";
import GuidingPrinciples from "./src/payload/collections/GuidingPrinciples";
import Impact from "./src/payload/collections/Impact";
import Media from "./src/payload/collections/Media";
import Pages from "./src/payload/collections/Pages";
Expand Down Expand Up @@ -31,7 +32,13 @@ const adapter = s3Adapter({

export default buildConfig({
serverURL: appURL,
collections: [Impact, Pages, Media, Partners] as CollectionConfig[],
collections: [
GuidingPrinciples,
Impact,
Pages,
Media,
Partners,
] as CollectionConfig[],
globals: [Settings] as GlobalConfig[],
admin: {
css: path.resolve(__dirname, "./src/payload/admin/scss/custom.scss"),
Expand Down
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 @@ -2,9 +2,11 @@ import { RichTypography } from "@commons-ui/next";
import { Card, CardContent, CardMedia } from "@mui/material";
import React from "react";

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

const GuidingPrinciplesCard = React.forwardRef(
function GuidingPrinciplesCard(props, ref) {
const { title, content, icon } = props;
const { title, description, icon } = props;

return (
<Card
Expand Down Expand Up @@ -35,7 +37,7 @@ const GuidingPrinciplesCard = React.forwardRef(
<RichTypography variant="h3" sx={{ my: 2.5 }}>
{title}
</RichTypography>
<RichTypography>{content}</RichTypography>
<RichText elements={description} />
</CardContent>
</Card>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import GuidingPrinciplesCard from "../GuidingPrinciplesCard";

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

if (!list?.length) {
return null;
}
return (
<Section {...other} ref={ref}>
<Section
sx={{
px: { xs: 2.5, sm: 0 },
py: { xs: 2.5, md: 10 },
...sx,
}}
ref={ref}
>
<RichTypography variant="h4">{title}</RichTypography>
<Grid
container
Expand Down
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CustomPageHeader from "@/codeforafrica/components/CustomPageHeader";
import FeaturedProjects from "@/codeforafrica/components/FeaturedProjects";
import GetInTouch from "@/codeforafrica/components/GetInTouch";
import GetInvolved from "@/codeforafrica/components/GetInvolved";
import GuidingPrinciplesCardList from "@/codeforafrica/components/GuidingPrinciplesCardList";
import Hero from "@/codeforafrica/components/Hero";
import JoinOurSlack from "@/codeforafrica/components/JoinOurSlack";
import MeetOurTeam from "@/codeforafrica/components/MeetOurTeam";
Expand All @@ -25,6 +26,7 @@ const componentsBySlugs = {
"join-our-slack": JoinOurSlack,
"meet-our-team": MeetOurTeam,
"news-stories": NewsAndStories,
"our-guiding-principles": GuidingPrinciplesCardList,
"our-impact": OurImpact,
"our-partners": OurPartners,
"page-header": PageHeader,
Expand Down
30 changes: 30 additions & 0 deletions apps/codeforafrica/src/payload/blocks/GuidingPrinciples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const GuidingPrinciples = {
slug: "our-guiding-principles",
imageURL: "/images/cms/blocks/guiding_principles.png",
imageAltText: "Guiding Principles",
fields: [
{
name: "title",
label: {
en: "Title",
},
type: "text",
localized: true,
required: true,
},
{
name: "list",
label: {
en: "Guiding Principles",
},
type: "relationship",
relationTo: "guiding-principles",
hasMany: true,
admin: {
isSortable: true,
},
},
],
};

export default GuidingPrinciples;
34 changes: 34 additions & 0 deletions apps/codeforafrica/src/payload/collections/GuidingPrinciples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import image from "../fields/image";
import richText from "../fields/richText";

const GuidingPrinciples = {
slug: "guiding-principles",
admin: {
useAsTitle: "title",
},
fields: [
{
name: "title",
label: {
en: "Title",
},
type: "text",
required: true,
},
image({
overrides: {
name: "icon",
required: true,
},
}),
richText({
name: "description",
label: {
en: "Description",
},
required: true,
}),
],
};

export default GuidingPrinciples;
3 changes: 3 additions & 0 deletions apps/codeforafrica/src/payload/collections/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const Media = {
required: true,
},
],
hooks: {
afterRead: [({ doc }) => ({ ...doc, src: doc.url })],
},
};

export default Media;
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 @@ -3,6 +3,7 @@ import CustomPageHeader from "../blocks/CustomPageHeader";
import Error from "../blocks/Error";
import GetInTouch from "../blocks/GetInTouch";
import GetInvolved from "../blocks/GetInvolved";
import GuidingPrinciples from "../blocks/GuidingPrinciples";
import Hero from "../blocks/Hero";
import JoinOurSlack from "../blocks/JoinOurSlack";
import MeetOurTeam from "../blocks/MeetOurTeam";
Expand Down Expand Up @@ -48,6 +49,7 @@ const Pages = {
Error,
GetInTouch,
GetInvolved,
GuidingPrinciples,
Hero,
JoinOurSlack,
MeetOurTeam,
Expand Down

0 comments on commit 488a9a9

Please sign in to comment.