Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3541 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3505 stevensc 1
import React, { useContext } from 'react';
2
import { IconButton, MenuItem as MuiMenuItem, Menu as MuiMenu, styled } from '@mui/material';
3
import { MoreVert } from '@mui/icons-material';
4
import { MenuContext } from '.';
5
 
6
const OptionsButton = styled(IconButton)(({ theme }) => ({
7
  position: 'absolute',
8
  top: theme.spacing(1),
9
  right: theme.spacing(1),
10
  zIndex: 1
11
}));
12
 
13
export function MenuContent({ icon, children }) {
14
  const { anchorEl, open, openMenu, closeMenu } = useContext(MenuContext);
15
 
16
  return (
17
    <>
18
      <OptionsButton onClick={openMenu}>{icon ? icon : <MoreVert />}</OptionsButton>
19
      <MuiMenu
20
        anchorEl={anchorEl}
21
        open={open}
22
        onClose={closeMenu}
23
        anchorOrigin={{
24
          vertical: 'bottom',
25
          horizontal: 'left'
26
        }}
27
        transformOrigin={{
28
          vertical: 'top',
29
          horizontal: 'right'
30
        }}
31
      >
32
        {children}
33
      </MuiMenu>
34
    </>
35
  );
36
}
37
 
38
export function MenuItem({ onClick, children }) {
39
  const { handleClick } = useContext(MenuContext);
40
 
41
  return <MuiMenuItem onClick={(event) => handleClick(onClick, event)}>{children}</MuiMenuItem>;
42
}