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

Add Guiding Principles #600

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}}
kilemensi marked this conversation as resolved.
Show resolved Hide resolved
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 = {
koechkevin marked this conversation as resolved.
Show resolved Hide resolved
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 })],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

},
};

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