Skip to content

Commit

Permalink
Improve Select
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Nov 29, 2024
1 parent f387125 commit 1cea12a
Showing 1 changed file with 26 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import { Box, Grid, IconButton, useTheme } from "@mui/material";
import { Box, Grid, IconButton, styled } from "@mui/material";
import PropTypes from "prop-types";
import React, { useEffect, useState } from "react";

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

const StyledSelect = styled(Select)(({ theme }) => ({
SelectProps: {
width: {
width: {
xs: theme.typography.pxToRem(165),
lg: theme.typography.pxToRem(200),
},
height: theme.typography.pxToRem(40),
paddingLeft: 0,
"& .MuiSelect-filled": {
padding: `${theme.typography.pxToRem(10)} ${theme.typography.pxToRem(
40,
)} ${theme.typography.pxToRem(10)} ${theme.typography.pxToRem(20)} !important`,
},
},
},
MenuProps: {
"& .MuiMenu-paper": {
maxHeight: theme.typography.pxToRem(310),
},
},
}));

function ChartFilter({
groups,
onSelectValue,
Expand All @@ -16,8 +39,6 @@ function ChartFilter({
selectedAttribute: selectedAttributeProp,
selectedValue: selectedValueProp,
}) {
const theme = useTheme();

const [selectedAttribute, setSelectedAttribute] = useState(
selectedAttributeProp,
);
Expand Down Expand Up @@ -95,30 +116,12 @@ function ChartFilter({
marginRight: { md: typography.pxToRem(10) },
})}
>
<Select
<StyledSelect
helperText={attributeText}
options={attributeOptions}
selected={selectedAttribute}
onChange={onAtrributeChange}
disabled={index === "default"}
SelectProps={{
width: {
xs: theme.typography.pxToRem(165),
lg: theme.typography.pxToRem(200),
},
height: theme.typography.pxToRem(40),
paddingLeft: 0,
"& .MuiSelect-filled": {
padding: `${theme.typography.pxToRem(10)} ${theme.typography.pxToRem(
40,
)} ${theme.typography.pxToRem(10)} ${theme.typography.pxToRem(20)} !important`,
},
}}
MenuProps={{
"& .MuiMenu-paper": {
maxHeight: theme.typography.pxToRem(310),
},
}}
/>
</Grid>
)}
Expand All @@ -129,30 +132,12 @@ function ChartFilter({
marginRight: { md: typography.pxToRem(10) },
})}
>
<Select
<StyledSelect
helperText={valueText}
options={valueOptions}
selected={selectedValue}
label={selectedValue?.length ? "" : "Select a value"}
onChange={onValueChange}
SelectProps={{
width: {
xs: theme.typography.pxToRem(165),
lg: theme.typography.pxToRem(200),
},
height: theme.typography.pxToRem(40),
paddingLeft: 0,
"& .MuiSelect-filled": {
padding: `${theme.typography.pxToRem(10)} ${theme.typography.pxToRem(
40,
)} ${theme.typography.pxToRem(10)} ${theme.typography.pxToRem(20)} !important`,
},
}}
MenuProps={{
"& .MuiMenu-paper": {
maxHeight: theme.typography.pxToRem(310),
},
}}
/>
</Grid>
)}
Expand Down

0 comments on commit 1cea12a

Please sign in to comment.