1
- <script >
2
- export default {
3
- name: " VueLoadingButton" ,
4
- props: {
5
- loading: {
6
- type: Boolean ,
7
- required: false ,
8
- default: false
9
- },
10
- }
11
- };
12
- </script >
13
-
14
1
<template >
15
2
<button
16
3
:class =" {
17
4
'vue-loading-button': true,
5
+ 'default-styles': styled,
18
6
'loading': loading,
19
7
}"
8
+ :disabled =" loading"
20
9
type =" button"
21
10
>
22
11
<slot >Submit</slot >
@@ -29,77 +18,77 @@ export default {
29
18
</button >
30
19
</template >
31
20
21
+ <script >
22
+ export default {
23
+ name: " VueLoadingButton" ,
24
+ props: {
25
+ loading: {
26
+ type: Boolean ,
27
+ required: false ,
28
+ default: false
29
+ },
30
+ styled: {
31
+ type: Boolean ,
32
+ required: false ,
33
+ default: true
34
+ }
35
+ }
36
+ };
37
+ </script >
38
+
32
39
<style scoped>
33
40
/* reset */
34
- .vue-loading- button {
41
+ button {
35
42
font-family : inherit ;
36
43
font-size : 100% ;
44
+ font-size : 1.4rem ;
37
45
line-height : 1.15 ;
38
46
margin : 0 ;
39
47
overflow : visible ;
40
48
text-transform : none ;
41
49
-webkit-appearance : button;
42
50
}
43
- .vue-loading- button::-moz-focus-inner {
51
+ button ::-moz-focus-inner {
44
52
border-style : none ;
45
53
padding : 0 ;
46
54
}
47
- .vue-loading- button:-moz-focusring {
55
+ button :-moz-focusring {
48
56
outline : 1px dotted ButtonText ;
49
57
}
50
- /* styles */
51
- .vue-loading-button {
52
- color : white ;
53
- background-color : blue ;
54
- border : solid 1px transparent ;
55
- border-radius : 4px ;
56
- cursor : pointer ;
57
- padding : 8px 16px ;
58
- line-height : 1.9rem ;
59
- font-size : 1.4rem ;
58
+
59
+ /* loading styles */
60
+ button {
60
61
position : relative ;
61
62
-webkit-transition : all 0.2s ;
62
63
transition : all 0.2s ;
63
64
transition-timing-function : ease-in ;
64
- overflow : hidden ;
65
- }
66
- .vue-loading-button :focus {
67
- outline : none ;
68
- box-shadow : 0 0 0 3px lightblue ,
69
- 0 0 0 1.5px lightblue ;
70
- }
71
- .vue-loading-button :not (.loading ) {
72
- transition-delay : 0.2s ;
73
65
}
74
66
.spinner {
75
67
line-height : 1.15 ;
76
68
position : absolute ;
77
69
top : 50% ;
78
70
left : auto ;
79
- right : 1.28 em ;
71
+ right : 1.7 rem ;
80
72
margin : -0.5em ;
81
- -webkit-transition : all 0.2s ;
82
- transition : all 0.2s ;
83
- transition-timing-function : ease-in ;
73
+ opacity : 0 ;
74
+ transition-property : padding , opacity;
75
+ transition-duration : 0.2s , 0.2s ;
76
+ transition-timing-function : ease-in , ease ;
77
+ transition-delay : 0s , 0.2s ;
84
78
}
85
79
.spinner span {
86
80
box-sizing : border-box ;
87
81
display : inline-block ;
88
82
position : absolute ;
89
83
right : 0 ;
90
- width : 1.2rem ;
91
- height : 1.2rem ;
92
- opacity : 0 ;
93
- border : 3.4px solid #fff ;
84
+ top : 0.15rem ;
85
+ width : 1rem ;
86
+ height : 1rem ;
87
+ opacity : 1 ;
88
+ border : 3.4px solid #888 ;
94
89
border-radius : 50% ;
95
90
animation : spinner 1.2s cubic-bezier (0.5 , 0 , 0.5 , 1 ) infinite ;
96
- border-color : #fff transparent transparent transparent ;
97
- -webkit-transition : opacity 0.2s ;
98
- transition : opacity 0.2s ;
99
- transition-timing-function : ease ;
100
- }
101
- .spinner span {
102
- transition-delay : 0.2s ;
91
+ border-color : #888 transparent transparent transparent ;
103
92
}
104
93
.spinner span :nth-child (1 ) {
105
94
animation-delay : 0.45s ;
@@ -110,22 +99,34 @@ export default {
110
99
.spinner span :nth-child (3 ) {
111
100
animation-delay : 0.15s ;
112
101
}
113
- .vue-loading-button :not (.loading ) .spinner span {
114
- box-shadow : 0 0 0 .2rem rgba (255 , 255 , 255 , 1 );
115
- border : 10.4px solid #fff ;
102
+ .loading {
103
+ padding-right : 3rem !important ;
104
+ }
105
+ .loading .spinner {
106
+ opacity : 1 ;
107
+ }
108
+ .loading .spinner span {
109
+ opacity : 1 ;
110
+ }
111
+ button :not (:disabled ) {
112
+ transition-delay : 0.2s ;
113
+ }
114
+ button :not (:disabled ) .spinner span {
115
+ box-shadow : 0 0 0 0.2rem #888 inset ;
116
+ border : 7.4px solid transparent ;
116
117
-webkit-transition : all 0.4s ;
117
118
transition : all 0.4s ;
118
119
}
119
- .vue-loading- button:not (.loading ) .spinner span :nth-child (1 ) {
120
+ button :not (:disabled ) .spinner span :nth-child (1 ) {
120
121
transform : rotate (0deg ) !important ;
121
122
}
122
- .vue-loading- button:not (.loading ) .spinner span :nth-child (2 ) {
123
+ button :not (:disabled ) .spinner span :nth-child (2 ) {
123
124
transform : rotate (90deg ) !important ;
124
125
}
125
- .vue-loading- button:not (.loading ) .spinner span :nth-child (3 ) {
126
+ button :not (:disabled ) .spinner span :nth-child (3 ) {
126
127
transform : rotate (180deg ) !important ;
127
128
}
128
- .vue-loading- button:not (.loading ) .spinner span :nth-child (4 ) {
129
+ button :not (:disabled ) .spinner span :nth-child (4 ) {
129
130
transform : rotate (270deg ) !important ;
130
131
}
131
132
@keyframes spinner {
@@ -136,10 +137,34 @@ export default {
136
137
transform : rotate (360deg );
137
138
}
138
139
}
139
- .loading {
140
- padding-right : 2.3em ;
140
+
141
+ /* default styles */
142
+ .default-styles {
143
+ color : white ;
144
+ background-color : blue ;
145
+ border : solid 1px transparent ;
146
+ border-radius : 4px ;
147
+ cursor : pointer ;
148
+ padding : 8px 16.5px 8px 16px ;
149
+ line-height : 1.9rem ;
141
150
}
142
- .loading .spinner span {
143
- opacity : 1 ;
151
+ .default-styles :disabled {
152
+ pointer-events : stroke ;
153
+ cursor : not-allowed ;
154
+ }
155
+ .default-styles :focus {
156
+ outline : none ;
157
+ box-shadow : 0 0 0 3px lightblue , 0 0 0 1.5px lightblue ;
158
+ }
159
+ .default-styles .spinner span {
160
+ top : 0rem ;
161
+ width : 1.2rem ;
162
+ height : 1.2rem ;
163
+ border : 3.4px solid #fff ;
164
+ border-color : #fff transparent transparent transparent ;
165
+ }
166
+ .default-styles :not (:disabled ) .spinner span {
167
+ border : 8.4px solid transparent ;
168
+ box-shadow : 0 0 0 0.1rem #fff inset ;
144
169
}
145
170
</style >
0 commit comments