Skip to content

Commit 37933af

Browse files
committed
feat: add EditButton component with custom tooltip and styled icon
Signed-off-by: Amit Amrutiya <amitamrutiya2210@gmail.com>
1 parent 99e9cf8 commit 37933af

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { IconButton } from '@mui/material';
2+
import React from 'react';
3+
import { CustomTooltip } from '../CustomTooltip';
4+
import { L5EditIcon } from './styles';
5+
6+
interface EditButtonProps {
7+
onClick: (e: React.MouseEvent) => void;
8+
disabled?: boolean;
9+
title?: string;
10+
}
11+
12+
const EditButton: React.FC<EditButtonProps> = ({ onClick, disabled, title = 'Edit' }) => {
13+
return (
14+
<CustomTooltip title={title}>
15+
<div>
16+
<IconButton onClick={onClick} disabled={disabled} size="small" sx={{ ml: 1 }}>
17+
<L5EditIcon />
18+
</IconButton>
19+
</div>
20+
</CustomTooltip>
21+
);
22+
};
23+
24+
export default EditButton;

src/custom/Workspaces/styles.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
1-
import { styled } from '../../theme';
1+
import EditIcon from '@mui/icons-material/Edit';
2+
import { buttonDisabled, styled } from '../../theme';
3+
import { HOVER_DELETE } from '../../theme/colors/colors';
24

35
export const ModalActionDiv = styled('div')({
46
display: 'flex',
57
gap: '1rem'
68
});
9+
10+
interface ExtendedEditIconProps {
11+
disabled?: boolean;
12+
bulk?: boolean;
13+
style?: React.CSSProperties;
14+
}
15+
16+
export const L5EditIcon = styled(EditIcon)<ExtendedEditIconProps>(
17+
({ disabled, bulk, style, theme }) => ({
18+
color: disabled ? theme.palette.icon.disabled : theme.palette.text.secondary,
19+
cursor: disabled ? 'not-allowed' : 'pointer',
20+
width: bulk ? '32' : '28.8',
21+
height: bulk ? '32' : '28.8',
22+
'&:hover': {
23+
color: disabled ? buttonDisabled : HOVER_DELETE,
24+
'& svg': {
25+
color: disabled ? buttonDisabled : HOVER_DELETE
26+
}
27+
},
28+
'& svg': {
29+
color: theme.palette.error.main,
30+
cursor: disabled ? 'not-allowed' : 'pointer'
31+
},
32+
...style
33+
})
34+
);

0 commit comments

Comments
 (0)