-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.js
More file actions
46 lines (41 loc) · 1.09 KB
/
Menu.js
File metadata and controls
46 lines (41 loc) · 1.09 KB
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
import React from 'react';
import { Menu, IconButton } from '@material-ui/core';
import { MoreVert as MenuIcon } from '@material-ui/icons';
export default ({ icon: IconComponent = MenuIcon, children, size }) => {
const [anchorEl, setAnchorEl] = React.useState(null);
const handleMenuClick = (event) => {
event.stopPropagation();
setAnchorEl(event.currentTarget);
};
const handleMenuClose = (event) => {
event.stopPropagation();
setAnchorEl(null);
};
return (
<>
<IconButton onClick={handleMenuClick} disableRipple size={size}>
<IconComponent />
</IconButton>
<Menu
onClick={handleMenuClose}
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleMenuClose}
elevation={1}
PaperProps={{ square: true }}
getContentAnchorEl={null}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
>
{children}
</Menu>
</>
);
};