1
1
<template >
2
- <button class =" zhiwei-button" :class =" classes" >
3
- <slot ></slot >
4
- </button >
2
+ <button class =" zhiwei-button" :class =" classes" >
3
+ <span v-if =" loading" class =" zhiwei-loadingIndicator" ></span >
4
+ <slot />
5
+ </button >
5
6
</template >
6
-
7
7
<script lang="ts">
8
- import { computed } from ' vue'
8
+ import { computed } from " vue" ;
9
9
export default {
10
- props:{
11
- theme:{
12
- type:String ,
13
- default: ' button'
10
+ props: {
11
+ theme: {
12
+ type: String ,
13
+ default: " button" ,
14
+ },
15
+ size: {
16
+ type: String ,
17
+ default: " normal" ,
14
18
},
15
- size: {
19
+ level: {
16
20
type: String ,
17
- default: ' normal'
21
+ default: " normal" ,
22
+ },
23
+ disabled: {
24
+ type: Boolean ,
25
+ default: false ,
26
+ },
27
+ loading: {
28
+ type: Boolean ,
29
+ default: false
18
30
}
19
31
},
20
- setup(props ){
21
- const { theme,size } = props
22
- const classes = computed (()=> {
32
+ setup(props ) {
33
+ const { theme, size, level } = props ;
34
+ const classes = computed (() => {
23
35
return {
24
- [` zhiwei-theme-${theme } ` ]:theme ,
25
- [` zhiwei-size-${size } ` ]:size
26
- }
27
- })
28
- return {
29
- classes
30
- }
31
- }
36
+ [` zhiwei-theme-${theme } ` ]: theme ,
37
+ [` zhiwei-size-${size } ` ]: size ,
38
+ [` zhiwei-level-${level } ` ]: level
39
+ };
40
+ });
41
+ return { classes };
42
+ },
32
43
};
33
44
</script >
34
-
35
45
<style lang="scss">
36
46
$h : 32px ;
37
47
$border-color : #d9d9d9 ;
38
48
$color : #333 ;
39
49
$blue : #40a9ff ;
40
50
$radius : 4px ;
51
+ $red : red ;
52
+ $grey : grey ;
41
53
.zhiwei-button {
42
54
box-sizing : border-box ;
43
55
height : $h ;
@@ -52,6 +64,7 @@ $radius: 4px;
52
64
border : 1px solid $border-color ;
53
65
border-radius : $radius ;
54
66
box-shadow : 0 1px 0 fade-out (black , 0.95 );
67
+ transition : background 250ms ;
55
68
& + & {
56
69
margin-left : 8px ;
57
70
}
@@ -79,6 +92,7 @@ $radius: 4px;
79
92
border-color : transparent ;
80
93
box-shadow : none ;
81
94
color : inherit ;
95
+ background-color : transparent ;
82
96
& :hover ,
83
97
& :focus {
84
98
background : darken (white , 5% );
@@ -94,10 +108,82 @@ $radius: 4px;
94
108
height : 20px ;
95
109
padding : 0 4px ;
96
110
}
97
- & .zhiwei-size-mini {
98
- font-size : 10px ;
99
- height : 16px ;
100
- padding : 0 2px ;
111
+ & .zhiwei-theme-button {
112
+ & .zhiwei-level-main {
113
+ background : $blue ;
114
+ color : white ;
115
+ border-color : $blue ;
116
+ & :hover ,
117
+ & :focus {
118
+ background : darken ($blue , 10% );
119
+ border-color : darken ($blue , 10% );
120
+ }
121
+ }
122
+ & .zhiwei-level-danger {
123
+ background : $red ;
124
+ border-color : $red ;
125
+ color : white ;
126
+ & :hover ,
127
+ & :focus {
128
+ background : darken ($red , 10% );
129
+ border-color : darken ($red , 10% );
130
+ }
131
+ }
132
+ }
133
+ & .zhiwei-theme-link {
134
+ & .zhiwei-level-danger {
135
+ color : $red ;
136
+ & :hover ,
137
+ & :focus {
138
+ color : darken ($red , 10% );
139
+ }
140
+ }
141
+ }
142
+ & .zhiwei-theme-text {
143
+ & .zhiwei-level-main {
144
+ color : $blue ;
145
+ & :hover ,
146
+ & :focus {
147
+ color : darken ($blue , 10% );
148
+ }
149
+ }
150
+ & .zhiwei-level-danger {
151
+ color : $red ;
152
+ & :hover ,
153
+ & :focus {
154
+ color : darken ($red , 10% );
155
+ }
156
+ }
101
157
}
158
+ & .zhiwei-theme-button {
159
+ & [disabled ] {
160
+ cursor : not-allowed ;
161
+ color : $grey ;
162
+ & :hover {
163
+ border-color : $grey ;
164
+ }
165
+ }
166
+ }
167
+ & .zhiwei-theme-link , & .zhiwei-theme-text {
168
+ & [disabled ] {
169
+ cursor : not-allowed ;
170
+ color : $grey ;
171
+ }
172
+ }
173
+ > .zhiwei-loadingIndicator {
174
+ width : 14px ;
175
+ height : 14px ;
176
+ display : inline-block ;
177
+ margin-right : 4px ;
178
+ border-radius : 8px ;
179
+ border-color : $blue $blue $blue transparent ;
180
+ border-style : solid ;
181
+ border-width : 2px ;
182
+ animation : zhiwei- spin 1s infinite linear ;
183
+ }
184
+ }
185
+ @keyframes zhiwei-spin {
186
+ 0% {transform : rotate (0deg )}
187
+ 100% {transform : rotate (360deg )}
102
188
}
103
189
</style >
0 commit comments