2023-06-23 13:42:35 +00:00
|
|
|
import {Button, SxProps, Theme, useTheme} from "@mui/material";
|
2022-12-26 10:00:03 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
Icon: React.ElementType;
|
|
|
|
isActive?: boolean;
|
|
|
|
onClick: () => void;
|
2023-06-23 13:42:35 +00:00
|
|
|
sx?: SxProps<Theme>;
|
2022-12-26 10:00:03 +00:00
|
|
|
}
|
|
|
|
|
2023-06-23 13:42:35 +00:00
|
|
|
export default function SelectableIconButton({ Icon, isActive = false, onClick, sx }: Props) {
|
2022-12-26 10:00:03 +00:00
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
return (
|
2023-05-10 17:35:30 +00:00
|
|
|
<Button
|
2022-12-26 10:00:03 +00:00
|
|
|
onClick={onClick}
|
|
|
|
variant="outlined"
|
|
|
|
startIcon={<Icon color={isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main} />}
|
|
|
|
sx={{
|
|
|
|
backgroundColor: isActive ? undefined : theme.palette.background.default,
|
|
|
|
borderColor: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
|
|
|
color: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
|
|
|
p: "7px",
|
|
|
|
width: "auto",
|
|
|
|
minWidth: 0,
|
|
|
|
"& .MuiButton-startIcon": {
|
|
|
|
mr: 0,
|
|
|
|
ml: 0,
|
|
|
|
},
|
|
|
|
"&:hover": {
|
|
|
|
borderColor: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
|
|
|
},
|
2023-06-23 13:42:35 +00:00
|
|
|
...sx
|
2022-12-26 10:00:03 +00:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|