Unverified Commit cca9dd12 authored by Jessica Chowdhury's avatar Jessica Chowdhury Committed by GitHub

examples: Add new `cms-payload` example. (#49616)

This PR adds `cms-payload` to the examples folder. The demo provides a
NextJS frontend, built with Payload, which can be deployed together in a
single instance.

### Improving Documentation or adding/fixing Examples

- [x] The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- [x] Make sure the linting passes by running `pnpm build && pnpm lint`.
See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

---------
Co-authored-by: 's avatarLee Robinson <me@leerob.io>
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 13c205ff
MONGODB_URI=mongodb://localhost/payload-vercel-functions
PAYLOAD_SECRET=YOUR_SECRET_HERE
PAYLOAD_CONFIG_PATH=dist/payload.config.js
NEXT_PUBLIC_APP_URL=http://localhost:3000
PAYLOAD_PUBLIC_CMS_URL=http://localhost:3000
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_REGION=
NEXT_PUBLIC_S3_ENDPOINT=
NEXT_PUBLIC_S3_BUCKET=
PAYLOAD_PRIVATE_REGENERATION_SECRET=
NEXT_PRIVATE_REGENERATION_SECRET=
\ No newline at end of file
.DS_Store
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Node Patch ###
# Serverless Webpack directories
.webpack/
# Optional stylelint cache
# SvelteKit build / generate output
.svelte-kit
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# Support for Project snippet scope
.vscode/*.code-snippets
# Ignore code-workspaces
*.code-workspace
# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode
.vercel
build
public/admin
legacy-peer-deps=true
# Next + Payload Serverless Demo
This is a demo showing how to utilize `@payloadcms/next-payload` to deploy Payload serverlessly, in the same repo alongside of a NextJS app.
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/cms-payload&project-name=cms-payload&repository-name=cms-payload)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
```bash
npx create-next-app --example cms-payload cms-payload-app
```
```bash
yarn create next-app --example cms-payload cms-payload-app
```
```bash
pnpm create next-app --example cms-payload cms-payload-app
```
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
The only thing you need to do to deploy to Vercel is to ensure that you have a Mongo Atlas database connection string and an S3 bucket (if desired).
Fill out the same environment variables that are shown in the `.env.example` with your own values, and then you're good to go!
### Developing locally
To develop with this package locally, make sure you have the following required software:
1. MongoDB
2. Node + NPM / Yarn
3. An S3 bucket to store media (optional)
### Getting started
Follow the steps below to spin up a local dev environment:
1. Clone the repo
2. Run `yarn` or `npm install`
3. Run `cp .env.example .env` and fill out all ENV variables as shown
4. Run `yarn dev` to start up the dev server
From there, you can visit your admin panel via navigating to `http://localhost:3000/admin`. Go ahead and start working!
### Related examples
- [Strapi](/examples/cms-strapi)
- [Contentful](/examples/cms-contentful)
- [WordPress](/examples/cms-wordpress)
- [Sanity](/examples/cms-sanity)
- [DatoCMS](/examples/cms-datocms)
- [TakeShape](/examples/cms-takeshape)
- [Prismic](/examples/cms-prismic)
- [Agility CMS](/examples/cms-agilitycms)
- [Cosmic](/examples/cms-cosmic)
- [ButterCMS](/examples/cms-buttercms)
- [Storyblok](/examples/cms-storyblok)
- [GraphCMS](/examples/cms-graphcms)
- [Kontent](/examples/cms-kontent)
// Need to render the same component for anything within /admin
export { default } from '../page'
'use client'
import React from 'react'
import Root from 'payload/dist/admin/Root'
const PayloadAdmin = () => {
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
if (!mounted) return null
return <Root />
}
export default PayloadAdmin
import { notFound } from 'next/navigation'
import { getPayloadClient } from '../../../payload/payloadClient'
import Blocks from '../../../components/Blocks'
import { Hero } from '../../../components/Hero'
import { AdminBar } from '../../../components/AdminBar'
import { Metadata } from 'next'
export async function generateMetadata({
params: { slug },
}): Promise<Metadata> {
return {
title: slug,
}
}
const Page = async ({ params: { slug } }) => {
const payload = await getPayloadClient()
const pages = await payload.find({
collection: 'pages',
where: {
slug: {
equals: slug || 'home',
},
},
})
const page = pages.docs[0]
if (!page) return notFound()
return (
<>
<AdminBar adminBarProps={{ collection: 'pages', id: page.id }} />
<Hero {...page.hero} />
<Blocks blocks={page.layout} />
</>
)
}
export async function generateStaticParams() {
const payload = await getPayloadClient()
const pages = await payload.find({
collection: 'pages',
limit: 0,
})
return pages.docs.map(({ slug }) => ({ slug }))
}
export default Page
import Layout from '../../components/Layout'
import { getPayloadClient } from '../../payload/payloadClient'
const SiteLayout = async ({ children }: { children: React.ReactNode }) => {
const payload = await getPayloadClient()
const mainMenu = await payload.findGlobal({
slug: 'main-menu',
})
return <Layout mainMenu={mainMenu}>{children}</Layout>
}
export default SiteLayout
import Page from './[slug]/page'
export default Page
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<body>{children}</body>
</html>
)
}
.adminBar {
z-index: 10;
width: 100%;
background-color: var(--color-base-1000);
color: var(--color-white);
padding: 5px 0;
font-size: calc(#{var(--html-font-size)} * 1px);
display: none;
}
.show {
display: block;
}
.controls {
& > *:not(:last-child) {
margin-right: 10px !important;
}
}
.user {
margin-right: 10px !important;
}
.logo {
margin-right: 10px !important;
}
.blockContainer {
position: relative;
}
.hr {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
background-color: var(--light-gray);
height: 2px;
}
'use client'
import React, { useState } from 'react'
import {
PayloadMeUser,
PayloadAdminBarProps,
PayloadAdminBar,
} from 'payload-admin-bar'
import { Gutter } from '../Gutter'
import classes from './index.module.scss'
const Title: React.FC = () => <span>Payload + Vercel</span>
export const AdminBar: React.FC<{
adminBarProps: PayloadAdminBarProps
}> = (props) => {
const { adminBarProps } = props
const [user, setUser] = useState<PayloadMeUser>()
return (
<div
className={[classes.adminBar, user && classes.show]
.filter(Boolean)
.join(' ')}
>
<Gutter className={classes.blockContainer}>
<PayloadAdminBar
{...adminBarProps}
cmsURL={process.env.NEXT_PUBLIC_APP_URL}
onAuthChange={setUser}
className={classes.payloadAdminBar}
classNames={{
user: classes.user,
logo: classes.logo,
controls: classes.controls,
}}
logo={<Title />}
style={{
position: 'relative',
zIndex: 'unset',
padding: 0,
backgroundColor: 'transparent',
}}
/>
</Gutter>
</div>
)
}
.white {
color: var(--color-base-1000);
background-color: var(--color-base-0);
}
.black {
color: var(--color-base-0);
background-color: var(--color-base-1000);
}
'use client'
import React, { useContext, createContext } from 'react'
import { VerticalPadding, VerticalPaddingOptions } from '../VerticalPadding'
import classes from './index.module.scss'
type BackgroundColorField = 'white' | 'black'
export const BackgroundColorContext =
createContext<BackgroundColorField>('white')
export const useBackgroundColor = (): BackgroundColorField =>
useContext(BackgroundColorContext)
type Props = {
color?: BackgroundColorField
paddingTop?: VerticalPaddingOptions
paddingBottom?: VerticalPaddingOptions
className?: string
children?: React.ReactNode
id?: string
}
export const BackgroundColor: React.FC<Props> = (props) => {
const {
id,
className,
children,
paddingTop,
paddingBottom,
color = 'white',
} = props
return (
<div
id={id}
className={[classes[color], className].filter(Boolean).join(' ')}
>
<BackgroundColorContext.Provider value={color}>
<VerticalPadding top={paddingTop} bottom={paddingBottom}>
{children}
</VerticalPadding>
</BackgroundColorContext.Provider>
</div>
)
}
@use '../.../../../../css/queries.scss' as *;
$spacer-h: calc(var(--block-padding) / 2);
.callToAction {
padding-left: $spacer-h;
padding-right: $spacer-h;
}
.background--white {
background-color: var(--color-base-1000);
color: var(--color-base-0);
}
.richText {
:last-child {
margin-bottom: 0;
}
}
.linkGroup {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
:last-child {
margin-bottom: 0;
}
@include mid-break {
margin-top: 20px;
}
}
import React from 'react'
import { Cell, Grid } from '@faceless-ui/css-grid'
import { Page } from '../../../payload-types'
import { BackgroundColor } from '../../BackgroundColor'
import { Gutter } from '../../Gutter'
import { CMSLink } from '../../Link'
import RichText from '../../RichText'
import classes from './index.module.scss'
type Props = {
ctaBackgroundColor?: 'white' | 'black'
richText: {
[k: string]: unknown
}[]
links: {
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
}
id?: string
}[]
id?: string
blockName?: string
blockType: 'cta'
}
export const CallToActionBlock: React.FC<Props> = ({
ctaBackgroundColor,
links,
richText,
}) => {
const oppositeBackgroundColor =
ctaBackgroundColor === 'white' ? 'black' : 'white'
return (
<Gutter>
<BackgroundColor color={oppositeBackgroundColor}>
<div className={classes.callToAction}>
<Grid>
<Cell cols={8} colsL={7} colsM={12}>
<div>
<RichText className={classes.richText} content={richText} />
</div>
</Cell>
<Cell
start={10}
cols={3}
startL={9}
colsL={4}
startM={1}
colsM={12}
>
<div className={classes.linkGroup}>
{(links || []).map(({ link }, i) => {
return <CMSLink key={i} {...link} />
})}
</div>
</Cell>
</Grid>
</div>
</BackgroundColor>
</Gutter>
)
}
import React from 'react'
import { Grid, Cell } from '@faceless-ui/css-grid'
import { Page } from '../../../payload-types'
import RichText from '../../RichText'
import { Gutter } from '../../Gutter'
import { CMSLink } from '../../Link'
import classes from './index.module.scss'
type Props = Extract<Page['layout'][0], { blockType: 'content' }>
const Columns: React.FC<Props> = ({
layout,
columnOne,
columnTwo,
columnThree,
}) => {
switch (layout) {
case 'oneColumn': {
return (
<Cell cols={9} colsM={4}>
<RichText content={columnOne.richText} />
{columnOne.enableLink && (
<CMSLink className={classes.link} {...columnOne.link} />
)}
</Cell>
)
}
case 'halfAndHalf':
case 'twoThirdsOneThird': {
let col1Cols = 6
let col2Cols = 6
if (layout === 'twoThirdsOneThird') {
col1Cols = 8
col2Cols = 4
}
return (
<React.Fragment>
<Cell cols={col1Cols} colsM={4}>
<RichText content={columnOne.richText} />
{columnOne.enableLink && (
<CMSLink className={classes.link} {...columnOne.link} />
)}
</Cell>
<Cell cols={col2Cols} colsM={4}>
<RichText content={columnTwo.richText} />
{columnTwo.enableLink && (
<CMSLink className={classes.link} {...columnTwo.link} />
)}
</Cell>
</React.Fragment>
)
}
case 'threeColumns': {
return (
<React.Fragment>
<Cell cols={4} colsM={4}>
<RichText content={columnOne.richText} />
{columnOne.enableLink && (
<CMSLink className={classes.link} {...columnOne.link} />
)}
</Cell>
<Cell cols={4} colsM={4}>
<RichText content={columnTwo.richText} />
{columnTwo.enableLink && (
<CMSLink className={classes.link} {...columnTwo.link} />
)}
</Cell>
<Cell cols={4} colsM={4}>
<RichText content={columnThree.richText} />
{columnThree.enableLink && (
<CMSLink className={classes.link} {...columnThree.link} />
)}
</Cell>
</React.Fragment>
)
}
default:
break
}
return null
}
export const ContentBlock: React.FC<Props> = (props) => {
return (
<Gutter className={classes.mediaBlock}>
<Grid>
<Columns {...props} />
</Grid>
</Gutter>
)
}
.mediaBlock {
position: relative;
}
.caption {
margin-top: var(--base);
}
import React from 'react'
import { Gutter } from '../../Gutter'
import { Media } from '../../Media'
import { Media as MediaType } from '../../../payload-types'
import RichText from '../../RichText'
import classes from './index.module.scss'
export const MediaBlock: React.FC<{
media?: MediaType
caption?: string
position?: 'default' | 'fullscreen'
mediaBackgroundColor?: string
}> = (props) => {
const { media, caption, position = 'default' } = props
return (
<div className={classes.mediaBlock}>
{position === 'fullscreen' && (
<div>
<Media resource={media} />
</div>
)}
{position === 'default' && (
<Gutter>
<div>
<Media resource={media} />
</div>
</Gutter>
)}
{caption && (
<Gutter className={classes.caption}>
<RichText content={caption} />
</Gutter>
)}
</div>
)
}
'use client'
import React, { Fragment } from 'react'
import { Page } from '../../payload-types'
import { toKebabCase } from '../../utilities/toKebabCase'
import { BackgroundColor } from '../BackgroundColor'
import { VerticalPaddingOptions } from '../VerticalPadding'
import { CallToActionBlock } from './CallToAction'
import { ContentBlock } from './Content'
import { MediaBlock } from './MediaBlock'
const blockComponents = {
cta: CallToActionBlock,
content: ContentBlock,
mediaBlock: MediaBlock,
}
const Blocks: React.FC<{
blocks: Page['layout']
}> = (props) => {
const { blocks } = props
const hasBlocks = blocks && Array.isArray(blocks) && blocks.length > 0
if (hasBlocks) {
return (
<Fragment>
{blocks.map((block, index) => {
const { blockName, blockType } = block
if (blockType && blockType in blockComponents) {
const Block = blockComponents[blockType]
const backgroundColor = block[`${blockType}BackgroundColor`]
const prevBlock = blocks[index - 1]
const nextBlock = blocks[index + 1]
const prevBlockBackground =
prevBlock?.[`${prevBlock.blockType}BackgroundColor`]
const nextBlockBackground =
nextBlock?.[`${nextBlock.blockType}BackgroundColor`]
let paddingTop: VerticalPaddingOptions = 'large'
let paddingBottom: VerticalPaddingOptions = 'large'
if (backgroundColor === prevBlockBackground) {
paddingTop = 'medium'
}
if (backgroundColor === nextBlockBackground) {
paddingBottom = 'medium'
}
if (Block) {
return (
<BackgroundColor
key={index}
paddingTop={paddingTop}
paddingBottom={paddingBottom}
color={backgroundColor}
>
<Block
// @ts-ignore
id={toKebabCase(blockName)}
{...block}
/>
</BackgroundColor>
)
}
}
return null
})}
</Fragment>
)
}
return null
}
export default Blocks
@import '../../css/type.scss';
.content {
display: flex;
align-items: center;
justify-content: space-around;
svg {
margin-right: calc(var(--base) / 2);
width: var(--base);
height: var(--base);
}
}
.label {
@extend %label;
display: flex;
align-items: center;
}
.button {
text-decoration: none;
display: inline-flex;
padding: 12px 18px;
margin-bottom: var(--base);
}
.primary--white {
background-color: black;
color: white;
}
.primary--black {
background-color: white;
color: black;
}
.secondary--white {
background-color: white;
box-shadow: inset 0 0 0 1px black;
}
.secondary--black {
background-color: black;
box-shadow: inset 0 0 0 1px white;
}
.appearance--default {
padding: 0;
margin-left: -8px;
}
import Link from 'next/link'
import React, { ElementType } from 'react'
import { useBackgroundColor } from '../BackgroundColor'
import { Chevron } from '../icons/Chevron'
import classes from './index.module.scss'
export type Props = {
label?: string
appearance?: 'default' | 'primary' | 'secondary'
el?: 'button' | 'link' | 'a'
onClick?: () => void
href?: string
newTab?: boolean
className?: string
}
export const Button: React.FC<Props> = ({
el = 'button',
label,
newTab,
href,
appearance,
className: classNameFromProps,
}) => {
const backgroundColor = useBackgroundColor()
const newTabProps = newTab
? { target: '_blank', rel: 'noopener noreferrer' }
: {}
const className = [
classNameFromProps,
classes[`appearance--${appearance}`],
classes[`${appearance}--${backgroundColor}`],
classes.button,
]
.filter(Boolean)
.join(' ')
const content = (
<div className={classes.content}>
<Chevron />
<span className={classes.label}>{label}</span>
</div>
)
if (el === 'link') {
return (
<Link {...newTabProps} href={href || ''} className={className}>
{content}
</Link>
)
}
const Element: ElementType = el
return (
<Element href={href} className={className} {...newTabProps}>
{content}
</Element>
)
}
.gutterLeft {
padding-left: var(--gutter-h);
}
.gutterRight {
padding-right: var(--gutter-h);
}
import React, { forwardRef, Ref } from 'react'
import classes from './index.module.scss'
type Props = {
left?: boolean
right?: boolean
className?: string
children: React.ReactNode
ref?: Ref<HTMLDivElement>
}
export const Gutter: React.FC<Props> = forwardRef<HTMLDivElement, Props>(
(props, ref) => {
const { left = true, right = true, className, children } = props
return (
<div
ref={ref}
className={[
left && classes.gutterLeft,
right && classes.gutterRight,
className,
]
.filter(Boolean)
.join(' ')}
>
{children}
</div>
)
}
)
Gutter.displayName = 'Gutter'
import React from 'react'
import { Modal } from '@faceless-ui/modal'
import { HeaderBar } from '.'
import { MainMenu } from '../../payload-types'
import { Gutter } from '../Gutter'
import { CMSLink } from '../Link'
import classes from './mobileMenuModal.module.scss'
type Props = {
navItems: MainMenu['navItems']
}
export const slug = 'menu-modal'
export const MobileMenuModal: React.FC<Props> = ({ navItems }) => {
return (
<Modal slug={slug} className={classes.mobileMenuModal}>
<HeaderBar />
<Gutter>
<div className={classes.mobileMenuItems}>
{navItems.map(({ link }, i) => {
return <CMSLink className={classes.menuItem} key={i} {...link} />
})}
</div>
</Gutter>
</Modal>
)
}
@use '../../css/queries.scss' as *;
.header {
padding: var(--base) 0;
z-index: var(--header-z-index);
}
.wrap {
display: flex;
justify-content: space-between;
}
.nav {
a {
text-decoration: none;
margin-left: var(--base);
}
@include mid-break {
display: none;
}
}
.mobileMenuToggler {
all: unset;
cursor: pointer;
display: none;
&[aria-expanded='true'] {
transform: rotate(-25deg);
}
@include mid-break {
display: block;
}
}
import { ModalToggler } from '@faceless-ui/modal'
import Link from 'next/link'
import React from 'react'
import { MainMenu } from '../../payload-types'
import { Gutter } from '../Gutter'
import { MenuIcon } from '../icons/Menu'
import { CMSLink } from '../Link'
import { Logo } from '../Logo'
import { MobileMenuModal, slug as menuModalSlug } from './MobileMenuModal'
import classes from './index.module.scss'
type HeaderBarProps = {
children?: React.ReactNode
}
export const HeaderBar: React.FC<HeaderBarProps> = ({ children }) => {
return (
<header className={classes.header}>
<Gutter className={classes.wrap}>
<Link href="/">
<Logo />
</Link>
{children}
<ModalToggler
slug={menuModalSlug}
className={classes.mobileMenuToggler}
>
<MenuIcon />
</ModalToggler>
</Gutter>
</header>
)
}
export const Header: React.FC<{ mainMenu: MainMenu }> = ({ mainMenu }) => {
const navItems = mainMenu?.navItems || []
return (
<>
<HeaderBar>
<nav className={classes.nav}>
{navItems.map(({ link }, i) => {
return <CMSLink key={i} {...link} />
})}
</nav>
</HeaderBar>
<MobileMenuModal navItems={navItems} />
</>
)
}
@use '../../css/common.scss' as *;
.mobileMenuModal {
position: relative;
width: 100%;
height: 100%;
border: none;
padding: 0;
opacity: 1;
display: none;
@include mid-break {
display: block;
}
}
.contentContainer {
padding: 20px;
}
.mobileMenuItems {
display: flex;
flex-direction: column;
height: 100%;
margin-top: 30px;
}
.menuItem {
@extend %h4;
margin-top: 0;
}
@import '../../../css/queries';
.hero {
padding-top: calc(var(--base) * 3);
@include mid-break {
padding-top: var(--base);
}
}
.media {
margin-top: calc(var(--base) * 3);
width: calc(100% + var(--gutter-h));
position: relative;
@include mid-break {
margin-top: var(--base);
margin-left: calc(var(--gutter-h) * -1);
width: calc(100% + var(--gutter-h) * 2);
}
}
.links {
list-style: none;
margin: 0;
padding: 0;
display: flex;
position: absolute;
background: white;
padding: 0 48px 24px 0;
li {
margin-right: 12px;
}
@include mid-break {
position: static;
padding: 0 var(--gutter-h);
display: block;
li {
margin-right: 0;
> * {
width: 100%;
}
}
}
}
import { Cell, Grid } from '@faceless-ui/css-grid'
import React from 'react'
import { Page } from '../../../payload-types'
import { Gutter } from '../../Gutter'
import { CMSLink } from '../../Link'
import { Media } from '../../Media'
import RichText from '../../RichText'
import classes from './index.module.scss'
export const HighImpactHero: React.FC<Page['hero']> = ({
richText,
media,
links,
}) => {
return (
<Gutter className={classes.hero}>
<Grid>
<Cell cols={10} colsM={4}>
<RichText content={richText} />
</Cell>
</Grid>
<div className={classes.media}>
{Array.isArray(links) && links.length > 0 && (
<ul className={classes.links}>
{links.map(({ link }, i) => {
return (
<li key={i}>
<CMSLink {...link} />
</li>
)
})}
</ul>
)}
{typeof media === 'object' && <Media resource={media} />}
</div>
</Gutter>
)
}
@use '../../../css/type.scss' as *;
.richText {
h1 {
@extend %h2;
}
}
import React from 'react'
import { Cell, Grid } from '@faceless-ui/css-grid'
import { Page } from '../../../payload-types'
import { Gutter } from '../../Gutter'
import RichText from '../../RichText'
import { VerticalPadding } from '../../VerticalPadding'
import classes from './index.module.scss'
export const LowImpactHero: React.FC<Page['hero']> = ({ richText }) => {
return (
<Gutter>
<Grid>
<Cell cols={8} colsL={10}>
<VerticalPadding>
<RichText className={classes.richText} content={richText} />
</VerticalPadding>
</Cell>
</Grid>
</Gutter>
)
}
@use '../../../css/common.scss' as *;
.hero {
padding-top: calc(var(--base) * 3);
@include mid-break {
padding-top: var(--base);
}
}
.richText {
position: relative;
h1 {
@extend %h2;
}
&::after {
content: '';
display: block;
position: absolute;
width: 100vw;
left: calc(var(--gutter-h) * -1);
height: 200px;
background: linear-gradient(to bottom, var(--color-base-100), transparent);
top: calc(100% + (var(--base) * 2));
right: 0;
@include mid-break {
display: none;
}
}
}
.links {
position: relative;
list-style: none;
margin: 0;
padding: 0;
display: flex;
margin-top: calc(var(--base) * 4);
li {
margin-right: 12px;
}
@include mid-break {
display: block;
margin-top: var(--base);
li {
margin-right: 0;
}
}
}
.link {
@include mid-break {
width: 100%;
}
}
.media {
position: relative;
width: calc(100% + var(--gutter-h));
}
import { Cell, Grid } from '@faceless-ui/css-grid'
import React from 'react'
import { Page } from '../../../payload-types'
import { Gutter } from '../../Gutter'
import { CMSLink } from '../../Link'
import { Media } from '../../Media'
import RichText from '../../RichText'
import classes from './index.module.scss'
export const MediumImpactHero: React.FC<Page['hero']> = (props) => {
const { richText, media, links } = props
return (
<Gutter className={classes.hero}>
<Grid>
<Cell cols={5} colsM={4}>
<RichText className={classes.richText} content={richText} />
{Array.isArray(links) && (
<ul className={classes.links}>
{links.map(({ link }, i) => {
return (
<li key={i}>
<CMSLink className={classes.link} {...link} />
</li>
)
})}
</ul>
)}
</Cell>
<Cell cols={7} colsM={4}>
{typeof media === 'object' && (
<Media className={classes.media} resource={media} />
)}
</Cell>
</Grid>
</Gutter>
)
}
'use client'
import React from 'react'
import { Page } from '../../payload-types'
import { HighImpactHero } from './HighImpact'
import { MediumImpactHero } from './MediumImpact'
import { LowImpactHero } from './LowImpact'
const heroes = {
highImpact: HighImpactHero,
mediumImpact: MediumImpactHero,
lowImpact: LowImpactHero,
}
export const Hero: React.FC<Page['hero']> = (props) => {
const { type } = props
const HeroToRender = heroes[type]
if (!HeroToRender) return null
return <HeroToRender {...props} />
}
@import '../../css/type.scss';
.label {
@extend %label;
}
import React from 'react'
import classes from './index.module.scss'
export const Label: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
return <p className={classes.label}>{children}</p>
}
@import '../../css/type.scss';
.largeBody {
@extend %large-body;
}
import React from 'react'
import classes from './index.module.scss'
export const LargeBody: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
return <p className={classes.largeBody}>{children}</p>
}
'use client'
import { GridProvider } from '@faceless-ui/css-grid'
import { ModalContainer, ModalProvider } from '@faceless-ui/modal'
import React from 'react'
import { Header } from '../Header'
import { MainMenu } from '../../payload-types'
import cssVariables from '../../cssVariables'
import '../../css/app.scss'
type Props = {
mainMenu: MainMenu
children: React.ReactNode
}
const Layout = ({ mainMenu, children }: Props): React.ReactElement => {
return (
<React.Fragment>
<GridProvider
breakpoints={{
s: cssVariables.breakpoints.s,
m: cssVariables.breakpoints.m,
l: cssVariables.breakpoints.l,
}}
colGap={{
s: '24px',
m: '48px',
l: '48px',
xl: '72px',
}}
cols={{
s: 4,
m: 4,
l: 12,
xl: 12,
}}
>
<ModalProvider transTime={0} zIndex="var(--modal-z-index)">
<Header mainMenu={mainMenu} />
{children}
<ModalContainer />
</ModalProvider>
</GridProvider>
</React.Fragment>
)
}
export default Layout
import Link from 'next/link'
import React from 'react'
import { Page } from '../../payload-types'
import { Button } from '../Button'
type CMSLinkType = {
type?: 'custom' | 'reference'
url?: string
newTab?: boolean
reference?: {
value: string | Page
relationTo: 'pages'
}
label?: string
appearance?: 'default' | 'primary' | 'secondary'
children?: React.ReactNode
className?: string
}
export const CMSLink: React.FC<CMSLinkType> = ({
type,
url,
newTab,
reference,
label,
appearance,
children,
className,
}) => {
const href =
type === 'reference' &&
typeof reference?.value === 'object' &&
reference.value.slug
? `/${reference.value.slug}`
: url
if (!appearance) {
const newTabProps = newTab
? { target: '_blank', rel: 'noopener noreferrer' }
: {}
if (type === 'custom') {
return (
<a href={url} {...newTabProps} className={className}>
{label && label}
{children && children}
</a>
)
}
if (href) {
return (
<Link href={href} className={className} {...newTabProps}>
{label && label}
{children && children}
</Link>
)
}
}
const buttonProps = {
newTab,
href,
appearance,
label,
}
return <Button className={className} {...buttonProps} el="link" />
}
import React from 'react'
export const Logo: React.FC = () => {
return (
<svg
width="123"
height="29"
viewBox="0 0 123 29"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M34.7441 22.9997H37.2741V16.3297H41.5981C44.7031 16.3297 46.9801 14.9037 46.9801 11.4537C46.9801 8.00369 44.7031 6.55469 41.5981 6.55469H34.7441V22.9997ZM37.2741 14.1447V8.73969H41.4831C43.3921 8.73969 44.3581 9.59069 44.3581 11.4537C44.3581 13.2937 43.3921 14.1447 41.4831 14.1447H37.2741Z"
fill="black"
/>
<path
d="M51.3652 23.3217C53.2742 23.3217 54.6082 22.5627 55.3672 21.3437H55.4132C55.5512 22.6777 56.1492 23.1147 57.2762 23.1147C57.6442 23.1147 58.0352 23.0687 58.4262 22.9767V21.5967C58.2882 21.6197 58.2192 21.6197 58.1502 21.6197C57.7132 21.6197 57.5982 21.1827 57.5982 20.3317V14.9497C57.5982 11.9137 55.6662 10.9017 53.2512 10.9017C49.6632 10.9017 48.1912 12.6727 48.0762 14.9267H50.3762C50.4912 13.3627 51.1122 12.7187 53.1592 12.7187C54.8842 12.7187 55.3902 13.4317 55.3902 14.2827C55.3902 15.4327 54.2632 15.6627 52.4232 16.0077C49.5022 16.5597 47.5242 17.3417 47.5242 19.9637C47.5242 21.9647 49.0192 23.3217 51.3652 23.3217ZM49.8702 19.8027C49.8702 18.5837 50.7442 18.0087 52.8142 17.5947C54.0102 17.3417 55.0222 17.0887 55.3902 16.7437V18.4227C55.3902 20.4697 53.8952 21.5047 51.8712 21.5047C50.4682 21.5047 49.8702 20.9067 49.8702 19.8027Z"
fill="black"
/>
<path
d="M61.4996 27.1167C63.3166 27.1167 64.4436 26.1737 65.5706 23.2757L70.2166 11.2697H67.8476L64.6276 20.2397H64.5816L61.1546 11.2697H58.6936L63.4316 22.8847C62.9716 24.7247 61.9136 25.1847 61.0166 25.1847C60.6486 25.1847 60.4416 25.1617 60.0506 25.1157V26.9557C60.6486 27.0707 60.9936 27.1167 61.4996 27.1167Z"
fill="black"
/>
<path
d="M71.5939 22.9997H73.8479V6.55469H71.5939V22.9997Z"
fill="black"
/>
<path
d="M81.6221 23.3447C85.2791 23.3447 87.4871 20.7917 87.4871 17.1117C87.4871 13.4547 85.2791 10.9017 81.6451 10.9017C77.9651 10.9017 75.7571 13.4777 75.7571 17.1347C75.7571 20.8147 77.9651 23.3447 81.6221 23.3447ZM78.1031 17.1347C78.1031 14.6737 79.2071 12.7877 81.6451 12.7877C84.0371 12.7877 85.1411 14.6737 85.1411 17.1347C85.1411 19.5727 84.0371 21.4817 81.6451 21.4817C79.2071 21.4817 78.1031 19.5727 78.1031 17.1347Z"
fill="black"
/>
<path
d="M92.6484 23.3217C94.5574 23.3217 95.8914 22.5627 96.6504 21.3437H96.6964C96.8344 22.6777 97.4324 23.1147 98.5594 23.1147C98.9274 23.1147 99.3184 23.0687 99.7094 22.9767V21.5967C99.5714 21.6197 99.5024 21.6197 99.4334 21.6197C98.9964 21.6197 98.8814 21.1827 98.8814 20.3317V14.9497C98.8814 11.9137 96.9494 10.9017 94.5344 10.9017C90.9464 10.9017 89.4744 12.6727 89.3594 14.9267H91.6594C91.7744 13.3627 92.3954 12.7187 94.4424 12.7187C96.1674 12.7187 96.6734 13.4317 96.6734 14.2827C96.6734 15.4327 95.5464 15.6627 93.7064 16.0077C90.7854 16.5597 88.8074 17.3417 88.8074 19.9637C88.8074 21.9647 90.3024 23.3217 92.6484 23.3217ZM91.1534 19.8027C91.1534 18.5837 92.0274 18.0087 94.0974 17.5947C95.2934 17.3417 96.3054 17.0887 96.6734 16.7437V18.4227C96.6734 20.4697 95.1784 21.5047 93.1544 21.5047C91.7514 21.5047 91.1534 20.9067 91.1534 19.8027Z"
fill="black"
/>
<path
d="M106.181 23.3217C108.021 23.3217 109.148 22.4477 109.792 21.6197H109.838V22.9997H112.092V6.55469H109.838V12.6957H109.792C109.148 11.7757 108.021 10.9247 106.181 10.9247C103.191 10.9247 100.914 13.2707 100.914 17.1347C100.914 20.9987 103.191 23.3217 106.181 23.3217ZM103.26 17.1347C103.26 14.8347 104.341 12.8107 106.549 12.8107C108.573 12.8107 109.815 14.4667 109.815 17.1347C109.815 19.7797 108.573 21.4587 106.549 21.4587C104.341 21.4587 103.26 19.4347 103.26 17.1347Z"
fill="black"
/>
<path
d="M12.2464 2.33838L22.2871 8.83812V21.1752L14.7265 25.8854V13.5484L4.67383 7.05725L12.2464 2.33838Z"
fill="black"
/>
<path
d="M11.477 25.2017V15.5747L3.90039 20.2936L11.477 25.2017Z"
fill="black"
/>
<path
d="M120.442 6.30273C119.086 6.30273 117.998 7.29978 117.998 8.75952C117.998 10.2062 119.086 11.1968 120.442 11.1968C121.791 11.1968 122.879 10.2062 122.879 8.75952C122.879 7.29978 121.791 6.30273 120.442 6.30273ZM120.442 10.7601C119.34 10.7601 118.48 9.95207 118.48 8.75952C118.48 7.54742 119.34 6.73935 120.442 6.73935C121.563 6.73935 122.397 7.54742 122.397 8.75952C122.397 9.95207 121.563 10.7601 120.442 10.7601ZM120.52 8.97457L121.048 9.9651H121.641L121.041 8.86378C121.367 8.72042 121.511 8.45975 121.511 8.17302C121.511 7.49528 121.054 7.36495 120.285 7.36495H119.49V9.9651H120.025V8.97457H120.52ZM120.37 7.78853C120.729 7.78853 120.976 7.86673 120.976 8.17953C120.976 8.43368 120.807 8.56402 120.403 8.56402H120.025V7.78853H120.37Z"
fill="black"
/>
</svg>
)
}
.placeholder-color-light {
background-color: rgba(0, 0, 0, 0.05);
}
.placeholder {
background-color: var(--color-base-50);
}
import React from 'react'
import NextImage, { StaticImageData } from 'next/image'
import classes from './index.module.scss'
import cssVariables from '../../../cssVariables'
import { Props } from '..'
const { breakpoints } = cssVariables
export const Image: React.FC<Props> = (props) => {
const {
imgClassName,
onClick,
onLoad: onLoadFromProps,
resource,
priority,
fill,
src: srcFromProps,
alt: altFromProps,
} = props
const [isLoading, setIsLoading] = React.useState(true)
let width: number | undefined
let height: number | undefined
let alt = altFromProps
let src: StaticImageData | string = srcFromProps || ''
if (!src && resource && typeof resource !== 'string') {
const {
width: fullWidth,
height: fullHeight,
filename: fullFilename,
alt: altFromResource,
} = resource
width = fullWidth
height = fullHeight
alt = altFromResource
let filename = fullFilename
src = `${process.env.NEXT_PUBLIC_S3_ENDPOINT}/${process.env.NEXT_PUBLIC_S3_BUCKET}/${filename}`
}
// NOTE: this is used by the browser to determine which image to download at different screen sizes
const sizes = Object.entries(breakpoints)
.map(([, value]) => `(max-width: ${value}px) ${value}px`)
.join(', ')
return (
<NextImage
className={[isLoading && classes.placeholder, classes.image, imgClassName]
.filter(Boolean)
.join(' ')}
src={src}
alt={alt || ''}
onClick={onClick}
onLoad={() => {
setIsLoading(false)
if (typeof onLoadFromProps === 'function') {
onLoadFromProps()
}
}}
fill={fill}
width={!fill ? width : undefined}
height={!fill ? height : undefined}
sizes={sizes}
priority={priority}
/>
)
}
.video {
max-width: 100%;
width: 100%;
background-color: var(--color-base-50);
}
.cover {
object-fit: cover;
width: 100%;
height: 100%;
}
import React, { useEffect, useRef } from 'react'
import classes from './index.module.scss'
import { Props } from '..'
export const Video: React.FC<Props> = (props) => {
const { videoClassName, resource, onClick } = props
const videoRef = useRef<HTMLVideoElement>(null)
useEffect(() => {
const { current: video } = videoRef
if (video) {
video.addEventListener('suspend', () => {
// setShowFallback(true);
// console.warn('Video was suspended, rendering fallback image.')
})
}
}, [])
if (resource && typeof resource !== 'string') {
const { filename } = resource
return (
<video
playsInline
autoPlay
muted
loop
controls={false}
className={[classes.video, videoClassName].filter(Boolean).join(' ')}
onClick={onClick}
ref={videoRef}
>
<source src={`${process.env.NEXT_PUBLIC_API_URL}/media/${filename}`} />
</video>
)
}
return null
}
import React, { ElementType, Fragment, Ref } from 'react'
import { Video } from './Video'
import { Image } from './Image'
import { StaticImageData } from 'next/image'
import { Media as MediaType } from '../../payload-types'
export type Props = {
src?: StaticImageData // for static media
alt?: string
resource?: MediaType // for Payload media
size?: string // for NextImage only
priority?: boolean // for NextImage only
fill?: boolean // for NextImage only
className?: string
imgClassName?: string
videoClassName?: string
htmlElement?: ElementType | null
onClick?: () => void
onLoad?: () => void
ref?: Ref<null | HTMLImageElement | HTMLVideoElement>
}
export const Media: React.FC<Props> = (props) => {
const { className, resource, htmlElement = 'div' } = props
const isVideo =
typeof resource !== 'string' && resource?.mimeType?.includes('video')
const Tag = (htmlElement as ElementType) || Fragment
return (
<Tag
{...(htmlElement !== null
? {
className,
}
: {})}
>
{isVideo ? (
<Video {...props} />
) : (
<Image {...props} /> // eslint-disable-line
)}
</Tag>
)
}
.richText {
:first-child {
margin-top: 0;
}
}
import React from 'react'
import serialize from './serialize'
import classes from './index.module.scss'
const RichText: React.FC<{ className?: string; content: any }> = ({
className,
content,
}) => {
if (!content) {
return null
}
return (
<div className={[classes.richText, className].filter(Boolean).join(' ')}>
{serialize(content)}
</div>
)
}
export default RichText
import React, { Fragment } from 'react'
import escapeHTML from 'escape-html'
import { Text } from 'slate'
import { Label } from '../Label'
import { LargeBody } from '../LargeBody'
// eslint-disable-next-line no-use-before-define
type Children = Leaf[]
type Leaf = {
type: string
value?: {
url: string
alt: string
}
children: Children
url?: string
[key: string]: unknown
}
const serialize = (children: Children): React.ReactNode[] =>
children.map((node, i) => {
if (Text.isText(node)) {
let text = (
<span dangerouslySetInnerHTML={{ __html: escapeHTML(node.text) }} />
)
if (node.bold) {
text = <strong key={i}>{text}</strong>
}
if (node.code) {
text = <code key={i}>{text}</code>
}
if (node.italic) {
text = <em key={i}>{text}</em>
}
if (node.underline) {
text = (
<span style={{ textDecoration: 'underline' }} key={i}>
{text}
</span>
)
}
if (node.strikethrough) {
text = (
<span style={{ textDecoration: 'line-through' }} key={i}>
{text}
</span>
)
}
return <Fragment key={i}>{text}</Fragment>
}
if (!node) {
return null
}
switch (node.type) {
case 'h1':
return <h1 key={i}>{serialize(node.children)}</h1>
case 'h2':
return <h2 key={i}>{serialize(node.children)}</h2>
case 'h3':
return <h3 key={i}>{serialize(node.children)}</h3>
case 'h4':
return <h4 key={i}>{serialize(node.children)}</h4>
case 'h5':
return <h5 key={i}>{serialize(node.children)}</h5>
case 'h6':
return <h6 key={i}>{serialize(node.children)}</h6>
case 'quote':
return <blockquote key={i}>{serialize(node.children)}</blockquote>
case 'ul':
return <ul key={i}>{serialize(node.children)}</ul>
case 'ol':
return <ol key={i}>{serialize(node.children)}</ol>
case 'li':
return <li key={i}>{serialize(node.children)}</li>
case 'link':
return (
<a href={escapeHTML(node.url)} key={i}>
{serialize(node.children)}
</a>
)
case 'label':
return <Label key={i}>{serialize(node.children)}</Label>
case 'large-body': {
return <LargeBody key={i}>{serialize(node.children)}</LargeBody>
}
default:
return <p key={i}>{serialize(node.children)}</p>
}
})
export default serialize
.top-large {
padding-top: var(--block-padding);
}
.top-medium {
padding-top: calc(var(--block-padding) / 2);
}
.bottom-large {
padding-bottom: var(--block-padding);
}
.bottom-medium {
padding-bottom: calc(var(--block-padding) / 2);
}
import React from 'react'
import classes from './index.module.scss'
export type VerticalPaddingOptions = 'large' | 'medium' | 'none'
type Props = {
top?: VerticalPaddingOptions
bottom?: VerticalPaddingOptions
children: React.ReactNode
className?: string
}
export const VerticalPadding: React.FC<Props> = ({
top = 'medium',
bottom = 'medium',
className,
children,
}) => {
return (
<div
className={[className, classes[`top-${top}`], classes[`bottom-${bottom}`]]
.filter(Boolean)
.join(' ')}
>
{children}
</div>
)
}
import React from 'react'
export const Chevron: React.FC = () => {
return (
<svg
width="25"
height="25"
viewBox="0 0 25 25"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10.5 16L14.5 12.5L10.5 9"
stroke="currentColor"
strokeWidth="2"
/>
</svg>
)
}
import React from 'react'
export const MenuIcon: React.FC = () => {
return (
<svg
width="25"
height="25"
viewBox="0 0 25 25"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<rect x="3.5" y="4.5" width="18" height="2" fill="currentColor" />
<rect x="3.5" y="11.5" width="18" height="2" fill="currentColor" />
<rect x="3.5" y="18.5" width="18" height="2" fill="currentColor" />
</svg>
)
}
@use './queries.scss' as *;
@use './colors.scss' as *;
@use './type.scss' as *;
:root {
--breakpoint-xs-width: #{$breakpoint-xs-width};
--breakpoint-s-width: #{$breakpoint-s-width};
--breakpoint-m-width: #{$breakpoint-m-width};
--breakpoint-l-width: #{$breakpoint-l-width};
--scrollbar-width: 17px;
--base: 24px;
--font-body: system-ui;
--font-mono: 'Roboto Mono', monospace;
--gutter-h: 180px;
--block-padding: 120px;
--header-z-index: 100;
--modal-z-index: 90;
@include large-break {
--gutter-h: 144px;
--block-padding: 96px;
}
@include mid-break {
--gutter-h: 24px;
--block-padding: 60px;
}
}
/////////////////////////////
// GLOBAL STYLES
/////////////////////////////
* {
box-sizing: border-box;
}
html {
@extend %body;
background: var(--color-base-0);
-webkit-font-smoothing: antialiased;
}
html,
body,
#app {
height: 100%;
}
body {
font-family: var(--font-body);
color: var(--color-base-1000);
margin: 0;
}
::selection {
background: var(--color-success-500);
color: var(--color-base-800);
}
::-moz-selection {
background: var(--color-success-500);
color: var(--color-base-800);
}
img {
max-width: 100%;
height: auto;
display: block;
}
h1 {
@extend %h1;
}
h2 {
@extend %h2;
}
h3 {
@extend %h3;
}
h4 {
@extend %h4;
}
h5 {
@extend %h5;
}
h6 {
@extend %h6;
}
p {
margin: var(--base) 0;
@include mid-break {
margin: calc(var(--base) * 0.75) 0;
}
}
ul,
ol {
padding-left: var(--base);
margin: 0 0 var(--base);
}
a {
color: currentColor;
&:focus {
opacity: 0.8;
outline: none;
}
&:active {
opacity: 0.7;
outline: none;
}
}
svg {
vertical-align: middle;
}
:root {
--color-base-0: rgb(255, 255, 255);
--color-base-50: rgb(245, 245, 245);
--color-base-100: rgb(235, 235, 235);
--color-base-150: rgb(221, 221, 221);
--color-base-200: rgb(208, 208, 208);
--color-base-250: rgb(195, 195, 195);
--color-base-300: rgb(181, 181, 181);
--color-base-350: rgb(168, 168, 168);
--color-base-400: rgb(154, 154, 154);
--color-base-450: rgb(141, 141, 141);
--color-base-500: rgb(128, 128, 128);
--color-base-550: rgb(114, 114, 114);
--color-base-600: rgb(101, 101, 101);
--color-base-650: rgb(87, 87, 87);
--color-base-700: rgb(74, 74, 74);
--color-base-750: rgb(60, 60, 60);
--color-base-800: rgb(47, 47, 47);
--color-base-850: rgb(34, 34, 34);
--color-base-900: rgb(20, 20, 20);
--color-base-950: rgb(7, 7, 7);
--color-base-1000: rgb(0, 0, 0);
--color-success-50: rgb(247, 255, 251);
--color-success-100: rgb(240, 255, 247);
--color-success-150: rgb(232, 255, 243);
--color-success-200: rgb(224, 255, 239);
--color-success-250: rgb(217, 255, 235);
--color-success-300: rgb(209, 255, 230);
--color-success-350: rgb(201, 255, 226);
--color-success-400: rgb(193, 255, 222);
--color-success-450: rgb(186, 255, 218);
--color-success-500: rgb(178, 255, 214);
--color-success-550: rgb(160, 230, 193);
--color-success-600: rgb(142, 204, 171);
--color-success-650: rgb(125, 179, 150);
--color-success-700: rgb(107, 153, 128);
--color-success-750: rgb(89, 128, 107);
--color-success-800: rgb(71, 102, 86);
--color-success-850: rgb(53, 77, 64);
--color-success-900: rgb(36, 51, 43);
--color-success-950: rgb(18, 25, 21);
--color-warning-50: rgb(255, 255, 246);
--color-warning-100: rgb(255, 255, 237);
--color-warning-150: rgb(254, 255, 228);
--color-warning-200: rgb(254, 255, 219);
--color-warning-250: rgb(254, 255, 210);
--color-warning-300: rgb(254, 255, 200);
--color-warning-350: rgb(254, 255, 191);
--color-warning-400: rgb(253, 255, 182);
--color-warning-450: rgb(253, 255, 173);
--color-warning-500: rgb(253, 255, 164);
--color-warning-550: rgb(228, 230, 148);
--color-warning-600: rgb(202, 204, 131);
--color-warning-650: rgb(177, 179, 115);
--color-warning-700: rgb(152, 153, 98);
--color-warning-750: rgb(127, 128, 82);
--color-warning-800: rgb(101, 102, 66);
--color-warning-850: rgb(76, 77, 49);
--color-warning-900: rgb(51, 51, 33);
--color-warning-950: rgb(25, 25, 16);
--color-error-50: rgb(255, 241, 241);
--color-error-100: rgb(255, 226, 228);
--color-error-150: rgb(255, 212, 214);
--color-error-200: rgb(255, 197, 200);
--color-error-250: rgb(255, 183, 187);
--color-error-300: rgb(255, 169, 173);
--color-error-350: rgb(255, 154, 159);
--color-error-400: rgb(255, 140, 145);
--color-error-450: rgb(255, 125, 132);
--color-error-500: rgb(255, 111, 118);
--color-error-550: rgb(230, 100, 106);
--color-error-600: rgb(204, 89, 94);
--color-error-650: rgb(179, 78, 83);
--color-error-700: rgb(153, 67, 71);
--color-error-750: rgb(128, 56, 59);
--color-error-800: rgb(102, 44, 47);
--color-error-850: rgb(77, 33, 35);
--color-error-900: rgb(51, 22, 24);
--color-error-950: rgb(25, 11, 12);
}
@forward './queries.scss';
@forward './type.scss';
$breakpoint-xs-width: 400px;
$breakpoint-s-width: 768px;
$breakpoint-m-width: 1024px;
$breakpoint-l-width: 1440px;
////////////////////////////
// MEDIA QUERIES
/////////////////////////////
@mixin extra-small-break {
@media (max-width: #{$breakpoint-xs-width}) {
@content;
}
}
@mixin small-break {
@media (max-width: #{$breakpoint-s-width}) {
@content;
}
}
@mixin mid-break {
@media (max-width: #{$breakpoint-m-width}) {
@content;
}
}
@mixin large-break {
@media (max-width: #{$breakpoint-l-width}) {
@content;
}
}
@use 'queries' as *;
/////////////////////////////
// HEADINGS
/////////////////////////////
%h1,
%h2,
%h3,
%h4,
%h5,
%h6 {
font-weight: 700;
}
%h1 {
margin: 50px 0;
font-size: 84px;
line-height: 1;
@include mid-break {
font-size: 70px;
}
@include small-break {
margin: 24px 0;
font-size: 36px;
line-height: 42px;
}
}
%h2 {
margin: 32px 0;
font-size: 56px;
line-height: 1;
@include mid-break {
margin: 36px 0;
font-size: 48px;
}
@include small-break {
margin: 24px 0;
font-size: 28px;
line-height: 32px;
}
}
%h3 {
margin: 28px 0;
font-size: 48px;
line-height: 56px;
@include mid-break {
font-size: 40px;
line-height: 48px;
}
@include small-break {
margin: 24px 0;
font-size: 24px;
line-height: 30px;
}
}
%h4 {
margin: 24px 0;
font-size: 40px;
line-height: 48px;
@include mid-break {
font-size: 33px;
line-height: 36px;
}
@include small-break {
margin: 20px 0;
font-size: 20px;
line-height: 24px;
}
}
%h5 {
margin: 20px 0;
font-size: 32px;
line-height: 42px;
@include mid-break {
font-size: 26px;
line-height: 32px;
}
@include small-break {
margin: 16px 0;
font-size: 18px;
line-height: 24px;
}
}
%h6 {
margin: 20px 0;
font-size: 24px;
line-height: 28px;
@include mid-break {
font-size: 20px;
line-height: 30px;
}
@include small-break {
margin: 16px 0;
font-size: 16px;
line-height: 22px;
}
}
/////////////////////////////
// TYPE STYLES
/////////////////////////////
%body {
font-size: 18px;
line-height: 32px;
@include mid-break {
font-size: 15px;
line-height: 24px;
}
@include small-break {
font-size: 13px;
line-height: 24px;
}
}
%large-body {
font-size: 25px;
line-height: 32px;
@include mid-break {
font-size: 22px;
line-height: 30px;
}
@include small-break {
font-size: 17px;
line-height: 24px;
}
}
%label {
font-size: 16px;
line-height: 24px;
letter-spacing: 3px;
text-transform: uppercase;
@include mid-break {
font-size: 13px;
letter-spacing: 2.75px;
}
@include small-break {
font-size: 12px;
line-height: 18px;
letter-spacing: 2.625px;
}
}
module.exports = {
breakpoints: {
s: 768,
m: 1024,
l: 1679,
},
}
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
const { withPayload } = require('@payloadcms/next-payload')
const path = require('path')
/** @type {import('next').NextConfig} */
const nextConfig = withPayload(
{
reactStrictMode: true,
rewrites: [{ source: '/admin/(.*)', destination: '/admin/index.html' }],
images: {
domains: [
'localhost',
'nextjs-vercel.payloadcms.com',
process.env.NEXT_PUBLIC_APP_URL ? process.env.NEXT_PUBLIC_APP_URL : '',
`${process.env.NEXT_PUBLIC_S3_ENDPOINT}`.replace('https://', ''),
],
},
},
{
configPath: path.resolve(__dirname, './payload/payload.config.ts'),
}
)
module.exports = nextConfig
{
"scripts": {
"dev": "next dev",
"start": "next start",
"install:payload": "next-payload install",
"build:next": "next build",
"build": "yarn build:next",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=payload/payload.config.ts payload generate:types",
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=payload/payload.config.ts payload generate:graphQLSchema"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.245.0",
"@aws-sdk/lib-storage": "^3.276.0",
"@faceless-ui/css-grid": "^1.2.0",
"@faceless-ui/modal": "^2.0.1",
"@payloadcms/next-payload": "0.0.27",
"@payloadcms/plugin-cloud-storage": "^1.0.14",
"@payloadcms/plugin-seo": "^1.0.10",
"@swc/wasm": "^1.3.35",
"@vercel/edge": "^0.1.2",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"next": "latest",
"payload": "1.9.2",
"payload-admin-bar": "^1.0.5",
"pino-pretty": "^9.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"sass": "^1.58.2",
"sass-loader": "^13.2.0"
},
"devDependencies": {
"@swc/core": "^1.3.35",
"@types/express": "^4.17.9",
"@types/node": "^18.11.18",
"@types/react": "^18.0.28",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
},
"private": true
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/[id]'
export default handler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/access/[id]'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/first-register'
export default handler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/forgot-password'
export default handler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]'
export default handler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/init'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/login'
export default handler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/logout'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/[collection]/me'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import meHandler from '@payloadcms/next-payload/dist/handlers/[collection]/me'
export default meHandler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/access'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/globals/[global]/access'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/globals/[global]'
export default handler
export const config = {
api: {
bodyParser: false,
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/graphql-playground'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import handler from '@payloadcms/next-payload/dist/handlers/graphql'
export default handler
export const config = {
api: {
externalResolver: true,
},
}
import type { NextApiRequest, NextApiResponse } from 'next'
const regenerate = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.query.secret !== process.env.NEXT_PRIVATE_REGENERATION_SECRET) {
console.error('Error regenerating: Invalid Token.')
return res
.status(401)
.json({ message: 'Error regenerating: Invalid token' })
}
if (typeof req.query.path === 'string') {
try {
const url = new URL(req.query.path, process.env.NEXT_PUBLIC_APP_URL)
const { pathname: pathToRegenerate } = url
await res.revalidate(pathToRegenerate)
return res.json({ regenerated: true })
} catch (err) {
console.error('Error regenerating: Cannot parse url.')
return res.status(500).send('Error regenerating: Cannot parse url.')
}
}
return res.status(400).send('No path to regenerate')
}
export default regenerate
/* tslint:disable */
/**
* This file was automatically generated by Payload CMS.
* 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: {
pages: Page
users: User
media: Media
}
globals: {
'main-menu': MainMenu
}
}
export interface Page {
id: string
title: string
hero: {
type: 'highImpact' | 'mediumImpact' | 'lowImpact'
richText: {
[k: string]: unknown
}[]
links: {
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
appearance?: 'default' | 'primary' | 'secondary'
}
id?: string
}[]
media: string | Media
}
layout: (
| {
ctaBackgroundColor?: 'white' | 'black'
richText: {
[k: string]: unknown
}[]
links: {
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
appearance?: 'primary' | 'secondary'
}
id?: string
}[]
id?: string
blockName?: string
blockType: 'cta'
}
| {
contentBackgroundColor?: 'white' | 'black'
layout?:
| 'oneColumn'
| 'twoThirdsOneThird'
| 'halfAndHalf'
| 'threeColumns'
columnOne: {
richText: {
[k: string]: unknown
}[]
enableLink?: boolean
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
appearance?: 'default' | 'primary' | 'secondary'
}
}
columnTwo: {
richText: {
[k: string]: unknown
}[]
enableLink?: boolean
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
appearance?: 'default' | 'primary' | 'secondary'
}
}
columnThree: {
richText: {
[k: string]: unknown
}[]
enableLink?: boolean
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
appearance?: 'default' | 'primary' | 'secondary'
}
}
id?: string
blockName?: string
blockType: 'content'
}
| {
mediaBlockBackgroundColor?: 'white' | 'black'
position?: 'default' | 'fullscreen'
media: string | Media
caption?: {
[k: string]: unknown
}[]
id?: string
blockName?: string
blockType: 'mediaBlock'
}
)[]
slug?: string
createdAt: string
updatedAt: string
}
export interface Media {
id: string
alt: string
url?: string
filename?: string
mimeType?: string
filesize?: number
width?: number
height?: number
createdAt: string
updatedAt: string
}
export interface User {
id: string
email?: string
resetPasswordToken?: string
resetPasswordExpiration?: string
loginAttempts?: number
lockUntil?: string
createdAt: string
updatedAt: string
password?: string
}
export interface MainMenu {
id: string
navItems: {
link: {
type?: 'reference' | 'custom'
newTab?: boolean
reference: {
value: string | Page
relationTo: 'pages'
}
url: string
label: string
}
id?: string
}[]
}
import { Access } from 'payload/config'
export const publishedOnly: Access = ({ req: { user } }) => {
if (Boolean(user)) return true
return {
_status: {
equals: 'published',
},
}
}
import { Block } from 'payload/types'
import { backgroundColor } from '../../fields/backgroundColor'
import linkGroup from '../../fields/linkGroup'
import richText from '../../fields/richText'
export const CallToAction: Block = {
slug: 'cta',
labels: {
singular: 'Call to Action',
plural: 'Calls to Action',
},
fields: [
backgroundColor({ overrides: { name: 'ctaBackgroundColor' } }),
richText(),
linkGroup({
appearances: ['primary', 'secondary'],
overrides: {
maxRows: 2,
},
}),
],
}
import { Block, Field } from 'payload/types'
import { backgroundColor } from '../../fields/backgroundColor'
import link from '../../fields/link'
import richText from '../../fields/richText'
const columnFields: Field[] = [
richText(),
{
name: 'enableLink',
type: 'checkbox',
},
link({
overrides: {
admin: {
condition: (_, { enableLink }) => Boolean(enableLink),
},
},
}),
]
export const Content: Block = {
slug: 'content',
fields: [
{
type: 'row',
fields: [
backgroundColor({ overrides: { name: 'contentBackgroundColor' } }),
{
name: 'layout',
type: 'select',
defaultValue: 'oneColumn',
options: [
{
label: 'One Column',
value: 'oneColumn',
},
{
label: 'Two Thirds + One Third',
value: 'twoThirdsOneThird',
},
{
label: 'Half + Half',
value: 'halfAndHalf',
},
{
label: 'Three Columns',
value: 'threeColumns',
},
],
},
],
},
{
name: 'columnOne',
type: 'group',
fields: columnFields,
},
{
name: 'columnTwo',
type: 'group',
fields: columnFields,
admin: {
condition: (_, { layout }) =>
['twoThirdsOneThird', 'halfAndHalf', 'threeColumns'].includes(layout),
},
},
{
name: 'columnThree',
type: 'group',
fields: columnFields,
admin: {
condition: (_, { layout }) => layout === 'threeColumns',
},
},
],
}
import { Block } from 'payload/types'
import { backgroundColor } from '../../fields/backgroundColor'
export const MediaBlock: Block = {
slug: 'mediaBlock',
fields: [
{
type: 'row',
fields: [
backgroundColor({ overrides: { name: 'mediaBlockBackgroundColor' } }),
{
name: 'position',
type: 'select',
defaultValue: 'default',
options: [
{
label: 'Default',
value: 'default',
},
{
label: 'Fullscreen',
value: 'fullscreen',
},
],
},
],
},
{
name: 'media',
type: 'upload',
relationTo: 'media',
required: true,
},
{
name: 'caption',
type: 'richText',
admin: {
elements: ['link'],
},
},
],
}
import { CollectionConfig } from 'payload/types'
import path from 'path'
export const Media: CollectionConfig = {
slug: 'media',
upload: {
staticDir: path.resolve(__dirname, '../../media'),
},
access: {
read: () => true,
},
fields: [
{
name: 'alt',
type: 'text',
required: true,
},
],
}
import { CollectionConfig } from 'payload/types'
import { publishedOnly } from '../access/publishedOnly'
import { CallToAction } from '../blocks/CallToAction'
import { Content } from '../blocks/Content'
import { MediaBlock } from '../blocks/Media'
import { hero } from '../fields/hero'
import { slugField } from '../fields/slug'
import { regenerateStaticPage } from '../utilities/regenerateStaticPage'
export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
useAsTitle: 'title',
defaultColumns: ['title', 'slug', 'updatedAt'],
preview: (doc, { locale }) => {
if (doc?.slug) {
return `/${doc.slug}${locale ? `?locale=${locale}` : ''}`
}
return ''
},
},
access: {
read: publishedOnly,
},
hooks: {
afterChange: [regenerateStaticPage],
},
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
type: 'tabs',
tabs: [
{
label: 'Hero',
fields: [hero],
},
{
label: 'Content',
fields: [
{
name: 'layout',
type: 'blocks',
required: true,
blocks: [CallToAction, Content, MediaBlock],
},
],
},
],
},
slugField(),
],
}
import { CollectionConfig } from 'payload/types'
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
fields: [
// Don't need any user fields here
],
}
import { Field, SelectField } from 'payload/types'
import deepMerge from '../utilities/deepMerge'
type Args = {
overrides?: Partial<SelectField>
}
export const backgroundColor = ({ overrides = {} }: Args): Field =>
deepMerge(
{
name: 'backgroundColor',
type: 'select',
defaultValue: 'white',
options: [
{
label: 'White',
value: 'white',
},
{
label: 'Black',
value: 'black',
},
],
},
overrides
)
import { Field } from 'payload/types'
import linkGroup from './linkGroup'
import richText from './richText'
import label from './richText/label'
import largeBody from './richText/largeBody'
export const hero: Field = {
name: 'hero',
label: false,
type: 'group',
fields: [
{
type: 'select',
name: 'type',
label: 'Type',
required: true,
defaultValue: 'lowImpact',
options: [
{
label: 'High Impact',
value: 'highImpact',
},
{
label: 'Medium Impact',
value: 'mediumImpact',
},
{
label: 'Low Impact',
value: 'lowImpact',
},
],
},
richText({
admin: {
elements: ['h1', largeBody, label, 'link'],
leaves: [],
},
}),
linkGroup({
overrides: {
maxRows: 2,
},
}),
{
name: 'media',
type: 'upload',
relationTo: 'media',
required: true,
admin: {
condition: (_, { type } = {}) =>
['highImpact', 'mediumImpact'].includes(type),
},
},
],
}
import { Field } from 'payload/types'
import deepMerge from '../utilities/deepMerge'
export const appearanceOptions = {
primary: {
label: 'Primary Button',
value: 'primary',
},
secondary: {
label: 'Secondary Button',
value: 'secondary',
},
default: {
label: 'Default',
value: 'default',
},
}
export type LinkAppearances = 'primary' | 'secondary' | 'default'
type LinkType = (options?: {
appearances?: LinkAppearances[] | false
disableLabel?: boolean
overrides?: Record<string, unknown>
}) => Field
const link: LinkType = ({
appearances,
disableLabel = false,
overrides = {},
} = {}) => {
let linkResult: Field = {
name: 'link',
type: 'group',
admin: {
hideGutter: true,
},
fields: [
{
type: 'row',
fields: [
{
name: 'type',
type: 'radio',
options: [
{
label: 'Internal link',
value: 'reference',
},
{
label: 'Custom URL',
value: 'custom',
},
],
defaultValue: 'reference',
admin: {
layout: 'horizontal',
width: '50%',
},
},
{
name: 'newTab',
label: 'Open in new tab',
type: 'checkbox',
admin: {
width: '50%',
style: {
alignSelf: 'flex-end',
},
},
},
],
},
],
}
let linkTypes: Field[] = [
{
name: 'reference',
label: 'Document to link to',
type: 'relationship',
relationTo: ['pages'],
required: true,
maxDepth: 1,
admin: {
condition: (_, siblingData) => siblingData?.type === 'reference',
},
},
{
name: 'url',
label: 'Custom URL',
type: 'text',
required: true,
admin: {
condition: (_, siblingData) => siblingData?.type === 'custom',
},
},
]
if (!disableLabel && linkTypes[0]?.admin && linkTypes[1]?.admin) {
linkTypes[0].admin.width = '50%'
linkTypes[1].admin.width = '50%'
linkResult.fields.push({
type: 'row',
fields: [
...linkTypes,
{
name: 'label',
label: 'Label',
type: 'text',
required: true,
admin: {
width: '50%',
},
},
],
})
} else {
linkResult.fields = [...linkResult.fields, ...linkTypes]
}
if (appearances !== false) {
let appearanceOptionsToUse = [
appearanceOptions.default,
appearanceOptions.primary,
appearanceOptions.secondary,
]
if (appearances) {
appearanceOptionsToUse = appearances.map(
(appearance) => appearanceOptions[appearance]
)
}
linkResult.fields.push({
name: 'appearance',
type: 'select',
defaultValue: 'default',
options: appearanceOptionsToUse,
admin: {
description: 'Choose how the link should be rendered.',
},
})
}
return deepMerge(linkResult, overrides)
}
export default link
import { Field } from 'payload/types'
import { ArrayField } from 'payload/dist/fields/config/types'
import deepMerge from '../utilities/deepMerge'
import link, { LinkAppearances } from './link'
type LinkGroupType = (options?: {
overrides?: Partial<ArrayField>
appearances?: LinkAppearances[] | false
}) => Field
const linkGroup: LinkGroupType = ({ overrides = {}, appearances } = {}) => {
const generatedLinkGroup: Field = {
name: 'links',
type: 'array',
fields: [
link({
appearances,
}),
],
}
return deepMerge(generatedLinkGroup, overrides)
}
export default linkGroup
import { RichTextElement } from 'payload/dist/fields/config/types'
import label from './label'
import largeBody from './largeBody'
const elements: RichTextElement[] = [
'blockquote',
'h2',
'h3',
'h4',
'h5',
'h6',
'link',
largeBody,
label,
]
export default elements
import {
RichTextElement,
RichTextField,
RichTextLeaf,
} from 'payload/dist/fields/config/types'
import deepMerge from '../../utilities/deepMerge'
import elements from './elements'
import leaves from './leaves'
type RichText = (
overrides?: Partial<RichTextField>,
additions?: {
elements?: RichTextElement[]
leaves?: RichTextLeaf[]
}
) => RichTextField
const richText: RichText = (
overrides,
additions = {
elements: [],
leaves: [],
}
) =>
deepMerge<RichTextField, Partial<RichTextField>>(
{
name: 'richText',
type: 'richText',
required: true,
admin: {
elements: [...elements, ...(additions.elements || [])],
leaves: [...leaves, ...(additions.leaves || [])],
},
},
overrides || {}
)
export default richText
'use client'
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line no-use-before-define
import React from 'react'
import { ElementButton } from 'payload/components/rich-text'
import Icon from '../Icon'
const baseClass = 'rich-text-label-button'
const ToolbarButton: React.FC<{ path: string }> = () => (
<ElementButton className={baseClass} format="label">
<Icon />
</ElementButton>
)
export default ToolbarButton
@import '~payload/scss';
.rich-text-label {
text-transform: uppercase;
font-family: 'Roboto Mono', monospace;
letter-spacing: 2px;
font-size: base(0.5);
margin: 0 0 base(1);
}
import React from 'react'
import './index.scss'
const baseClass = 'rich-text-label'
const LabelElement: React.FC<{
attributes: any
element: any
children: React.ReactNode
}> = ({ attributes, children }) => (
<div {...attributes}>
<span className={baseClass}>{children}</span>
</div>
)
export default LabelElement
/* eslint-disable no-use-before-define */
// eslint-disable-next-line import/no-extraneous-dependencies
import React from 'react'
const Icon = () => (
<svg
width="25"
height="25"
viewBox="0 0 25 25"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8.08884 15.2753L8.79758 17.7598H10.916L7.28663 6.41986H5.46413L1.75684 17.7598H3.88308L4.59962 15.2753H8.08884ZM5.10586 13.5385L6.36759 9.20812L7.59816 13.5385H5.10586Z"
fill="currentColor"
/>
<path
d="M21.1778 15.2753L21.8865 17.7598H24.005L20.3756 6.41986H18.5531L14.8458 17.7598H16.972L17.6886 15.2753H21.1778ZM18.1948 13.5385L19.4565 9.20812L20.6871 13.5385H18.1948Z"
fill="currentColor"
/>
</svg>
)
export default Icon
import { RichTextCustomElement } from 'payload/types'
import Button from './Button'
import Element from './Element'
import withLabel from './plugin'
export default {
name: 'label',
Button,
Element,
plugins: [withLabel],
} as RichTextCustomElement
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment