123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import { makeStyles } from '@material-ui/core'
- import React, { useState } from 'react';
- import { styled } from '@mui/material/styles';
- import Avatar from '@mui/material/Avatar';
- import Menu from '@mui/material/Menu';
- import MenuItem from '@mui/material/MenuItem';
- import PersonIcon from '@mui/icons-material/Person';
- import GroupIcon from '@mui/icons-material/Group';
- import GroupsIcon from '@mui/icons-material/Groups';
- import ModeEditOutlineOutlinedIcon from '@mui/icons-material/ModeEditOutlineOutlined';
- import CloseIcon from '@mui/icons-material/Close';
- const useStyles = makeStyles({
- container: {
- position: 'absolute',
- maxWidth: '100%',
- top: 895,
- left: 390,
- zIndex: 10,
- visibility: 'visible',
- cursor:'pointer'
- },
- })
- const StyledMenu = styled((props:any) => (
- <Menu
- elevation={0}
- anchorOrigin={{
- vertical: 'top',
- horizontal: 'right',
- }}
- transformOrigin={{
- vertical: 'bottom',
- horizontal: 'right',
- }}
- {...props}
- />
- ))(({ theme }:any) => ({
- '& .MuiPaper-root': {
- borderRadius: 10,
- marginTop: theme.spacing(-2),
- minWidth: 220,
- color:
- theme.palette.mode === 'light' ? 'rgb(55, 65, 81)' : theme.palette.grey[500],
- boxShadow:
- 'rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px',
- '& .MuiMenu-list': {
- padding: '14px 14px',
- },
- '& .MuiMenuItem-root': {
- marginBottom: theme.spacing(1),
- '& .MuiSvgIcon-root': {
- fontSize: 21,
- color: theme.palette.text.secondary,
- marginRight: theme.spacing(4),
- }
- },
- },
- }));
- const SmallMenuBar = () => {
- const classes = useStyles()
- const [anchorEl, setAnchorEl] = useState<any>(null);
- const open = Boolean(anchorEl);
- const handleClick = (e: React.MouseEvent<HTMLDivElement>):void => setAnchorEl(e.currentTarget)
- const handleClose = (i:number|null):void => {
- console.log('chosen one element from small menu by id',i)
- setAnchorEl(null)
- }
- return (
- <div className={classes.container}>
- <Avatar onClick={handleClick} sx={{
- bgcolor: 'rgb(41, 139, 231)',
- width: 56, height: 56 }}>
- {!anchorEl?<ModeEditOutlineOutlinedIcon />:<CloseIcon/>}
- </Avatar>
- <StyledMenu
- id="demo-positioned-menu"
- aria-labelledby="demo-positioned-button"
- anchorEl={anchorEl}
- open={open}
- onClose={handleClose}
- >
- <MenuItem onClick={() => handleClose(0)}>
- <GroupsIcon />
- New Channel
- </MenuItem>
- <MenuItem onClick={() => handleClose(1)}>
- <GroupIcon />
- New Group
- </MenuItem>
- <MenuItem onClick={() => handleClose(2)}>
- <PersonIcon />
- New Message
- </MenuItem>
- </StyledMenu>
- </div>
- );
- }
- export default SmallMenuBar
|