Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2123 | Rev 2856 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2123 Rev 2853
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from 'react'
2
import { Menu, MenuItem, IconButton } from '@mui/material'
2
import { Menu, MenuItem, IconButton } from '@mui/material'
3
import { MoreVert } from '@mui/icons-material'
3
import { MoreVert } from '@mui/icons-material'
Línea -... Línea 4...
-
 
4
 
-
 
5
import colors from '@styles/colors'
4
 
6
 
5
const Options = ({ options = [], right = '.5rem', top = '.5rem' }) => {
7
const Options = ({ children }) => {
6
  const [anchorEl, setAnchorEl] = useState(null)
8
  const [anchorEl, setAnchorEl] = useState(null)
Línea 7... Línea -...
7
  const open = Boolean(anchorEl)
-
 
8
 
9
  const open = Boolean(anchorEl)
9
  const handleClick = (event) => {
-
 
10
    setAnchorEl(event.currentTarget)
10
 
11
  }
11
  const handleClick = (event) => setAnchorEl(event.currentTarget)
12
 
-
 
13
  const handleClose = () => {
-
 
14
    setAnchorEl(null)
-
 
15
  }
-
 
16
 
-
 
17
  if (!options.length) {
-
 
Línea 18... Línea 12...
18
    return null
12
 
19
  }
13
  const handleClose = () => setAnchorEl(null)
20
 
14
 
21
  return (
-
 
22
    <>
-
 
23
      <IconButton
-
 
24
        sx={{
-
 
25
          position: 'absolute',
-
 
26
          right,
-
 
27
          top,
-
 
28
          transform: top ? 'none' : 'translateY(-50%)'
-
 
29
        }}
15
  return (
30
        right={right}
16
    <>
31
        top={top}
-
 
32
        onClick={handleClick}
17
      <IconButton
-
 
18
        onClick={handleClick}
33
        aria-controls={open ? 'account-menu' : ''}
19
        aria-controls={open ? 'account-menu' : ''}
34
        aria-haspopup='true'
20
        aria-expanded={open ? 'true' : ''}
35
        aria-expanded={open ? 'true' : ''}
21
        aria-haspopup='true'
36
      >
22
      >
37
        <MoreVert />
-
 
38
      </IconButton>
23
        <MoreVert />
-
 
24
      </IconButton>
39
      <Menu
25
      <Menu
40
        anchorEl={anchorEl}
26
        id='account-menu'
41
        id='account-menu'
27
        anchorEl={anchorEl}
42
        open={open}
28
        open={open}
43
        onClose={handleClose}
29
        onClose={handleClose}
-
 
30
        onClick={handleClose}
-
 
31
        transformOrigin={{ horizontal: 'right', vertical: 'top' }}
-
 
32
        anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
-
 
33
        sx={{
44
        onClick={handleClose}
34
          boxShadow: 'none',
45
        transformOrigin={{ horizontal: 'right', vertical: 'top' }}
-
 
46
        anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
-
 
47
      >
-
 
48
        {options.map((option, index) => (
-
 
49
          <MenuItem
-
 
50
            key={index}
-
 
51
            onClick={() => {
35
          border: `1px solid ${colors.border.primary}`
52
              option.action()
-
 
53
              handleClose()
-
 
54
            }}
-
 
55
          >
-
 
56
            {option.label}
36
        }}
57
          </MenuItem>
37
      >
58
        ))}
38
        {children}
59
      </Menu>
39
      </Menu>
Línea -... Línea 40...
-
 
40
    </>
-
 
41
  )
-
 
42
}
-
 
43
 
-
 
44
function OptionItem({ children, ...props }) {
-
 
45
  return <MenuItem {...props}>{children}</MenuItem>
60
    </>
46
}