1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-19 17:52:45 +02:00
unleash.unleash/frontend/src/component/common/DropdownMenu/DropdownMenu.jsx
Fredrik Strand Oseberg 728477e238 Feat/feature routes (#327)
* fix: setup new routes

* fix: copy toggle

* fix: link to correct project

* fix: redirect oss to default

* fix: update tests

* fix: edit path

* fix: remove invalid property

* fix: add project to test data

* fix: update paths to use features

* fix: update test data

* fix: update snapshots

* fix: only show button to add toggle if you have access

* fix: change heading

* fix: use new route

* fix: archive view

* fix: update snapshots

* fix: sorting headers

* fix: list headers

* fix: only show span if revive is present

* fix: add border to list

* fix: update snapshots

* fix: remove console log
2021-08-25 13:37:22 +02:00

71 lines
1.6 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { Menu } from '@material-ui/core';
import { ArrowDropDown } from '@material-ui/icons';
import { DropdownButton } from '..';
import styles from '../common.module.scss';
const DropdownMenu = ({
renderOptions,
id,
title,
callback,
icon = <ArrowDropDown />,
label,
style,
startIcon,
...rest
}) => {
const [anchor, setAnchor] = React.useState(null);
const handleOpen = e => setAnchor(e.currentTarget);
const handleClose = e => {
if (callback && typeof callback === 'function') {
callback(e);
}
setAnchor(null);
};
return (
<>
<DropdownButton
id={id}
label={label}
title={title}
startIcon={startIcon}
onClick={handleOpen}
style={style}
aria-controls={id}
aria-haspopup="true"
icon={icon}
{...rest}
/>
<Menu
id={id}
className={styles.dropdownMenu}
onClick={handleClose}
anchorEl={anchor}
open={Boolean(anchor)}
>
{renderOptions()}
</Menu>
</>
);
};
DropdownMenu.propTypes = {
renderOptions: PropTypes.func,
id: PropTypes.string,
title: PropTypes.string,
callback: PropTypes.func,
icon: PropTypes.object,
label: PropTypes.string,
startIcon: PropTypes.object,
};
export default DropdownMenu;