-
-
Notifications
You must be signed in to change notification settings - Fork 656
/
FavoriteIconCell.tsx
59 lines (54 loc) · 1.49 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
54
55
56
57
58
59
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';
const StyledCell = styled(Box)(({ theme }) => ({
paddingLeft: theme.spacing(1.25),
}));
const StyledIconButton = styled(IconButton)(({ theme }) => ({
color: theme.palette.primary.main,
padding: theme.spacing(1.25),
}));
const StyledIconButtonInactive = styled(StyledIconButton)({
opacity: 0,
'&:hover': {
opacity: 1,
},
'&:focus': {
opacity: 1,
},
'&:active': {
opacity: 1,
},
});
interface IFavoriteIconCellProps {
value?: boolean;
onClick?: () => void;
}
export const FavoriteIconCell: VFC<IFavoriteIconCellProps> = ({
value,
onClick,
}) => (
<StyledCell>
<ConditionallyRender
condition={Boolean(value)}
show={
<StyledIconButton onClick={onClick} size='small'>
<StarIcon fontSize='small' />
</StyledIconButton>
}
elseShow={
<StyledIconButtonInactive
className='show-row-hover'
onClick={onClick}
size='small'
>
<StarBorderIcon fontSize='small' />
</StyledIconButtonInactive>
}
/>
</StyledCell>
);