-
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 #949 from CodeForAfrica/ft/climatemapped-visualisa…
…tion-guide ClimateMapped Data Visualisation Guide
- Loading branch information
Showing
8 changed files
with
186 additions
and
11 deletions.
There are no files selected for viewing
Binary file added
BIN
+324 KB
apps/climatemappedafrica/public/images/cms/blocks/data-visualisation-guide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
92 changes: 92 additions & 0 deletions
92
apps/climatemappedafrica/src/components/DataVisualisationGuide/index.js
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,92 @@ | ||
import { RichTypography } from "@commons-ui/core"; | ||
import { useMediaQuery, Box, Grid } from "@mui/material"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
|
||
import Card from "@/climatemappedafrica/components/Card"; | ||
import Carousel from "@/climatemappedafrica/components/Carousel"; | ||
import Section from "@/climatemappedafrica/components/Section"; | ||
|
||
function DataVisualisationGuide({ title, items }) { | ||
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up("lg")); | ||
|
||
if (!items?.length) { | ||
return null; | ||
} | ||
return ( | ||
<Box | ||
sx={(theme) => ({ | ||
padding: `${theme.typography.pxToRem(40)} 0`, | ||
})} | ||
> | ||
<Section> | ||
<RichTypography component="h4" variant="h4"> | ||
{title} | ||
</RichTypography> | ||
<Box | ||
sx={{ | ||
display: { | ||
xs: "none", | ||
md: "block", | ||
}, | ||
}} | ||
> | ||
<Carousel showDots={!isDesktop}> | ||
{items.map((item) => ( | ||
<Card | ||
key={item.id} | ||
{...item} | ||
sx={{ | ||
marginTop: "40px", | ||
"& .bold": { | ||
fontWeight: "bold", | ||
}, | ||
}} | ||
/> | ||
))} | ||
</Carousel> | ||
</Box> | ||
<Box | ||
sx={{ | ||
display: { | ||
xs: "block", | ||
md: "none", | ||
}, | ||
}} | ||
> | ||
<Grid | ||
container | ||
direction={{ xs: "column", md: "row" }} | ||
justifyContent={{ md: "space-between" }} | ||
> | ||
{items.map((item) => ( | ||
<Grid item xs={12} key={item.id}> | ||
<Card | ||
{...item} | ||
sx={(theme) => ({ | ||
marginTop: theme.typography.pxToRem(40), | ||
"& .bold": { | ||
fontWeight: "bold", | ||
}, | ||
})} | ||
/> | ||
</Grid> | ||
))} | ||
</Grid> | ||
</Box> | ||
</Section> | ||
</Box> | ||
); | ||
} | ||
|
||
DataVisualisationGuide.propTypes = { | ||
title: PropTypes.string, | ||
items: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
description: PropTypes.string || PropTypes.array, | ||
image: PropTypes.string, | ||
}), | ||
), | ||
}; | ||
|
||
export default DataVisualisationGuide; |
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
41 changes: 41 additions & 0 deletions
41
apps/climatemappedafrica/src/payload/blocks/DataVisualisationGuide.js
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,41 @@ | ||
import { slateEditor } from "@payloadcms/richtext-slate"; | ||
|
||
import image from "../fields/image"; | ||
|
||
const DataVisualisationGuide = { | ||
slug: "data-visualisation-guide", | ||
imageURL: "/images/cms/blocks/data-visualisation-guide.png", | ||
fields: [ | ||
{ | ||
name: "title", | ||
type: "text", | ||
required: true, | ||
localized: true, | ||
}, | ||
{ | ||
name: "items", | ||
type: "array", | ||
minRows: 1, | ||
fields: [ | ||
image({ | ||
overrides: { | ||
required: true, | ||
}, | ||
}), | ||
{ | ||
name: "description", | ||
type: "richText", | ||
required: true, | ||
editor: slateEditor({ | ||
admin: { | ||
elements: ["link"], | ||
leaves: ["bold", "code", "italic", "underline"], | ||
}, | ||
}), | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
export default DataVisualisationGuide; |
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