/
FavoriteIconCell.tsx
53 lines (50 loc) · 1.69 KB
/
FavoriteIconCell.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { VFC } from 'react';
import { Box, IconButton, styled } from '@mui/material';
import {
Star as StarIcon,
StarBorder as StarBorderIcon,
} from '@mui/icons-material';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { TooltipResolver } from 'component/common/TooltipResolver/TooltipResolver';
interface IFavoriteIconCellProps {
value?: boolean;
onClick?: () => void;
}
const InactiveIconButton = styled(IconButton)(({ theme }) => ({
color: theme.palette.primary.main,
opacity: 0,
}));
export const FavoriteIconCell: VFC<IFavoriteIconCellProps> = ({
value = false,
onClick,
}) => (
<Box sx={{ pl: 1.25, display: 'inline-flex' }}>
<ConditionallyRender
condition={value}
show={
<TooltipResolver title={'Remove from favorites'}>
<IconButton
onClick={onClick}
color="primary"
size="small"
sx={{ padding: 1.25 }}
>
<StarIcon fontSize="small" />
</IconButton>
</TooltipResolver>
}
elseShow={
<TooltipResolver title={'Add to favorites'}>
<InactiveIconButton
className="show-row-hover"
onClick={onClick}
size="small"
sx={{ padding: 1.25 }}
>
<StarBorderIcon fontSize="small" />
</InactiveIconButton>
</TooltipResolver>
}
/>
</Box>
);