Skip to content

Commit

Permalink
Merge branch 'main' into ft/civicsignalblog-auth_forms
Browse files Browse the repository at this point in the history
  • Loading branch information
m453h authored Dec 10, 2024
2 parents 744f28c + 19afd75 commit 71e26a5
Show file tree
Hide file tree
Showing 27 changed files with 626 additions and 699 deletions.
1 change: 1 addition & 0 deletions apps/climatemappedafrica/src/assets/icons/x-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
import { RichTypography } from "@commons-ui/legacy";
import { Typography } from "@mui/material";
import { Box, Typography } from "@mui/material";
import PropTypes from "prop-types";
import React from "react";

import useStyles from "./useStyles";

import Image from "@/climatemappedafrica/components/Image";

function CategoryHeader({ title, description, icon, ...props }) {
const classes = useStyles();

if (!title) {
return null;
}
return (
<div className={classes.root}>
<Typography {...props} variant="h3" className={classes.title}>
<Box>
<Typography
{...props}
variant="h3"
sx={({ typography }) => ({
fontSize: typography.pxToRem(28),
display: "flex",
alignItems: "center",
scrollMarginTop: typography.pxToRem(110),
paddingTop: typography.pxToRem(40),
paddingBottom: typography.pxToRem(20),
})}
>
{icon && (
<div className={classes.icon}>
<Image src={icon} layout="fill" />
</div>
<Box
sx={({ typography }) => ({
position: "relative",
height: typography.pxToRem(32),
width: typography.pxToRem(32),
marginRight: typography.pxToRem(10),
backgroundImage: `url(${icon})`,
backgroundSize: "contain",
backgroundRepeat: "no-repeat",
})}
/>
)}
{title}
</Typography>
<RichTypography variant="body2" className={classes.description}>
{description}
</RichTypography>
</div>
{description && (
<Typography
variant="body2"
sx={({ typography }) => ({
paddingBottom: typography.pxToRem(20),
"& p": {
margin: 0,
},
})}
>
{description}
</Typography>
)}
</Box>
);
}

Expand Down

This file was deleted.

19 changes: 7 additions & 12 deletions apps/climatemappedafrica/src/components/HURUmap/Chart/Filters.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import { ButtonBase } from "@mui/material";
import makeStyles from "@mui/styles/makeStyles";
import { Box, ButtonBase } from "@mui/material";
import PropTypes from "prop-types";
import React, { useEffect, useState, useCallback } from "react";

import { idify } from "./utils";

import ChartFilter from "@/climatemappedafrica/components/HURUmap/ChartFilter";

const useStyles = makeStyles(({ typography }) => ({
root: {
paddingBottom: typography.pxToRem(18),
},
}));

function Filters({
filterGroups,
defaultFilters,
filterSelectProps,
setFilterSelectProps,
view,
...props
}) {
const classes = useStyles(props);
const [availableGroups, setAvailableGroups] = useState([]);

const handleFilterSelectProps = (v) => {
Expand Down Expand Up @@ -122,7 +113,11 @@ function Filters({
}

return (
<div className={classes.root}>
<Box
sx={({ typography }) => ({
paddingBottom: typography.pxToRem(18),
})}
>
{
// default filters cannot be deleted
// & their attributes cannot be changes, but values can
Expand All @@ -149,7 +144,7 @@ function Filters({
{availableGroups?.length > 0 && (
<ButtonBase onClick={addFilter}>Add new filter</ButtonBase>
)}
</div>
</Box>
);
}

Expand Down
41 changes: 20 additions & 21 deletions apps/climatemappedafrica/src/components/HURUmap/Chart/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { RichTypography } from "@commons-ui/legacy";
import { ChartTooltip, IndicatorTitle, Download, Share } from "@hurumap/core";
import { Source } from "@hurumap/next";
import { useMediaQuery, useTheme } from "@mui/material";
import makeStyles from "@mui/styles/makeStyles";
import { Box, useMediaQuery, useTheme } from "@mui/material";
import React, { useState, useRef, useCallback, useEffect } from "react";
import * as vega from "vega";
import embed from "vega-embed";
Expand All @@ -18,26 +17,13 @@ import FacebookIcon from "@/climatemappedafrica/assets/icons/Facebook.svg";
import LinkedInIcon from "@/climatemappedafrica/assets/icons/LinkedIn.svg";
import InfoIcon from "@/climatemappedafrica/assets/icons/plus.svg";
import ShareIcon from "@/climatemappedafrica/assets/icons/share.svg";
import TwitterIcon from "@/climatemappedafrica/assets/icons/Twitter.svg";
import WhatsAppIcon from "@/climatemappedafrica/assets/icons/WhatsApp.svg";
import XLogo from "@/climatemappedafrica/assets/icons/x-logo.svg";
import cfalogo from "@/climatemappedafrica/assets/logos/cfa.svg";
import projectlogo from "@/climatemappedafrica/assets/logos/projectLogo.svg";
import config, { hurumapArgs } from "@/climatemappedafrica/config";
import site from "@/climatemappedafrica/utils/site";

const useStyles = makeStyles(({ typography }) => ({
root: {
position: "relative",
width: "100%",
"&:last-of-type": {
marginBottom: typography.pxToRem(32),
},
},
chart: {
width: "100%",
},
}));

function Chart({
indicator,
indicatorTitle,
Expand All @@ -48,7 +34,6 @@ function Chart({
isCompare,
...props
}) {
const classes = useStyles(props);
const chartRef = useRef();
const tooltipRef = useRef();
const [view, setView] = useState(null);
Expand Down Expand Up @@ -228,7 +213,7 @@ function Chart({
},
{
name: "Twitter",
icon: TwitterIcon,
icon: XLogo,
props: { title, via: "Code4Africa", related: ["Code4Africa"] },
},
{
Expand Down Expand Up @@ -328,7 +313,16 @@ function Chart({
];

return (
<div className={classes.root} id={`chart-${id}-${geoCode}`}>
<Box
id={`chart-${id}-${geoCode}`}
sx={({ typography }) => ({
position: "relative",
width: "100%",
"&:last-of-type": {
marginBottom: typography.pxToRem(32),
},
})}
>
<IndicatorTitle
title={title}
description={description}
Expand Down Expand Up @@ -357,7 +351,12 @@ function Chart({
view={view}
/>
)}
<div ref={chartRef} className={classes.chart} />
<Box
ref={chartRef}
sx={{
width: "100%",
}}
/>
<RichTypography
variant="body2"
sx={(theme) => ({
Expand Down Expand Up @@ -393,7 +392,7 @@ function Chart({
}
/>
)}
</div>
</Box>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Grid, IconButton } from "@mui/material";
import { Box, Grid, IconButton, useTheme } from "@mui/material";
import PropTypes from "prop-types";
import React, { useEffect, useState } from "react";

import useStyles from "./useStyles";

import CloseIcon from "@/climatemappedafrica/assets/icons/x.svg";
import Select from "@/climatemappedafrica/components/Select";

Expand All @@ -17,10 +15,7 @@ function ChartFilter({
valueText = "Select a value:",
selectedAttribute: selectedAttributeProp,
selectedValue: selectedValueProp,
...props
}) {
const classes = useStyles(props);

const [selectedAttribute, setSelectedAttribute] = useState(
selectedAttributeProp,
);
Expand All @@ -29,6 +24,8 @@ function ChartFilter({
const [attributeOptions, setAttributeOptions] = useState([]);
const [valueOptions, setValueOptions] = useState([]);

const theme = useTheme();

useEffect(() => {
if (index === "default") {
setAttributeOptions([selectedAttribute]);
Expand Down Expand Up @@ -86,44 +83,91 @@ function ChartFilter({
}

return (
<div className={classes.root}>
<Box
sx={({ typography }) => ({
paddingBottom: typography.pxToRem(10),
})}
>
<Grid container alignItems="flex-end">
{attributeOptions?.length > 0 && (
<Grid item className={classes.grid}>
<Grid
sx={({ typography }) => ({
marginRight: { md: typography.pxToRem(10) },
})}
>
<Select
helperText={attributeText}
options={attributeOptions}
selected={selectedAttribute}
onChange={onAtrributeChange}
disabled={index === "default"}
classes={{
select: classes.select,
filled: classes.filled,
paper: classes.selectPaper,
SelectProps={{
width: theme.typography.pxToRem(205),
height: theme.typography.pxToRem(40),
paddingLeft: 0,
"& .MuiSelect-filled": {
padding: `${theme.typography.pxToRem(10)} 0 ${theme.typography.pxToRem(
10,
)} ${theme.typography.pxToRem(15)} !important`,
},
}}
MenuProps={{
"& .MuiMenu-paper": {
maxHeight: theme.typography.pxToRem(310),
boxShadow: "none",
borderRadius: 0,
marginTop: theme.typography.pxToRem(5),
},
}}
/>
</Grid>
)}
{valueOptions?.length > 0 && (
<Grid item className={classes.grid}>
<Grid
item
sx={({ typography }) => ({
marginRight: { md: typography.pxToRem(10) },
})}
>
<Select
helperText={valueText}
options={valueOptions}
selected={selectedValue}
label={selectedValue?.length ? "" : "Select a value"}
onChange={onValueChange}
classes={{
select: classes.select,
filled: classes.filled,
paper: classes.selectPaper,
SelectProps={{
width: theme.typography.pxToRem(205),
height: theme.typography.pxToRem(40),
paddingLeft: 0,
"& .MuiSelect-filled": {
padding: `${theme.typography.pxToRem(10)} 0 ${theme.typography.pxToRem(
10,
)} ${theme.typography.pxToRem(15)} !important`,
},
}}
MenuProps={{
"& .MuiMenu-paper": {
maxHeight: theme.typography.pxToRem(310),
boxShadow: "none",
borderRadius: 0,
marginTop: theme.typography.pxToRem(5),
},
}}
/>
</Grid>
)}
{index !== "default" && index !== 0 && (
<Grid item>
<IconButton
className={classes.icon}
sx={({ palette, typography }) => ({
padding: 0,
background: palette.background.paper,
"& :hover": {
background: palette.background.paper,
},
height: typography.pxToRem(36),
width: typography.pxToRem(36),
})}
onClick={removeFilter}
size="large"
>
Expand All @@ -132,7 +176,7 @@ function ChartFilter({
</Grid>
)}
</Grid>
</div>
</Box>
);
}

Expand Down
Loading

0 comments on commit 71e26a5

Please sign in to comment.