index.js 792 B

123456789101112131415161718192021222324252627
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { Dropdown, Button, Icon, Menu } from 'antd';
  4. const DropOption = ({ onMenuClick, menuOptions = [], buttonStyle, dropdownProps }) => {
  5. const menu = menuOptions.map(item => <Menu.Item key={item.key}>{item.name}</Menu.Item>);
  6. return (
  7. <Dropdown
  8. overlay={<Menu onClick={onMenuClick}>{menu}</Menu>}
  9. {...dropdownProps}
  10. >
  11. <Button style={{ border: 'none', ...buttonStyle }}>
  12. <Icon style={{ marginRight: 2 }} type="bars" />
  13. <Icon type="down" />
  14. </Button>
  15. </Dropdown>
  16. );
  17. };
  18. DropOption.propTypes = {
  19. onMenuClick: PropTypes.func,
  20. menuOptions: PropTypes.array.isRequired,
  21. buttonStyle: PropTypes.object,
  22. dropdownProps: PropTypes.object,
  23. };
  24. export default DropOption;