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

47 lines
1.1 KiB
TypeScript
Raw Normal View History

import * as React from 'react';
import classNames from 'classnames';
import { ButtonSize } from './button';
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
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;
prefixCls?: string;
2016-07-14 13:29:50 +08:00
}
const ButtonGroup: React.SFC<ButtonGroupProps> = props => (
<ConfigConsumer>
{({ getPrefixCls }: ConfigConsumerProps) => {
const { prefixCls: customizePrefixCls, size, className, ...others } = props;
const prefixCls = getPrefixCls('btn-group', customizePrefixCls);
// large => lg
// small => sm
let sizeCls = '';
switch (size) {
case 'large':
sizeCls = 'lg';
break;
case 'small':
sizeCls = 'sm';
2019-08-05 18:38:10 +08:00
break;
default:
break;
}
2018-12-07 20:02:01 +08:00
const classes = classNames(
prefixCls,
{
[`${prefixCls}-${sizeCls}`]: sizeCls,
},
className,
);
return <div {...others} className={classes} />;
}}
</ConfigConsumer>
);
2017-07-18 16:46:19 +08:00
export default ButtonGroup;