diff options
author | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-26 02:49:13 +0300 |
---|---|---|
committer | ilyayudovin <ilyayudovin123@gmail.com> | 2020-06-26 02:49:13 +0300 |
commit | c5b771b87b92260e19f0c43ed83151c8e3d49f73 (patch) | |
tree | d0bb715e5e3c2e55a0b4356ac09e31c6811bc3be /src/pages/ProfilePage/MoreMenu.tsx | |
parent | 9852ed44fca2c71e6992e583d4cd3b874b6b18fa (diff) | |
download | which-ui-c5b771b87b92260e19f0c43ed83151c8e3d49f73.tar.gz |
feat: add more menu button to profile
Diffstat (limited to 'src/pages/ProfilePage/MoreMenu.tsx')
-rw-r--r-- | src/pages/ProfilePage/MoreMenu.tsx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/pages/ProfilePage/MoreMenu.tsx b/src/pages/ProfilePage/MoreMenu.tsx new file mode 100644 index 0000000..a4bc993 --- /dev/null +++ b/src/pages/ProfilePage/MoreMenu.tsx @@ -0,0 +1,66 @@ +import React from 'react'; +import IconButton from '@material-ui/core/IconButton'; +import Menu from '@material-ui/core/Menu'; +import MenuItem from '@material-ui/core/MenuItem'; +import MoreHorizIcon from '@material-ui/icons/MoreHoriz'; +import {makeStyles} from "@material-ui/core"; + +interface PropTypes { + logOut: () => void; +} + +const ITEM_HEIGHT = 48; + +const useStyles = makeStyles({ + moreMenu: { + position: 'absolute', + right: 10, + zIndex: 100 + } +}); + +const MoreMenu: React.FC<PropTypes> = ({ logOut }) => { + const classes = useStyles(); + const [anchorEl, setAnchorEl] = React.useState(null); + const open = Boolean(anchorEl); + + const handleClick = (event: any) => { + setAnchorEl(event.currentTarget); + }; + + const handleClose = () => { + setAnchorEl(null); + }; + + return ( + <div className={classes.moreMenu}> + <div> + <IconButton + aria-label="more" + aria-controls="long-menu" + aria-haspopup="true" + onClick={handleClick} + > + <MoreHorizIcon/> + </IconButton> + <Menu + id="long-menu" + anchorEl={anchorEl} + keepMounted + open={open} + onClose={handleClose} + PaperProps={{ + style: { + maxHeight: ITEM_HEIGHT * 4.5, + width: '20ch', + }, + }} + > + <MenuItem onClick={logOut}>Log out</MenuItem> + </Menu> + </div> + </div> + ); +}; + +export default MoreMenu; |