Skip to content

Commit 7d13fcf

Browse files
committed
feat: enhance TooltipIcon component with additional props and improved styling
Signed-off-by: Amit Amrutiya <amitamrutiya2210@gmail.com>
1 parent bfc74c3 commit 7d13fcf

1 file changed

Lines changed: 37 additions & 19 deletions

File tree

src/custom/TooltipIcon.tsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
1-
import { SxProps } from '@mui/material/styles';
1+
import { IconButton } from '@mui/material';
22
import React from 'react';
3-
import { IconButton } from '../base/IconButton';
3+
import { useTheme } from '../theme';
44
import { CustomTooltip } from './CustomTooltip';
5+
import { IconWrapper } from './ResponsiveDataTable';
56

67
interface TooltipIconProps {
78
title: string;
89
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
9-
icon: React.ReactNode;
10+
icon?: React.ReactNode;
1011
arrow?: boolean;
1112
style?: React.CSSProperties;
13+
iconType?: string;
14+
id?: string;
15+
placement?: 'bottom' | 'top' | 'left' | 'right';
16+
disabled?: boolean;
17+
children?: React.ReactNode;
1218
}
1319

1420
export function TooltipIcon({
21+
children,
1522
title,
1623
onClick,
1724
icon,
1825
style,
19-
arrow = false
26+
arrow = false,
27+
disabled = false,
28+
iconType,
29+
id,
30+
placement
2031
}: TooltipIconProps): JSX.Element {
32+
const theme = useTheme();
33+
2134
return (
22-
<CustomTooltip title={title} arrow={arrow}>
23-
<IconButton
24-
onClick={onClick}
25-
sx={{
26-
'&:hover': {
27-
'& svg': {
28-
fill: '#00d3a9'
35+
<CustomTooltip title={title} arrow={arrow} placement={placement} id={id}>
36+
<IconWrapper disabled={disabled}>
37+
<IconButton
38+
disabled={disabled}
39+
onClick={onClick}
40+
sx={{
41+
'&:hover': {
42+
'& svg': {
43+
fill:
44+
iconType === 'delete'
45+
? theme.palette.error.main
46+
: theme.palette.primary.brand?.default
47+
}
2948
},
30-
borderRadius: '4px'
31-
},
32-
...(style as SxProps)
33-
}}
34-
disableRipple
35-
>
36-
{icon}
37-
</IconButton>
49+
...style
50+
}}
51+
disableRipple
52+
>
53+
{icon || children}
54+
</IconButton>
55+
</IconWrapper>
3856
</CustomTooltip>
3957
);
4058
}

0 commit comments

Comments
 (0)