fixed ImgIcon not quite centering things properly

This commit is contained in:
Carter 2025-03-18 13:09:31 -06:00
parent 3e1e65ad88
commit 4f80c36c8c
2 changed files with 21 additions and 14 deletions

View file

@ -1,17 +1,21 @@
import { Icon } from "@mui/material"; import { Icon } from "@mui/material";
import { makeStyles } from "@mui/styles"; import { makeStyles } from "@mui/styles";
// import Image from "material-ui-image"; import { Img as Image } from "react-image";
import { Img as Image } from 'react-image';
const useStyles = makeStyles(() => ({ const useStyles = makeStyles(() => ({
icon: { icon: {
textAlign: "center", display: "flex", // Ensure flexbox for centering
justifyContent: "center", // Center horizontally
alignItems: "center", // Center vertically
margin: "1px", margin: "1px",
overflow: "hidden", // Prevent image overflow
}, },
img: { img: {
height: "100%", maxHeight: "100%", // Fit within container height
width: "auto !important" maxWidth: "100%", // Fit within container width
} width: "auto", // Maintain aspect ratio
height: "auto", // Maintain aspect ratio
},
})); }));
interface Props { interface Props {
@ -29,7 +33,10 @@ export function ImgIcon(props: Props) {
if (!src) return null; if (!src) return null;
return ( return (
<Icon className={classes.icon} style={{height: iconHeight, width: iconWidth}}> <Icon
className={classes.icon}
style={{ height: iconHeight, width: iconWidth }}
>
<Image <Image
alt={alt} alt={alt}
className={classes.img} className={classes.img}

View file

@ -24,12 +24,12 @@ import { Link, useLocation } from "react-router-dom";
import BinsIcon from "products/Bindapt/BinsIcon"; import BinsIcon from "products/Bindapt/BinsIcon";
import { useGlobalState } from "providers"; import { useGlobalState } from "providers";
import { import {
hasTutorialPlaylist, // hasTutorialPlaylist,
IsAdaptiveAgriculture, // IsAdaptiveAgriculture,
IsAdCon, // IsAdCon,
isBXT, // isBXT,
IsMiVent, IsMiVent,
IsOmniAir // IsOmniAir
} from "services/whiteLabel"; } from "services/whiteLabel";
import MiningIcon from "products/ventilation/MiningIcon"; import MiningIcon from "products/ventilation/MiningIcon";
import { useAuth0 } from "@auth0/auth0-react"; import { useAuth0 } from "@auth0/auth0-react";
@ -235,7 +235,7 @@ export default function SideNavigator(props: Props) {
</Toolbar> </Toolbar>
<Divider /> <Divider />
{/* {isAuthenticated || isOffline() ? authenticatedSideMenu() : unauthenticatedSideMenu()} */} {/* {isAuthenticated || isOffline() ? authenticatedSideMenu() : unauthenticatedSideMenu()} */}
{isAuthenticated && authenticatedSideMenu()} {isAuthenticated && authenticatedSideMenu()}
</SwipeableDrawer> </SwipeableDrawer>
); );
} }