-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropOption.js
More file actions
34 lines (30 loc) · 1.01 KB
/
Copy pathDropOption.js
File metadata and controls
34 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react'
import PropTypes from 'prop-types'
import { Dropdown, Button, Icon, Menu } from 'antd'
const Divider = () => {
return <div style={{ borderTop: '1px solid #f4f4f4' }} />
}
const DropOption = ({ onMenuClick, menuOptions = [], buttonStyle, dropdownProps }) => {
const menu = menuOptions.map((item) => {
if (item.isDivider) {
return <Divider key={item.key}/>
}
return <Menu.Item key={item.key} disabled={!!item.disabled}>{item.name}</Menu.Item>
})
return (<Dropdown
overlay={<Menu onClick={onMenuClick}>{menu}</Menu>}
{...dropdownProps}
>
<Button style={{ border: 'none', ...buttonStyle }}>
<Icon style={{ marginRight: 2 }} type="bars" />
<Icon type="down" />
</Button>
</Dropdown>)
}
DropOption.propTypes = {
onMenuClick: PropTypes.func,
menuOptions: PropTypes.array.isRequired,
buttonStyle: PropTypes.object,
dropdownProps: PropTypes.object,
}
export default DropOption