forked from didi/mand-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.vue
148 lines (138 loc) · 3.18 KB
/
index.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<template>
<div
class="md-button"
:class="[type, size, disabled ? 'disabled' : '', icon ? 'with-icon' : '']"
@click="$_onBtnClick"
>
<div class="md-button-inner">
<template v-if="icon">
<md-icon :name="icon"></md-icon>
</template>
<slot></slot>
</div>
</div>
</template>
<script>import Icon from '../icon'
export default {
name: 'md-button',
components: {
[Icon.name]: Icon,
},
props: {
type: {
type: String,
default: 'primary',
},
size: {
type: String,
default: 'large',
},
icon: {
type: String,
default: '',
},
disabled: {
type: Boolean,
default: false,
},
},
methods: {
$_onBtnClick(event) {
if (this.disabled) {
event.stopImmediatePropagation()
} else {
this.$emit('click', event)
}
},
},
}
</script>
<style lang="stylus">
.md-button
-webkit-user-select none
-webkit-tap-highlight-color transparent
position relative
text-align center
border-radius radius-normal
box-sizing border-box
overflow visible
&.disabled
&:active::before
display none
&::before
absolute-pos()
display none
content ''
position absolute
box-sizing border-box
&:active::before
display block
.md-button-inner
width 100%
height 100%
overflow hidden
text-overflow ellipsis
word-break break-word
white-space nowrap
// type
&.primary
background-color button-primary-fill
color color-text-base-inverse
&:active::before
background-color button-primary-fill-tap
&.disabled
background-color button-primary-fill-disabled
&.large, &.small
width button-primary-width
height button-primary-height
line-height button-primary-height
font-size button-primary-font-size
font-weight font-weight-medium
&.ghost
color button-ghost-color
hairline(all, button-ghost-color, true)
&:active::before
background-color button-ghost-fill-tap
&.ghost-primary
color button-ghost-primary-color
hairline(all, button-ghost-primary-color, true)
&:active::before
background-color button-ghost-primary-fill-tap
&.ghost, &.ghost-primary
&.disabled
opacity opacity-disabled
&.large
width button-ghost-width
height button-ghost-height
line-height button-ghost-height
font-size button-ghost-font-size
&.small
width button-ghost-width-sm
height button-ghost-height-sm
line-height button-ghost-height-sm
font-size button-ghost-font-size
&.link
background-color button-link-fill
color button-link-color
.md-button-inner
hairline(top, color-border-base)
hairline(bottom, color-border-base)
display flex
align-items center
justify-content center
&:active::before
background-color button-link-fill-tap
&.disabled
opacity opacity-disabled
&.large, &.small
width button-link-width
height button-link-height
font-size font-heading-normal
&.with-icon
.md-icon
display flex
align-items center
justify-content center
margin-right h-gap-sm
</style>