added height and width the the ImgIcon common component in order to control the icon size so that icons that are not square dont get the bottom cut off

This commit is contained in:
csawatzky 2025-03-13 16:28:36 -06:00
parent 53a7c486ce
commit 17f4cbc242
8 changed files with 2218 additions and 17 deletions

2198
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@
"@mui/x-date-pickers": "^7.26.0", "@mui/x-date-pickers": "^7.26.0",
"@sentry/react": "^8.38.0", "@sentry/react": "^8.38.0",
"@turf/area": "^7.2.0", "@turf/area": "^7.2.0",
"@turf/turf": "^7.2.0",
"@types/classnames": "^2.3.0", "@types/classnames": "^2.3.0",
"axios": "^1.7.7", "axios": "^1.7.7",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",

View file

@ -53,7 +53,7 @@ export default function AddBinFab(props: Props) {
aria-label="Create Bin" aria-label="Create Bin"
className={classString} className={classString}
size={isMobile ? "medium" : "large"}> size={isMobile ? "medium" : "large"}>
<ImgIcon alt="Create Bin" src={AddBinIcon} /> <ImgIcon alt="Create Bin" src={AddBinIcon} iconHeight={"35px"} iconWidth={"35px"}/>
</Fab> </Fab>
); );
} }

View file

@ -85,6 +85,9 @@ export default function BinsList(props: Props) {
//const visibility = useContext(VisibilityContext); //const visibility = useContext(VisibilityContext);
return ( return (
<ScrollMenu <ScrollMenu
onUpdate={(visibility) => {
console.log(visibility.useIsVisible('last', false))
}}
LeftArrow={leftArrow} LeftArrow={leftArrow}
RightArrow={rightArrow}> RightArrow={rightArrow}>
{bins.map((b, i) => ( {bins.map((b, i) => (

View file

@ -6,7 +6,7 @@ import { Img as Image } from 'react-image';
const useStyles = makeStyles(() => ({ const useStyles = makeStyles(() => ({
icon: { icon: {
textAlign: "center", textAlign: "center",
margin: "1px" margin: "1px",
}, },
img: { img: {
height: "100%", height: "100%",
@ -18,16 +18,18 @@ interface Props {
src?: string; src?: string;
alt?: string; alt?: string;
style?: any; style?: any;
iconHeight?: number | string;
iconWidth?: number | string;
} }
export function ImgIcon(props: Props) { export function ImgIcon(props: Props) {
const { src, alt, style } = props; const { src, alt, style, iconHeight, iconWidth } = props;
const classes = useStyles(); const classes = useStyles();
if (!src) return null; if (!src) return null;
return ( return (
<Icon className={classes.icon}> <Icon className={classes.icon} style={{height: iconHeight, width: iconWidth}}>
<Image <Image
alt={alt} alt={alt}
className={classes.img} className={classes.img}

View file

@ -139,7 +139,7 @@ export default function SideNavigator(props: Props) {
classes={getClasses("/bin")} classes={getClasses("/bin")}
> >
<ListItemIcon> <ListItemIcon>
<BinsIcon /> <BinsIcon height={"26px"}/>
</ListItemIcon> </ListItemIcon>
{open && <ListItemText primary="Bins" />} {open && <ListItemText primary="Bins" />}
</ListItemButton> </ListItemButton>
@ -168,7 +168,7 @@ export default function SideNavigator(props: Props) {
classes={getClasses("/mine")} classes={getClasses("/mine")}
> >
<ListItemIcon> <ListItemIcon>
<MiningIcon /> <MiningIcon height={"26px"} width={"26px"} />
</ListItemIcon> </ListItemIcon>
{open && <ListItemText primary="Mines" />} {open && <ListItemText primary="Mines" />}
</ListItemButton> </ListItemButton>

View file

@ -8,12 +8,13 @@ import { useThemeType } from "../../hooks/useThemeType";
interface Props { interface Props {
singleBin?: boolean; singleBin?: boolean;
type?: "light" | "dark"; type?: "light" | "dark";
size?: number; width?: number | string;
height?: number | string;
} }
export default function BinsIcon(props: Props) { export default function BinsIcon(props: Props) {
const themeType = useThemeType(); const themeType = useThemeType();
const { type, singleBin, size } = props; const { type, singleBin, width, height } = props;
const lightIcon = () => { const lightIcon = () => {
return singleBin ? BinLightIcon : BinsLightIcon; return singleBin ? BinLightIcon : BinsLightIcon;
@ -31,9 +32,9 @@ export default function BinsIcon(props: Props) {
return themeType === "light" ? darkIcon() : lightIcon(); return themeType === "light" ? darkIcon() : lightIcon();
}; };
if (size) { // if (size) {
return <img width={size} height={size} alt="bins" src={src()} />; // return <img width={size} height={size} alt="bins" src={src()} />;
} // }
return <ImgIcon alt="bins" src={src()} />; return <ImgIcon alt="bins" src={src()} iconHeight={height} iconWidth={width}/>;
} }

View file

@ -6,11 +6,13 @@ import React from "react";
interface Props { interface Props {
type?: "light" | "dark"; type?: "light" | "dark";
height?: number | string
width?: number | string
} }
export default function VentilationIcon(props: Props) { export default function VentilationIcon(props: Props) {
const themeType = useThemeType(); const themeType = useThemeType();
const { type } = props; const { type, height, width } = props;
const src = () => { const src = () => {
if (type) { if (type) {
@ -20,5 +22,5 @@ export default function VentilationIcon(props: Props) {
return themeType === "light" ? MineDarkIcon : MineLightIcon; return themeType === "light" ? MineDarkIcon : MineLightIcon;
}; };
return <ImgIcon alt="mine" src={src()} />; return <ImgIcon alt="mine" src={src()} iconHeight={height} iconWidth={width}/>;
} }