-
Notifications
You must be signed in to change notification settings - Fork 9
/
u-button.vue
114 lines (101 loc) · 2.13 KB
/
u-button.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<a
class="u-button"
v-on="listeners"
:autofocus="autofocus"
:href="href"
:disabled="disabled"
:round="round"
:circle="circle"
@click="onClick"
>
<u-icon v-if="icon" :name="icon" />
<span v-if="$slots.default"><slot></slot></span>
</a>
</template>
<script>
import ULink from './u-link.vue'
export default {
name: 'u-button',
mixins: [ULink],
props: {
icon: String,
autofocus: Boolean,
round: Boolean,
circle: Boolean
}
}
</script>
<style lang="scss" scoped>
.u-button {
position: relative;
text-align: center;
cursor: pointer;
user-select: none;
display: inline-block;
padding: 10px 20px;
border: 1px solid $border-color;
border-radius: 4px;
background-color: #ffffff;
letter-spacing: 0;
line-height: 1;
&:hover {
border: 1px solid $primary-color;
color: $primary-color;
}
/* size大小 */
&[size='l'] {
padding: 12px 20px;
}
&[size='s'] {
padding: 9px 15px;
font-size: 12px;
border-radius: 3px;
}
&[size='xs'] {
padding: 7px 15px;
font-size: 12px;
border-radius: 3px;
}
/* round圆角 */
&[round] {
border-radius: 20px;
}
&[circle] {
border-radius: 50%;
padding: 10px;
}
/* type类型 */
@each $name, $color in $colors {
&[type='#{$name}'] {
border: 1px solid $color;
background: $color;
color: #ffffff;
}
}
&[type='text'] {
color: $primary-color;
background: 0 0;
padding: 0;
border: none;
&[disabled] {
color: $disabled-color;
background: 0 0;
border: none;
}
}
/*禁用*/
&[disabled] {
cursor: not-allowed;
background: $disabled-color;
border: 1px solid $disabled-color;
color: #ffffff;
}
& + .u-button {
margin-left: 10px;
}
[class*='u-icon-'] + span {
margin-left: 5px;
}
}
</style>