refactor: extract tooltip icon as component

This commit is contained in:
dongchengjie
2024-06-26 08:10:18 +08:00
parent 753395965a
commit c89ccf7185
8 changed files with 66 additions and 112 deletions

View File

@@ -0,0 +1,24 @@
import {
Tooltip,
IconButton,
IconButtonProps,
SvgIconProps,
} from "@mui/material";
import { InfoRounded } from "@mui/icons-material";
interface Props extends IconButtonProps {
title?: string;
icon?: React.ElementType<SvgIconProps>;
}
export const TooltipIcon: React.FC<Props> = (props: Props) => {
const { title = "", icon: Icon = InfoRounded } = props;
return (
<Tooltip title={title} placement="top">
<IconButton color="inherit" size="small" {...props}>
<Icon fontSize="inherit" style={{ cursor: "pointer", opacity: 0.75 }} />
</IconButton>
</Tooltip>
);
};