Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
6911 stevensc 1
import React, { useState } from 'react'
2
import IconButton from '@mui/material/IconButton'
3
import MoreVertIcon from '@mui/icons-material/MoreVert'
4
 
5
const Options = ({ options }) => {
6
  const [isShowMenu, setIsShowMenu] = useState(false)
7
 
8
  const toggleOptions = () => {
9
    setIsShowMenu(!isShowMenu)
10
  }
11
 
12
  return (
13
    <div className="header-options">
14
      <IconButton onClick={toggleOptions}>
15
        <MoreVertIcon />
16
        <Options.Menu
17
          options={options}
18
          onClose={toggleOptions}
19
          show={isShowMenu}
20
        />
21
      </IconButton>
22
    </div>
23
  )
24
}
25
 
26
const Menu = ({ options, show, onClose }) => {
27
  return (
28
    <ul className={`feed-options ${show ? 'active' : ''}`}>
29
      {options.map((option, index) => (
30
        <li key={index}>
31
          <button
32
            className="btn option-btn"
33
            onClick={() => {
34
              option.action()
35
              onClose()
36
            }}
37
          >
38
            {option.label}
39
          </button>
40
        </li>
41
      ))}
42
    </ul>
43
  )
44
}
45
 
46
Options.Menu = Menu
47
 
48
export default Options