2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2015-11-24 20:03:57 +08:00
|
|
|
import classNames from 'classnames';
|
2017-09-25 22:14:49 +08:00
|
|
|
import { ButtonSize } from './button';
|
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
|
|
|
}
|
|
|
|
|
2017-07-18 16:46:19 +08:00
|
|
|
const ButtonGroup: React.SFC<ButtonGroupProps> = (props) => {
|
2017-10-20 10:52:06 +08:00
|
|
|
const { prefixCls = 'ant-btn-group', size, className, ...others } = props;
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-04-13 17:38:53 +08:00
|
|
|
// large => lg
|
|
|
|
// small => sm
|
2017-04-27 00:30:51 +08:00
|
|
|
let sizeCls = '';
|
|
|
|
switch (size) {
|
|
|
|
case 'large':
|
|
|
|
sizeCls = 'lg';
|
|
|
|
break;
|
|
|
|
case 'small':
|
|
|
|
sizeCls = 'sm';
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-10-22 21:01:52 +08:00
|
|
|
|
2016-11-30 10:20:23 +08:00
|
|
|
const classes = classNames(prefixCls, {
|
2016-09-14 16:18:33 +08:00
|
|
|
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
2016-11-30 10:20:23 +08:00
|
|
|
}, className);
|
2015-10-22 21:01:52 +08:00
|
|
|
|
2016-04-13 17:38:53 +08:00
|
|
|
return <div {...others} className={classes} />;
|
2017-07-18 16:46:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default ButtonGroup;
|