ant-design-vue/components/button/button-group.jsx
Amour1688 615b460ee4
chore: enhance eslint (#1890)
* perf: enhance eslint

* perf: remove props in progress
2020-03-18 14:52:02 +08:00

53 lines
1.2 KiB
Vue

import { filterEmpty } from '../_util/props-util';
import PropTypes from '../_util/vue-types';
import { ConfigConsumerProps } from '../config-provider';
const ButtonGroupProps = {
prefixCls: PropTypes.string,
size: {
validator(value) {
return ['small', 'large', 'default'].includes(value);
},
},
};
export { ButtonGroupProps };
export default {
name: 'AButtonGroup',
props: ButtonGroupProps,
inject: {
configProvider: { default: () => ConfigConsumerProps },
},
data() {
return {
sizeMap: {
large: 'lg',
small: 'sm',
},
};
},
render() {
const { prefixCls: customizePrefixCls, size, $slots } = this;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('btn-group', customizePrefixCls);
// large => lg
// small => sm
let sizeCls = '';
switch (size) {
case 'large':
sizeCls = 'lg';
break;
case 'small':
sizeCls = 'sm';
break;
default:
break;
}
const classes = {
[`${prefixCls}`]: true,
[`${prefixCls}-${sizeCls}`]: sizeCls,
};
return <div class={classes}>{filterEmpty($slots.default)}</div>;
},
};