1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import Menu from '@material-ui/core/Menu';
7 import IconButton from '@material-ui/core/IconButton';
8 import { PopoverOrigin } from '@material-ui/core/Popover';
9 import IconBase, { IconTypes } from '../icon/icon';
11 interface DropdownMenuProps {
14 // icon: React.ComponentType;
17 class DropdownMenu extends React.Component<DropdownMenuProps> {
23 transformOrigin: PopoverOrigin = {
29 const { icon, id, children } = this.props;
30 const { anchorEl } = this.state;
34 aria-owns={anchorEl ? id : undefined}
37 onClick={this.handleOpen}
40 <IconBase icon={icon} />
45 open={Boolean(anchorEl)}
46 onClose={this.handleClose}
47 onClick={this.handleClose}
48 anchorOrigin={this.transformOrigin}
49 transformOrigin={this.transformOrigin}
58 this.setState({ anchorEl: undefined });
61 handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
62 this.setState({ anchorEl: event.currentTarget });
67 export default DropdownMenu;