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

View file

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

View file

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

View file

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

View file

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

View file

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