-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #747 from CodeForAfrica/ft/blockify-components
Blockify CMS Blocks
- Loading branch information
Showing
30 changed files
with
867 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* This file was automatically generated by Payload. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config, | ||
* and re-run `payload generate:types` to regenerate this file. | ||
*/ | ||
|
||
export interface Config { | ||
collections: { | ||
media: Media; | ||
pages: Page; | ||
users: User; | ||
"payload-preferences": PayloadPreference; | ||
"payload-migrations": PayloadMigration; | ||
}; | ||
globals: { | ||
"settings-site": SettingsSite; | ||
}; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "media". | ||
*/ | ||
export interface Media { | ||
id: string; | ||
alt: string; | ||
prefix?: string | null; | ||
updatedAt: string; | ||
createdAt: string; | ||
url?: string | null; | ||
filename?: string | null; | ||
mimeType?: string | null; | ||
filesize?: number | null; | ||
width?: number | null; | ||
height?: number | null; | ||
focalX?: number | null; | ||
focalY?: number | null; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "pages". | ||
*/ | ||
export interface Page { | ||
id: string; | ||
title: string; | ||
fullTitle?: string | null; | ||
slug?: string | null; | ||
blocks?: | ||
| { | ||
title: string; | ||
subtitle: string; | ||
id?: string | null; | ||
blockName?: string | null; | ||
blockType: "page-header"; | ||
}[] | ||
| null; | ||
meta?: { | ||
title?: string | null; | ||
description?: string | null; | ||
image?: string | Media | null; | ||
}; | ||
parent?: (string | null) | Page; | ||
breadcrumbs?: | ||
| { | ||
doc?: (string | null) | Page; | ||
url?: string | null; | ||
label?: string | null; | ||
id?: string | null; | ||
}[] | ||
| null; | ||
updatedAt: string; | ||
createdAt: string; | ||
_status?: ("draft" | "published") | null; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "users". | ||
*/ | ||
export interface User { | ||
id: string; | ||
firstName: string; | ||
lastName: string; | ||
roles: ("admin" | "editor")[]; | ||
updatedAt: string; | ||
createdAt: string; | ||
email: string; | ||
resetPasswordToken?: string | null; | ||
resetPasswordExpiration?: string | null; | ||
salt?: string | null; | ||
hash?: string | null; | ||
_verified?: boolean | null; | ||
_verificationToken?: string | null; | ||
loginAttempts?: number | null; | ||
lockUntil?: string | null; | ||
password: string | null; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-preferences". | ||
*/ | ||
export interface PayloadPreference { | ||
id: string; | ||
user: { | ||
relationTo: "users"; | ||
value: string | User; | ||
}; | ||
key?: string | null; | ||
value?: | ||
| { | ||
[k: string]: unknown; | ||
} | ||
| unknown[] | ||
| string | ||
| number | ||
| boolean | ||
| null; | ||
updatedAt: string; | ||
createdAt: string; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "payload-migrations". | ||
*/ | ||
export interface PayloadMigration { | ||
id: string; | ||
name?: string | null; | ||
batch?: number | null; | ||
updatedAt: string; | ||
createdAt: string; | ||
} | ||
/** | ||
* This interface was referenced by `Config`'s JSON-Schema | ||
* via the `definition` "settings-site". | ||
*/ | ||
export interface SettingsSite { | ||
id: string; | ||
title: string; | ||
description: { | ||
[k: string]: unknown; | ||
}[]; | ||
primaryLogo: string | Media; | ||
secondaryLogo?: string | Media | null; | ||
primaryNavigation?: { | ||
menus?: | ||
| { | ||
label: string; | ||
linkType?: ("custom" | "internal") | null; | ||
doc?: { | ||
relationTo: "pages"; | ||
value: string | Page; | ||
} | null; | ||
url?: string | null; | ||
href: string; | ||
id?: string | null; | ||
}[] | ||
| null; | ||
connect?: | ||
| ("Facebook" | "Twitter" | "Instagram" | "Linkedin" | "Github" | "Slack") | ||
| null; | ||
}; | ||
secondaryNavigation?: { | ||
menus?: | ||
| { | ||
label: string; | ||
linkType?: ("custom" | "internal") | null; | ||
doc?: { | ||
relationTo: "pages"; | ||
value: string | Page; | ||
} | null; | ||
url?: string | null; | ||
href: string; | ||
id?: string | null; | ||
}[] | ||
| null; | ||
}; | ||
connect: { | ||
title: string; | ||
links?: | ||
| { | ||
platform: | ||
| "Facebook" | ||
| "Twitter" | ||
| "Instagram" | ||
| "Linkedin" | ||
| "Github" | ||
| "Slack"; | ||
url: string; | ||
id?: string | null; | ||
}[] | ||
| null; | ||
}; | ||
newsletter: { | ||
title: string; | ||
embedCode: string; | ||
}; | ||
initiative: { | ||
title: string; | ||
description: { | ||
[k: string]: unknown; | ||
}[]; | ||
partners?: | ||
| { | ||
name: string; | ||
logo: string | Media; | ||
label: string; | ||
linkType?: ("custom" | "internal") | null; | ||
doc?: { | ||
relationTo: "pages"; | ||
value: string | Page; | ||
} | null; | ||
url?: string | null; | ||
href: string; | ||
id?: string | null; | ||
}[] | ||
| null; | ||
}; | ||
updatedAt?: string | null; | ||
createdAt?: string | null; | ||
} | ||
|
||
declare module "payload" { | ||
export interface GeneratedTypes extends Config {} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
apps/roboshield/src/components/BlockRenderer/BlockRenderer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import PageHeader from "@/roboshield/components/PageHeader/PageHeader"; | ||
import { Page } from "@/root/payload-types"; | ||
|
||
interface BlockRendererProps extends Pick<Page, "blocks"> {} | ||
|
||
const components = { | ||
"page-header": PageHeader, | ||
}; | ||
|
||
export default function BlockRenderer({ blocks }: BlockRendererProps) { | ||
return ( | ||
<> | ||
{blocks?.map((block, index) => { | ||
const Component = components[block.blockType]; | ||
|
||
if (Component) { | ||
return <Component key={index} {...block} />; | ||
} | ||
|
||
return null; | ||
})} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import BlockRenderer from "./BlockRenderer"; | ||
|
||
export default BlockRenderer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Section } from "@commons-ui/core"; | ||
import { RichTypography } from "@commons-ui/next"; | ||
import TwoToneBackground from "@/roboshield/components/TwoToneBackground"; | ||
import { Page } from "@/root/payload-types"; | ||
import { ExtractBlockType } from "@/roboshield/utils/blocks"; | ||
|
||
type PageHeaderProps = ExtractBlockType< | ||
NonNullable<Page["blocks"]>[number], | ||
"page-header" | ||
>; | ||
|
||
export default function PageHeader({ title, subtitle }: PageHeaderProps) { | ||
return ( | ||
<> | ||
<TwoToneBackground sx={{ backgroundColor: "background.default" }}> | ||
<Section | ||
sx={{ | ||
px: { xs: 2.5, sm: 0 }, | ||
py: { xs: 3.75, sm: 5.5, md: 6.75, lg: 9.6 }, | ||
zIndex: 1, | ||
textAlign: "center", | ||
}} | ||
> | ||
<RichTypography | ||
component="h2" | ||
sx={{ | ||
color: "primary.main", | ||
paddingBottom: 2.5, | ||
textTransform: "uppercase", | ||
}} | ||
variant="h5ExtraBold" | ||
> | ||
{title} | ||
</RichTypography> | ||
<RichTypography component="h2" variant="h2"> | ||
{subtitle} | ||
</RichTypography> | ||
</Section> | ||
</TwoToneBackground> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PageHeader from "./PageHeader"; | ||
|
||
export default PageHeader; |
55 changes: 55 additions & 0 deletions
55
apps/roboshield/src/components/TwoToneBackground/TwoToneBackground.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Box } from "@mui/material"; | ||
import { alpha, styled, Theme } from "@mui/material/styles"; | ||
import React from "react"; | ||
|
||
import bg from "@/roboshield/assets/images/1920x668px bg - 2 2.png"; | ||
|
||
const TwoToneBackgroundRoot = styled(Box)(({ theme }) => ({ | ||
display: "flex", | ||
justifyContent: "center", | ||
width: "100%", | ||
position: "relative", | ||
backgroundColor: theme.palette.background.default, | ||
backgroundImage: `url('${bg.src}')`, | ||
backgroundPosition: "top left", | ||
"&:before": { | ||
content: '""', | ||
top: 0, | ||
left: 0, | ||
position: "absolute", | ||
height: "100%", | ||
width: "100%", | ||
background: `linear-gradient(to right, ${theme.palette.background.default}, transparent 30%)`, | ||
[theme.breakpoints.up("sm")]: { | ||
background: `linear-gradient(to right, ${theme.palette.background.default} 20%, transparent 30%)`, | ||
}, | ||
[theme.breakpoints.up("md")]: { | ||
background: `linear-gradient(to right, ${ | ||
theme.palette.background.default | ||
} 30%, transparent 40%, transparent 95%, ${alpha( | ||
theme.palette.background.default, | ||
0.7, | ||
)} 98%)`, | ||
}, | ||
[theme.breakpoints.up("lg")]: { | ||
background: `linear-gradient(to right, ${theme.palette.background.default} 30%, transparent 40%, transparent 95%, ${theme.palette.background.default} 99%)`, | ||
}, | ||
[theme.breakpoints.up("xl")]: { | ||
background: `linear-gradient(to right, ${theme.palette.background.default} 35%, transparent 45%, transparent 80%, ${theme.palette.background.default} 90%)`, | ||
}, | ||
}, | ||
})); | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
sx: any; | ||
} | ||
|
||
const TwoToneBackground = React.forwardRef(function TwoToneBackground({ | ||
children, | ||
...props | ||
}: Props) { | ||
return <TwoToneBackgroundRoot {...props}>{children}</TwoToneBackgroundRoot>; | ||
}); | ||
|
||
export default TwoToneBackground; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TwoToneBackground from "./TwoToneBackground"; | ||
|
||
export default TwoToneBackground; |
Oops, something went wrong.