-
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 #948 from CodeForAfrica/feat/climatemappedafrica_a…
…bout_page @/climatemappedafrica About Page
- Loading branch information
Showing
50 changed files
with
5,711 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["eslint-config-commons-ui/next"], | ||
settings: { | ||
"import/resolver": { | ||
webpack: { | ||
config: "./eslint.webpack.config.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,26 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.svg$/i, | ||
type: "asset", | ||
resourceQuery: /url/, // *.svg?url | ||
}, | ||
{ | ||
test: /\.svg$/i, | ||
issuer: /\.[jt]sx?$/, | ||
resourceQuery: { not: [/url/] }, // exclude react component if *.svg?url | ||
use: ["@svgr/webpack"], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
alias: { | ||
"@/climatemappedafrica": path.resolve(__dirname, "src/"), | ||
content: path.resolve(__dirname, "content/"), | ||
}, | ||
extensions: [".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
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
100 changes: 100 additions & 0 deletions
100
apps/climatemappedafrica/src/components/AboutTeam/AboutTeam.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,100 @@ | ||
import { Box, Grid, Typography, useMediaQuery } from "@mui/material"; | ||
import { useTheme } from "@mui/material/styles"; | ||
import { chunk, uniqueId } from "lodash"; | ||
import PropTypes from "prop-types"; | ||
import React, { useRef } from "react"; | ||
|
||
import Card from "@/climatemappedafrica/components/Card"; | ||
import Carousel from "@/climatemappedafrica/components/Carousel"; | ||
import Section from "@/climatemappedafrica/components/Section"; | ||
|
||
// NOTE(kilemensi) useStyles uses import/definition order to determine how | ||
// classes are ordered. | ||
// see: https://material-ui.com/styles/advanced/#makestyles-withstyles-styled | ||
// eslint-disable-next-line import/order | ||
import useStyles from "./useStyles"; | ||
|
||
const responsive = { | ||
desktop: { | ||
items: 1, | ||
}, | ||
tablet: { | ||
items: 1, | ||
}, | ||
}; | ||
|
||
function AboutTeam({ title, members: membersProp, ...props }) { | ||
const membersCount = membersProp?.length ?? 0; | ||
const classes = useStyles({ ...props, membersCount }); | ||
const theme = useTheme(); | ||
const isMdUp = useMediaQuery(theme.breakpoints.up("md")); | ||
const ref = useRef(); | ||
|
||
if (!membersProp?.length) { | ||
return null; | ||
} | ||
const chunkSize = isMdUp ? 4 : 2; | ||
const members = chunk(membersProp, chunkSize); | ||
const scrollToTeam = () => { | ||
if (ref.current && !isMdUp) { | ||
ref.current.scrollIntoView({ behavior: "smooth" }); | ||
} | ||
}; | ||
return ( | ||
<Box | ||
sx={{ | ||
bgcolor: "background.paper", | ||
py: { xs: 5, md: 10 }, | ||
px: 0, | ||
scrollMarginTop: 40, | ||
scrollBehavior: "auto", | ||
}} | ||
ref={ref} | ||
> | ||
<Section> | ||
{title && ( | ||
<Typography | ||
variant="h4" | ||
className={classes.title} | ||
sx={{ | ||
textAlign: "center", | ||
paddingBottom: { xs: 5, md: 10 }, | ||
}} | ||
> | ||
{title} | ||
</Typography> | ||
)} | ||
<Carousel | ||
afterChange={scrollToTeam} | ||
responsive={responsive} | ||
classes={{ dotList: classes.dotList }} | ||
> | ||
{members.map((membersChunks) => ( | ||
<Grid | ||
container | ||
justifyContent="space-between" | ||
key={uniqueId("team-chunk-")} | ||
> | ||
{membersChunks.map((member) => ( | ||
<Grid item key={title}> | ||
<Card {...member} mediaProps={{ square: true }} /> | ||
</Grid> | ||
))} | ||
</Grid> | ||
))} | ||
</Carousel> | ||
</Section> | ||
</Box> | ||
); | ||
} | ||
|
||
AboutTeam.propTypes = { | ||
title: PropTypes.string, | ||
members: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
title: PropTypes.string, | ||
}), | ||
), | ||
}; | ||
|
||
export default AboutTeam; |
28 changes: 28 additions & 0 deletions
28
apps/climatemappedafrica/src/components/AboutTeam/AboutTeam.snap.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,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<AboutTeam /> renders unchanged 1`] = ` | ||
<div> | ||
<div | ||
class="MuiBox-root css-1termwk" | ||
> | ||
<div | ||
class="makeStyles-root-7 makeStyles-root-5 makeStyles-root-3 makeStyles-fixed-4 MuiBox-root css-0" | ||
> | ||
<h4 | ||
class="MuiTypography-root MuiTypography-h4 css-kemoay-MuiTypography-root" | ||
> | ||
About Team | ||
</h4> | ||
<div | ||
class="react-multi-carousel-list makeStyles-root-8" | ||
dir="ltr" | ||
> | ||
<ul | ||
class="react-multi-carousel-track " | ||
style="transition: none; overflow: unset; transform: translate3d(0px,0,0);" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
28 changes: 28 additions & 0 deletions
28
apps/climatemappedafrica/src/components/AboutTeam/AboutTeam.test.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,28 @@ | ||
import { createRender } from "@commons-ui/testing-library"; | ||
import React from "react"; | ||
|
||
import AboutTeam from "."; | ||
|
||
import theme from "@/climatemappedafrica/theme"; | ||
|
||
// eslint-disable-next-line testing-library/render-result-naming-convention | ||
const render = createRender({ theme }); | ||
|
||
const defaultProps = { | ||
title: "About Team", | ||
members: [ | ||
{ | ||
alt: "Name", | ||
description: "Name, Country", | ||
image: "/media/member.jpg", | ||
title: "Name", | ||
}, | ||
], | ||
}; | ||
|
||
describe("<AboutTeam />", () => { | ||
it("renders unchanged", () => { | ||
const { container } = render(<AboutTeam {...defaultProps} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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 AboutTeam from "./AboutTeam"; | ||
|
||
export default AboutTeam; |
19 changes: 19 additions & 0 deletions
19
apps/climatemappedafrica/src/components/AboutTeam/useStyles.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,19 @@ | ||
import makeStyles from "@mui/styles/makeStyles"; | ||
|
||
const useStyles = makeStyles(({ breakpoints, palette }) => ({ | ||
dotList: ({ membersCount }) => ({ | ||
display: membersCount > 2 ? "flex" : "none", | ||
"& button": { | ||
borderColor: "#000", | ||
background: palette.background.paper, | ||
}, | ||
"& .react-multi-carousel-dot--active button": { | ||
borderColor: "#000", | ||
}, | ||
[breakpoints.up("md")]: { | ||
display: membersCount > 4 ? "flex" : "none", | ||
}, | ||
}), | ||
})); | ||
|
||
export default useStyles; |
52 changes: 52 additions & 0 deletions
52
apps/climatemappedafrica/src/components/Card/ActionArea.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,52 @@ | ||
import { Link } from "@commons-ui/next"; | ||
import { CardActionArea } from "@mui/material"; | ||
import makeStyles from "@mui/styles/makeStyles"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
root: {}, | ||
focusHighlight: { | ||
background: "transparent", | ||
}, | ||
focusVisible: {}, | ||
})); | ||
|
||
function ActionArea({ href, children, onClick, ...props }) { | ||
const classes = useStyles(props); | ||
|
||
if (!(href || onClick)) { | ||
return children; | ||
} | ||
return ( | ||
<CardActionArea | ||
component={href ? Link : undefined} | ||
color="textPrimary" | ||
underline="none" | ||
{...props} | ||
href={href} | ||
onClick={onClick} | ||
classes={{ | ||
root: classes.root, | ||
focusHighlight: classes.focusHighlight, | ||
focusVisible: classes.focusVisible, | ||
}} | ||
> | ||
{children} | ||
</CardActionArea> | ||
); | ||
} | ||
|
||
ActionArea.propTypes = { | ||
children: PropTypes.node, | ||
href: PropTypes.string, | ||
onClick: PropTypes.func, | ||
}; | ||
|
||
ActionArea.defaultProps = { | ||
children: undefined, | ||
href: undefined, | ||
onClick: undefined, | ||
}; | ||
|
||
export default ActionArea; |
Oops, something went wrong.