feat(button-group): size

This commit is contained in:
07akioni 2020-02-08 16:21:09 +08:00
parent 1b1f43328e
commit 577104b11f
6 changed files with 28 additions and 8 deletions

View File

@ -1,7 +1,7 @@
# Button Group
Button can be grouped.
```html
<n-button-group>
<n-button-group size="small">
<n-button
type="default"
round

View File

@ -17,9 +17,10 @@ debug
### Button Props
|Name|Type|Default|Description|
|-|-|-|-|
|size|`'small' \| 'medium' \| 'large'`|`'medium'`
|size|`'small' \| 'medium' \| 'large'`|`'medium'`||
|type|`'default' \| 'primary' \| 'success' \| 'info' \| 'warning' \| 'error'`|`'default'`||
|text|`boolean`|`false`||
|block|`boolean`|`false`||
|ghost|`boolean`|`false`||
|disabled|`boolean`|`false`||
|circle|`boolean`|`false`||
@ -30,6 +31,7 @@ debug
### Button Group Props
|Name|Type|Default|Description|
|-|-|-|-|
|size|`'small' \| 'medium' \| 'large'`|`null`|The buttons' size in button group. If set, the button's size prop inner group won't work.|
|vertical|`boolean`|`false`||
## Slots

View File

@ -1,7 +1,7 @@
# 按钮组
可以把几个按钮结合成按钮组。
```html
<n-button-group>
<n-button-group size="small">
<n-button
type="default"
round

View File

@ -17,9 +17,10 @@ debug
### Button Props
|名称|类型|默认值|说明|
|-|-|-|-|
|size|`'small' \| 'medium' \| 'large'`|`'medium'`
|size|`'small' \| 'medium' \| 'large'`|`'medium'`||
|type|`'default' \| 'primary' \| 'success' \| 'info' \| 'warning' \| 'error'`|`'default'`||
|text|`boolean`|`false`||
|block|`boolean`|`false`||
|ghost|`boolean`|`false`||
|disabled|`boolean`|`false`||
|circle|`boolean`|`false`||
@ -30,6 +31,7 @@ debug
### Button Group Props
|名称|类型|默认值|说明|
|-|-|-|-|
|size|`'small' \| 'medium' \| 'large'`|`'medium'`|在组内的按钮的尺寸。如果设定,内部的按钮尺寸将不生效|
|vertical|`boolean`|`false`||
## Slots

View File

@ -5,7 +5,7 @@
'n-button--round': round,
'n-button--circle': circle,
[`n-button--${type}-type`]: true,
[`n-button--${size}-size`]: true,
[`n-button--${synthesizedSize}-size`]: true,
'n-button--disabled': disabled,
'n-button--loading': loading,
'n-button--block': block,
@ -121,6 +121,11 @@ export default {
NIconSwitchTransition,
NFadeInHeightExpandTransition
},
inject: {
NButtonGroup: {
default: null
}
},
mixins: [withapp, themeable, hollowoutable],
props: {
text: {
@ -194,6 +199,12 @@ export default {
}
},
computed: {
synthesizedSize () {
if (this.NButtonGroup && this.NButtonGroup.size) {
return this.NButtonGroup.size
}
return this.size
},
noTextContent () {
return this.circle || !this.$slots.default
},

View File

@ -13,10 +13,15 @@
<script>
export default {
name: 'NButtonGroup',
provide () {
return {
NButtonGroup: this
}
},
props: {
block: {
type: Boolean,
default: false
size: {
type: String,
default: null
},
vertical: {
type: Boolean,