Skip to content

Commit

Permalink
Merge branch 'main' into feat/civicsignal_webtools_media_data
Browse files Browse the repository at this point in the history
  • Loading branch information
m453h authored Oct 25, 2024
2 parents 1ed6712 + a1e011c commit ee84370
Show file tree
Hide file tree
Showing 99 changed files with 3,283 additions and 958 deletions.
1 change: 0 additions & 1 deletion apps/climatemappedafrica/eslint.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = {
resolve: {
alias: {
"@/climatemappedafrica": path.resolve(__dirname, "src/"),
content: path.resolve(__dirname, "content/"),
},
extensions: [".js"],
},
Expand Down
2 changes: 2 additions & 0 deletions apps/climatemappedafrica/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module.exports = {
"<rootDir>/../../packages/commons-ui-core/src/$1",
"^@/commons-ui/next/(.*)$":
"<rootDir>/../../packages/commons-ui-next/src/$1",
"^@/commons-ui/payload/(.*)$":
"<rootDir>/../../packages/commons-ui-payload/src/$1",
},
transformIgnorePatterns: ["<rootDir>/node_modules/(?!camelcase-keys)"],
};
1 change: 1 addition & 0 deletions apps/climatemappedafrica/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@/climatemappedafrica/*": ["./src/*"],
"@/commons-ui/core/*": ["../../packages/commons-ui-core/src/*"],
"@/commons-ui/next/*": ["../../packages/commons-ui-next/src/*"],
"@/commons-ui/payload/*": ["../../packages/commons-ui-payload/src/*"],
"@/hurumap/core/*": ["../../packages/hurumap-core/src/*"],
"@/hurumap/next/*": ["../../packages/hurumap-next/src/*"]
}
Expand Down
1 change: 1 addition & 0 deletions apps/climatemappedafrica/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
transpilePackages: [
"@commons-ui/core",
"@commons-ui/next",
"@commons-ui/payload",
"@hurumap/core",
"@hurumap/next",
],
Expand Down
3 changes: 2 additions & 1 deletion apps/climatemappedafrica/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"@emotion/styled": "catalog:",
"@hurumap/core": "workspace:*",
"@hurumap/next": "workspace:*",
"@mui/lab": "catalog:mui-styles",
"@mui/material": "catalog:mui-styles",
"@mui/styles": "catalog:mui-styles",
"@mui/utils": "catalog:mui-styles",
"@mui/x-tree-view": "catalog:",
"@next/env": "catalog:",
"@payloadcms/bundler-webpack": "catalog:",
"@payloadcms/db-mongodb": "catalog:",
Expand Down Expand Up @@ -78,6 +78,7 @@
"react-vega": "catalog:",
"sharp": "catalog:",
"simplebar-react": "catalog:",
"slate": "catalog:",
"swr": "catalog:",
"vega": "catalog:",
"vega-embed": "catalog:",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions apps/climatemappedafrica/src/components/Card/Card.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Link } from "@commons-ui/next";
import { Card as MuiCard } from "@mui/material";
import clsx from "clsx";
import PropTypes from "prop-types";
import React from "react";

Expand Down Expand Up @@ -28,6 +27,7 @@ function Card({
title,
titleProps,
variant,
sx,
...props
}) {
const squareMedia = mediaProps?.square;
Expand All @@ -43,7 +43,29 @@ function Card({
};

return (
<MuiCard elevation={0} square className={clsx(classes.root, className)}>
<MuiCard
elevation={0}
square
sx={(theme) => ({
backgroundColor: "inherit",
boxShadow: "none",
borderRadius: 0,
padding: {
xs: squareMedia ? `0 ${theme.typography.pxToRem(36)}` : 0,
md: 0,
},
minWidth: {
xs: theme.typography.pxToRem(350),
md: "unset",
},
width: {
xs: "100%",
md: theme.typography.pxToRem(squareMedia ? 278 : 296),
lg: theme.typography.pxToRem(squareMedia ? 278 : 376),
},
...sx,
})}
>
<CardActionArea
{...actionAreaProps}
classes={{
Expand Down
2 changes: 1 addition & 1 deletion apps/climatemappedafrica/src/components/Card/Card.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`<Card /> renders unchanged 1`] = `
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiCard-root makeStyles-root-1 makeStyles-root-11 css-1rw30ef-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiCard-root css-s2nibj-MuiPaper-root-MuiCard-root"
/>
</div>
`;
24 changes: 17 additions & 7 deletions apps/climatemappedafrica/src/components/Card/Content.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RichTypography } from "@commons-ui/core";
import { RichText } from "@commons-ui/payload";
import { CardContent } from "@mui/material";
import makeStyles from "@mui/styles/makeStyles";
import clsx from "clsx";
Expand Down Expand Up @@ -44,13 +45,22 @@ function Content({
<RichTypography variant="h5" {...titleProps} className={classes.title}>
{title}
</RichTypography>
<RichTypography
variant="subtitle2"
{...descriptionProps}
className={classes.description}
>
{description}
</RichTypography>
{/* Support for rich text while keeping backwards compatibility */}
{Array.isArray(description) ? (
<RichText
{...descriptionProps}
className={classes.description}
elements={description}
/>
) : (
<RichTypography
variant="subtitle2"
{...descriptionProps}
className={classes.description}
>
{description}
</RichTypography>
)}
</CardContent>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import { Box, ClickAwayListener, Grid, Slide } from "@mui/material";
import PropTypes from "prop-types";
import React, { useState } from "react";

import Icon from "./Icon";
import IndicatorPanel from "./IndicatorPanel";

import bg from "@/climatemappedafrica/assets/images/Mask Group 8.png";
import Image from "@/climatemappedafrica/components/Image";
import RichHeader from "@/climatemappedafrica/components/RichHeader";

function DataIndicators({ indicators, title }) {
const [checked, setChecked] = useState(false);
const [currentItemIndex, setCurrentItemIndex] = useState(null);

if (!indicators?.length) {
return null;
}
const handleIconClick = (index) => {
setCurrentItemIndex(index);
setChecked(true);
};
const resetItemClick = () => {
setChecked(false);
setCurrentItemIndex(null);
};
const currentItem = indicators[currentItemIndex];
const panelProps = {
in: checked,
mountOnEnter: true,
unmountOnExit: true,
component: Slide,
direction: "left",
timeout: 300,
sx: ({ palette, typography }) => ({
position: "absolute",
right: 0,
top: { lg: 0, xs: typography.pxToRem(124) },
backgroundColor: palette.primary.main,
display: "flex",
justifyContent: "flex-start",
alignItems: "flex-start",
flexDirection: "column",
color: palette.text.secondary,
margin: { xs: "auto 0" },
width: { lg: typography.pxToRem(480), xs: typography.pxToRem(390) },
height: {
xs: typography.pxToRem(528),
lg: typography.pxToRem(600),
},
padding: {
xs: typography.pxToRem(15),
md: `${typography.pxToRem(50)} ${typography.pxToRem(36)}`,
lg: `${typography.pxToRem(76)} ${typography.pxToRem(84)}`,
},
}),
};

return (
<Box
sx={({ typography }) => ({
backgroundColor: "#F0F0F0",
height: { xs: typography.pxToRem(672), lg: typography.pxToRem(600) },
position: "relative",
})}
>
<Box
sx={{
position: "absolute",
width: "100%",
height: "100%",
}}
>
<Image objectFit="cover" src={bg} layout="fill" />
</Box>
<Box
sx={{
display: "flex",
overflow: "hidden",
position: { lg: "relative" },
}}
>
<Box
sx={({ typography }) => ({
width: "100%",
height: {
xs: typography.pxToRem(672),
lg: typography.pxToRem(600),
},
transition: "width 0.3s ease-out",
...(checked && {
width: { md: "calc(100% - 355px)", lg: "calc(100% - 480px)" },
}),
})}
>
<RichHeader
TitleProps={{
sx: {
width: "100%",
textAlign: "center",
padding: `40px 0`,
},
}}
>
{title}
</RichHeader>
<ClickAwayListener onClickAway={resetItemClick}>
<Grid container alignItems="center" justifyContent="center">
{indicators.map((item, index) => (
<Grid
item
key={item.title}
sx={({ typography }) => ({
marginBottom: typography.pxToRem(16),
justifyContent: "center",
transition: "margin-right 0.3s ease-out",
display: { xs: "flex", lg: "initial" },
width: { xs: "100%", lg: "auto" },
mr: { lg: 7.5 },
"&:last-of-type": {
marginRight: 0,
},

...(checked && {
mr: { lg: 2.5 },
"&:last-of-type": {
marginRight: 0,
},
}),
})}
>
<Icon
handleIconClick={() => handleIconClick(index)}
item={item}
index={index}
currentItemIndex={currentItemIndex}
handleClickAway={resetItemClick}
/>
</Grid>
))}
</Grid>
</ClickAwayListener>
</Box>
<IndicatorPanel
{...panelProps}
onClick={resetItemClick}
currentItem={currentItem}
/>
</Box>
</Box>
);
}

DataIndicators.propTypes = {
title: PropTypes.arrayOf(PropTypes.shape({})),
indicators: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string,
description: PropTypes.arrayOf(PropTypes.shape({})),
}),
),
};

export default DataIndicators;
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<DataIndicators /> renders unchanged 1`] = `
<div>
<div
class="MuiBox-root css-8h5fdo"
>
<div
class="MuiBox-root css-b4kcmh"
>
<img
data-nimg="fill"
decoding="async"
loading="lazy"
sizes="100vw"
src="/_next/image?url=%2Furl&w=3840&q=75"
srcset="/_next/image?url=%2Furl&w=640&q=75 640w, /_next/image?url=%2Furl&w=750&q=75 750w, /_next/image?url=%2Furl&w=828&q=75 828w, /_next/image?url=%2Furl&w=1080&q=75 1080w, /_next/image?url=%2Furl&w=1200&q=75 1200w, /_next/image?url=%2Furl&w=1920&q=75 1920w, /_next/image?url=%2Furl&w=2048&q=75 2048w, /_next/image?url=%2Furl&w=3840&q=75 3840w"
style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; right: 0px; bottom: 0px; object-fit: cover; color: transparent;"
/>
</div>
<div
class="MuiBox-root css-18h5v7w"
>
<div
class="MuiBox-root css-5raypf"
>
<header
class="MuiBox-root css-0"
>
<div
class="MuiBox-root css-1lz18kf"
>
Indicators
</div>
</header>
<div
class="MuiGrid-root MuiGrid-container css-go2vvz-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-18bgkre-MuiGrid-root"
>
<button
class="MuiButtonBase-root css-72d9li-MuiButtonBase-root"
tabindex="0"
type="button"
>
<div
class="MuiBox-root css-g5rc5c"
>
<img
data-nimg="fill"
decoding="async"
src=""
style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px; right: 0px; bottom: 0px; color: transparent;"
/>
</div>
<p
class="MuiTypography-root MuiTypography-body1 css-1eogcpa-MuiTypography-root"
>
Overview
</p>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
`;
Loading

0 comments on commit ee84370

Please sign in to comment.