Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useStyles from HURUMap #1008

Merged
merged 28 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1871fff
Remove useStyles from navigation
kelvinkipruto Nov 25, 2024
ca7f89b
Remove useStyles from explore page
kelvinkipruto Nov 25, 2024
92112f6
Remove useStyles from categoryHeader
kelvinkipruto Nov 25, 2024
3a4eec5
Fix categoryHeader description
kelvinkipruto Nov 25, 2024
8303f36
Remove useStyles from Filters
kelvinkipruto Nov 25, 2024
d8847af
Remove useStyles from ChartFilters
kelvinkipruto Nov 25, 2024
a767c81
Remove useStyles partially from ChartFilters
kelvinkipruto Nov 25, 2024
4a20ee5
Remove useStyles partially from KeyMetrics
kelvinkipruto Nov 25, 2024
d0fb430
Remove useStyles from LocationHeader
kelvinkipruto Nov 25, 2024
7df809c
Remove useStyles from PanelItem
kelvinkipruto Nov 25, 2024
3ea4648
Remove useStyles from PinAndCompare
kelvinkipruto Nov 25, 2024
0046b68
Remove useStyles from SubcategoryHeader
kelvinkipruto Nov 25, 2024
8574274
Remove useStyles from TutorialStep
kelvinkipruto Nov 25, 2024
69faa7c
Remove useStyles from Mobile Navigation
kelvinkipruto Nov 26, 2024
f69ca3e
Revert unnecessary changes
kelvinkipruto Nov 27, 2024
d5af9d9
Remove useStyles from Tutorial Line
kelvinkipruto Nov 27, 2024
cc4e0e8
Use Styled ReactTour
kelvinkipruto Nov 27, 2024
ad3b094
Remove unused styles file
kelvinkipruto Nov 27, 2024
7f3914d
Fix mobile panel
kelvinkipruto Nov 27, 2024
da50fde
Remove useprops from select
kelvinkipruto Nov 27, 2024
e243471
Merge branch 'main' into ft/climatemapped-remove-usestyles-hurumap
kelvinkipruto Nov 28, 2024
8821285
Fix Select font size and color
kelvinkipruto Nov 29, 2024
f387125
Fix conditional header components
kelvinkipruto Nov 29, 2024
1cea12a
Improve Select
kelvinkipruto Nov 29, 2024
a37d881
Fix review feedback
kelvinkipruto Dec 3, 2024
5600686
Minor improvements
kelvinkipruto Dec 3, 2024
855de64
Fix Select dropdown styles
kelvinkipruto Dec 4, 2024
4b998de
Update Chartfilter
kelvinkipruto Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,31 +1,53 @@
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}>
<div>
<Typography
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved
{...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>
{description && (
<Typography
variant="body2"
sx={({ typography }) => ({
paddingBottom: typography.pxToRem(20),
"& p": {
margin: 0,
},
})}
>
{description}
</Typography>
)}
</div>
);
}
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 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 @@
isCompare,
...props
}) {
const classes = useStyles(props);
const chartRef = useRef();
const tooltipRef = useRef();
const [view, setView] = useState(null);
Expand Down Expand Up @@ -108,7 +93,7 @@

setView(newView.view);
} catch (error) {
console.error("Error rendering chart", error);

Check warning on line 96 in apps/climatemappedafrica/src/components/HURUmap/Chart/index.js

View workflow job for this annotation

GitHub Actions / Build and Test (20.16, ubuntu-latest)

Unexpected console statement
}
}
}
Expand All @@ -127,7 +112,7 @@
const viewProp = new vega.View(vega.parse(cSpec), { renderer: "none" });
setDownloadView(viewProp);
} catch (error) {
console.error("Error creating view", error);

Check warning on line 115 in apps/climatemappedafrica/src/components/HURUmap/Chart/index.js

View workflow job for this annotation

GitHub Actions / Build and Test (20.16, ubuntu-latest)

Unexpected console statement
}
}, [cSpec]);

Expand Down Expand Up @@ -228,7 +213,7 @@
},
{
name: "Twitter",
icon: TwitterIcon,
icon: XLogo,
props: { title, via: "Code4Africa", related: ["Code4Africa"] },
},
{
Expand Down Expand Up @@ -328,7 +313,16 @@
];

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 @@
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 @@
}
/>
)}
</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,97 @@ 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": {
height: theme.typography.pxToRem(310),
boxShadow: "none",
},
"& .MuiMenu-list": {
padding: `${theme.typography.pxToRem(10)} 0 ${theme.typography.pxToRem(
10,
)} ${theme.typography.pxToRem(15)} !important`,
},
kelvinkipruto marked this conversation as resolved.
Show resolved Hide resolved
}}
/>
</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": {
height: theme.typography.pxToRem(310),
boxShadow: "none",
},
"& .MuiMenu-list": {
padding: `${theme.typography.pxToRem(10)} 0 ${theme.typography.pxToRem(
10,
)} ${theme.typography.pxToRem(15)} !important`,
},
}}
/>
</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 +182,7 @@ function ChartFilter({
</Grid>
)}
</Grid>
</div>
</Box>
);
}

Expand Down
Loading
Loading