ant-design/components/dropdown/dropdown-button.tsx

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2016-07-07 20:25:03 +08:00
import * as React from 'react';
2015-12-02 15:18:15 +08:00
import Button from '../button';
import Icon from '../icon';
import Dropdown from './dropdown';
const ButtonGroup = Button.Group;
import classNames from 'classnames';
2016-06-22 13:18:43 +08:00
import splitObject from '../_util/splitObject';
export default class DropdownButton extends React.Component {
static defaultProps = {
align: {
points: ['tr', 'br'],
overlay: {
adjustX: 1,
adjustY: 1,
},
offset: [0, 4],
targetOffset: [0, 0],
},
type: 'default',
2016-07-13 11:14:24 +08:00
};
2015-12-02 15:18:15 +08:00
render() {
2016-07-13 11:14:24 +08:00
const [{ type, overlay, trigger, align, children, className, onClick }, restProps] = splitObject(this.props,
2016-06-22 13:18:43 +08:00
['type', 'overlay', 'trigger', 'align', 'children', 'className', 'onClick']);
const cls = classNames({
'ant-dropdown-button': true,
[className]: !!className,
});
return (
<ButtonGroup {...restProps} className={cls}>
<Button type={type} onClick={onClick}>{children}</Button>
<Dropdown align={align} overlay={overlay} trigger={trigger}>
<Button type={type}>
<Icon type="down" />
</Button>
</Dropdown>
</ButtonGroup>
);
2015-12-02 15:18:15 +08:00
}
}