2016-09-21 11:54:53 +08:00
|
|
|
import React from 'react';
|
2015-11-24 20:03:57 +08:00
|
|
|
import classNames from 'classnames';
|
2016-06-22 13:18:43 +08:00
|
|
|
import splitObject from '../_util/splitObject';
|
2015-09-27 16:30:35 +08:00
|
|
|
|
2016-09-13 15:31:29 +08:00
|
|
|
export type ButtonSize = 'small' | 'large'
|
2016-07-14 13:29:50 +08:00
|
|
|
|
2016-09-13 15:31:29 +08:00
|
|
|
export interface ButtonGroupProps {
|
2016-07-14 13:29:50 +08:00
|
|
|
size?: ButtonSize;
|
|
|
|
style?: React.CSSProperties;
|
|
|
|
className?: string;
|
2016-09-14 16:18:33 +08:00
|
|
|
prefixCls?: string;
|
2016-07-14 13:29:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function ButtonGroup(props: ButtonGroupProps) {
|
2016-09-14 16:18:33 +08:00
|
|
|
const [{ prefixCls = 'ant-btn-group', size, className }, others] =
|
|
|
|
splitObject(props, ['prefixCls', 'size', 'className']);
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-04-13 17:38:53 +08:00
|
|
|
// large => lg
|
|
|
|
// small => sm
|
|
|
|
const sizeCls = ({
|
|
|
|
large: 'lg',
|
|
|
|
small: 'sm',
|
|
|
|
})[size] || '';
|
2015-10-22 21:01:52 +08:00
|
|
|
|
2016-04-13 17:38:53 +08:00
|
|
|
const classes = classNames({
|
2016-09-14 16:18:33 +08:00
|
|
|
[prefixCls]: true,
|
|
|
|
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
2016-05-11 09:32:33 +08:00
|
|
|
[className]: className,
|
2016-04-13 17:38:53 +08:00
|
|
|
});
|
2015-10-22 21:01:52 +08:00
|
|
|
|
2016-04-13 17:38:53 +08:00
|
|
|
return <div {...others} className={classes} />;
|
2015-09-27 16:30:35 +08:00
|
|
|
}
|