File tree 16 files changed +322
-3
lines changed
16 files changed +322
-3
lines changed Original file line number Diff line number Diff line change 98
98
"input-phone" : " ./packages/input-phone/index.js" ,
99
99
"input-email" : " ./packages/input-email/index.js" ,
100
100
"switch-enhance" : " ./packages/switch-enhance/index.js" ,
101
- "input-url" : " ./packages/input-url/index.js"
101
+ "input-url" : " ./packages/input-url/index.js" ,
102
+ "button-group-enhance" : " ./packages/button-group-enhance/index.js"
102
103
}
Original file line number Diff line number Diff line change
1
+ .el-card .el-card__body {
2
+ padding : 0 ;
3
+
4
+ .content {
5
+ padding : 20px ;
6
+ }
7
+ .el-button-group-enhance {
8
+ .el-button {
9
+ border-bottom : none ;
10
+ border-radius : 0 ;
11
+ & :first-child {
12
+ border-left : none ;
13
+ }
14
+ & .el-dropdown__caret-button {
15
+ border-right : none ;
16
+ }
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change 44
44
@import " ./infinite-scroll.scss" ;
45
45
@import " ./avatar.scss" ;
46
46
@import " ./drawer.scss" ;
47
-
47
+ @import " ./button-group-enhance.scss " ;
Original file line number Diff line number Diff line change
1
+ ## ButtonGroupEnhance
Original file line number Diff line number Diff line change
1
+ ## ButtonGroupEnhance
Original file line number Diff line number Diff line change
1
+ ## ButtonGroupEnhance
Original file line number Diff line number Diff line change
1
+ ## ElButtonGroupEnhance 可折叠按钮组
2
+
3
+ ### 基本用法
4
+
5
+ 可折叠的按钮组,常用于卡片底部放置聚合操作。
6
+
7
+ ::: demo
8
+
9
+ ``` html
10
+ <template >
11
+ <el-row :gutter =" 15" >
12
+ <el-col :span =" 10" >
13
+ <el-button-group-enhance
14
+ :buttons =" buttons()"
15
+ type =" primary"
16
+ :collapse-at =" 3"
17
+ />
18
+ <el-button-group-enhance
19
+ style =" margin-top : 15px "
20
+ :buttons =" buttons()"
21
+ :collapse-at =" 3"
22
+ />
23
+ </el-col >
24
+ <el-col :span =" 10" >
25
+ <el-card shadow =" hover" >
26
+ <div class =" content" >
27
+ activate: {{activate}}
28
+ </div >
29
+ <el-button-group-enhance
30
+ :buttons =" buttons()"
31
+ :collapse-at =" 3"
32
+ />
33
+ </el-card >
34
+ <el-card shadow =" hover" style =" margin-top : 15px " >
35
+ <div class =" content" >
36
+ activate: {{activate}}
37
+ </div >
38
+ <el-button-group-enhance
39
+ :buttons =" buttons()"
40
+ type =" primary"
41
+ :collapse-at =" 3"
42
+ />
43
+ </el-card >
44
+ </el-col >
45
+ </el-row >
46
+ </template >
47
+
48
+ <script >
49
+ export default {
50
+ data () {
51
+ return {
52
+ activate: true ,
53
+ buttons : () => [
54
+ {
55
+ text: ' 查看应用信息' ,
56
+ click : () => {
57
+ return new Promise (r => setTimeout (r, 2000 ))
58
+ },
59
+ },
60
+ {
61
+ text: ' 开发者信息' ,
62
+ },
63
+ {
64
+ text: ` ${ this .activate ? ' 禁' : ' 启' } 用应用` ,
65
+ click : () => {
66
+ this .activate = ! this .activate
67
+ },
68
+ },
69
+ {
70
+ text: ' 删除应用' ,
71
+ show: ! this .activate
72
+ },
73
+ ],
74
+ }
75
+ }
76
+ }
77
+ </script >
78
+ <style lang =" scss" >
79
+ .el-card .el-card__body {
80
+ padding : 0 ;
81
+
82
+ .content {
83
+ padding : 20px ;
84
+ }
85
+ .el-button-group-enhance {
86
+ .el-button {
87
+ border-bottom : none ;
88
+ border-radius : 0 ;
89
+ &:first-child {
90
+ border-left: none ;
91
+ }
92
+ &.el-dropdown__caret-button {
93
+ border-right : none ;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ </style >
99
+ ```
100
+ :::
101
+
102
+ ### Attributes
103
+ | 参数 | 说明 | 类型 | 可选值 | 默认值 |
104
+ | ---------- | -------- | ---------- | ------------- | -------- |
105
+ | buttons | 按钮配置列表 | array | — | [ ] |
106
+ | buttons[ 0] | el-button 的所有属性 | object | — | — |
107
+ | buttons[ 0] .text | 按钮文案 | string | — | — |
108
+ | buttons[ 0] .click | 点击按钮触发的操作 | function | — | — |
109
+ | collapseAt | 从第几个按钮开始折叠 | number | — | 2 |
110
+ | moreText | 折叠按钮的文案 | string | — | 更多 |
111
+ | size | 尺寸 | string | mini /small / median | small |
112
+ | type | 类型 | string | primary / success / warning / danger / info / text | default |
Original file line number Diff line number Diff line change 375
375
{
376
376
"path" : " /switch-enhance" ,
377
377
"title" : " SwitchEnhance 开关增强"
378
+ },
379
+ {
380
+ "path" : " /button-group-enhance" ,
381
+ "title" : " ButtonGroupEnhance 可折叠按钮组"
378
382
}
379
383
]
380
384
}
751
755
{
752
756
"path" : " /input-url" ,
753
757
"title" : " InputUrl"
758
+ },
759
+ {
760
+ "path" : " /button-group-enhance" ,
761
+ "title" : " ButtonGroupEnhance"
754
762
}
755
763
]
756
764
}
1127
1135
{
1128
1136
"path" : " /input-url" ,
1129
1137
"title" : " InputUrl"
1138
+ },
1139
+ {
1140
+ "path" : " /button-group-enhance" ,
1141
+ "title" : " ButtonGroupEnhance"
1130
1142
}
1131
1143
]
1132
1144
}
1502
1514
{
1503
1515
"path" : " /input-url" ,
1504
1516
"title" : " InputUrl"
1517
+ },
1518
+ {
1519
+ "path" : " /button-group-enhance" ,
1520
+ "title" : " ButtonGroupEnhance"
1505
1521
}
1506
1522
]
1507
1523
}
Original file line number Diff line number Diff line change
1
+ import ButtonGroupEnhance from './src/main' ;
2
+
3
+ /* istanbul ignore next */
4
+ ButtonGroupEnhance . install = function ( Vue ) {
5
+ Vue . component ( ButtonGroupEnhance . name , ButtonGroupEnhance ) ;
6
+ } ;
7
+
8
+ export default ButtonGroupEnhance ;
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <el-button-group class =" el-button-group-enhance" >
3
+ <el-loading-button
4
+ v-for =" (button, index) in buttonsAtFront"
5
+ :key =" index"
6
+ :type =" type"
7
+ :size =" size"
8
+ v-bind =" button"
9
+ :loading-click =" button.click"
10
+ >{{ button.text }}</el-loading-button
11
+ >
12
+ <el-dropdown
13
+ v-if =" buttonsCollapsed.length"
14
+ :size =" size"
15
+ placement =" bottom-start"
16
+ @command =" handleCommand"
17
+ >
18
+ <el-button :type =" type" :size =" size" class =" el-dropdown__caret-button" >
19
+ <slot name =" more" >
20
+ {{ moreText }}
21
+ <i class =" el-icon-arrow-down el-icon--right" ></i >
22
+ </slot >
23
+ </el-button >
24
+ <el-dropdown-menu slot =" dropdown" >
25
+ <el-dropdown-item
26
+ v-for =" (item, key) in buttonsCollapsed"
27
+ :key =" key"
28
+ v-bind =" item"
29
+ :command =" key"
30
+ >
31
+ <slot v-bind =" item" name =" dropdownItem" >{{ item.text }}</slot >
32
+ </el-dropdown-item >
33
+ </el-dropdown-menu >
34
+ </el-dropdown >
35
+ </el-button-group >
36
+ </template >
37
+
38
+ <script >
39
+ export default {
40
+ name: ' ElButtonGroupEnhance' ,
41
+ props: {
42
+ /**
43
+ * 支持所有 button 属性和以下:
44
+ * text: string
45
+ * show: (data) => boolean
46
+ * click: (data) => Promise | undefined
47
+ */
48
+ buttons: {
49
+ type: Array ,
50
+ default : () => []
51
+ },
52
+
53
+ // 从第 n 个按钮开始折叠
54
+ collapseAt: {
55
+ type: Number ,
56
+ default: 2 ,
57
+ validator : v => v > 1
58
+ },
59
+
60
+ moreText: {
61
+ type: String ,
62
+ default: ' 更多'
63
+ },
64
+
65
+ type: {
66
+ type: String ,
67
+ default: ' default'
68
+ },
69
+
70
+ size: {
71
+ type: String ,
72
+ default: ' small'
73
+ }
74
+ },
75
+
76
+ computed: {
77
+ buttonsDisplay : ({ buttons }) =>
78
+ buttons
79
+ .filter (({ show = true }) => show)
80
+ .map (config => ({
81
+ click () {},
82
+ ... config
83
+ })),
84
+
85
+ sliceIndex () {
86
+ return this .collapseAt - 1 ;
87
+ },
88
+
89
+ buttonsAtFront () {
90
+ return this .buttonsDisplay .slice (0 , this .sliceIndex );
91
+ },
92
+
93
+ buttonsCollapsed () {
94
+ return this .buttonsDisplay .slice (this .sliceIndex );
95
+ }
96
+ },
97
+
98
+ methods: {
99
+ handleCommand (index ) {
100
+ this .buttonsCollapsed [index].click ();
101
+ }
102
+ }
103
+ };
104
+ </script >
Original file line number Diff line number Diff line change
1
+ @import " mixins/mixins" ;
2
+ @import " common/var" ;
3
+
4
+ @include b (button- group- enhance) {
5
+ display : flex ;
6
+
7
+ & > .el-button {
8
+ flex : 1 0 0 ;
9
+ padding-left : 0 ;
10
+ padding-right : 0 ;
11
+ }
12
+
13
+ .el-dropdown {
14
+ flex : 1 0 0 ;
15
+ .el-dropdown__caret-button {
16
+ width : 100% ;
17
+ border-top-left-radius : 0 ;
18
+ border-bottom-left-radius : 0 ;
19
+ & ::before {
20
+ top : 0 ;
21
+ bottom : 0 ;
22
+ }
23
+ & .el-button--default ::before {
24
+ background-color : #DCDEE6 ;
25
+ }
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change 96
96
@import " ./input-email.scss" ;
97
97
@import " ./switch-enhance.scss" ;
98
98
@import " ./input-url.scss" ;
99
+ @import " ./button-group-enhance.scss" ;
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ import InputPhone from '../packages/input-phone/index.js';
100
100
import InputEmail from '../packages/input-email/index.js' ;
101
101
import SwitchEnhance from '../packages/switch-enhance/index.js' ;
102
102
import InputUrl from '../packages/input-url/index.js' ;
103
+ import ButtonGroupEnhance from '../packages/button-group-enhance/index.js' ;
103
104
import locale from 'element-ui/src/locale' ;
104
105
import CollapseTransition from 'element-ui/src/transitions/collapse-transition' ;
105
106
@@ -198,6 +199,7 @@ const components = [
198
199
InputEmail ,
199
200
SwitchEnhance ,
200
201
InputUrl ,
202
+ ButtonGroupEnhance ,
201
203
CollapseTransition
202
204
] ;
203
205
@@ -339,5 +341,6 @@ export default {
339
341
InputPhone,
340
342
InputEmail,
341
343
SwitchEnhance,
342
- InputUrl
344
+ InputUrl,
345
+ ButtonGroupEnhance
343
346
} ;
Original file line number Diff line number Diff line change
1
+ import { createTest , destroyVM } from '../util' ;
2
+ import ButtonGroupEnhance from 'packages/button-group-enhance' ;
3
+
4
+ describe ( 'ButtonGroupEnhance' , ( ) => {
5
+ let vm ;
6
+ afterEach ( ( ) => {
7
+ destroyVM ( vm ) ;
8
+ } ) ;
9
+
10
+ it ( 'create' , ( ) => {
11
+ vm = createTest ( ButtonGroupEnhance , true ) ;
12
+ expect ( vm . $el ) . to . exist ;
13
+ } ) ;
14
+ } ) ;
15
+
Original file line number Diff line number Diff line change
1
+ import { ElementUIComponent } from './component'
2
+
3
+ /** ButtonGroupEnhance Component */
4
+ export declare class ElButtonGroupEnhance extends ElementUIComponent {
5
+ }
You can’t perform that action at this time.
0 commit comments