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

48 lines
885 B
Vue
Raw Normal View History

2017-10-26 15:18:08 +08:00
<script>
2018-02-24 18:12:24 +08:00
import { filterEmpty } from '../_util/props-util'
2018-01-29 18:57:20 +08:00
const ButtonGroupProps = {
prefixCls: {
default: 'ant-btn-group',
type: String,
},
size: {
validator (value) {
return ['small', 'large', 'default'].includes(value)
2017-10-26 15:18:08 +08:00
},
},
2018-01-29 18:57:20 +08:00
}
export { ButtonGroupProps }
export default {
name: 'ButtonGroup',
props: ButtonGroupProps,
2017-10-26 15:18:08 +08:00
data () {
return {
sizeMap: {
large: 'lg',
small: 'sm',
},
}
},
computed: {
classes () {
const { prefixCls, size, sizeMap } = this
const sizeCls = sizeMap[size] || ''
return [
{
[`${prefixCls}`]: true,
[`${prefixCls}-${sizeCls}`]: sizeCls,
},
]
},
},
2018-01-24 15:39:21 +08:00
render () {
const { classes, $slots } = this
return (
<div class={classes}>
{filterEmpty($slots.default)}
</div>
)
},
2017-10-26 15:18:08 +08:00
}
</script>