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

33 lines
728 B
TypeScript
Raw Normal View History

2016-07-07 20:25:03 +08:00
import * as React from 'react';
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
const prefix = 'ant-btn-group-';
2016-07-14 13:29:50 +08:00
type ButtonSize = 'small' | 'large'
interface ButtonGroupProps {
size?: ButtonSize;
style?: React.CSSProperties;
className?: string;
}
export default function ButtonGroup(props: ButtonGroupProps) {
2016-07-13 11:14:24 +08:00
const [{ size, className }, others] = splitObject(props, ['size', 'className']);
// large => lg
// small => sm
const sizeCls = ({
large: 'lg',
small: 'sm',
})[size] || '';
const classes = classNames({
'ant-btn-group': true,
[prefix + sizeCls]: sizeCls,
2016-05-11 09:32:33 +08:00
[className]: className,
});
return <div {...others} className={classes} />;
2015-09-27 16:30:35 +08:00
}