index.vue
2.1 KB
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
<template>
<button class="zui-button" :class="classRender" :style="styleRender" v-on="bindEvents">
<slot></slot>
</button>
</template>
<script>
import color from 'color';
import BUTTON_MIXIN from '../mixins/button';
export default {
name: 'Button',
mixins: [BUTTON_MIXIN],
props: {
type: {
type: String,
default: 'default',
},
size: {
type: String,
default: 'md',
},
block: {
type: Boolean,
default: false,
},
round: Boolean,
square: Boolean,
disabled: Boolean,
theme: String,
color: String,
},
computed: {
classRender() {
return {
...this.bindClass,
[this.size]: true,
[this.type]: true,
[this.theme]: !!this.theme,
disabled: this.disabled,
block: this.block,
round: this.round,
square: this.square,
custom: !!this.color,
};
},
styleRender() {
if (this.color) {
if (this.type === 'primary') {
return {
backgroundColor: this.hover ? color(this.color).lighten(0.2) : this.color,
borderColor: this.hover ? color(this.color).lighten(0.2) : this.color,
};
} else if (this.type === 'secondary') {
return {
backgroundColor: this.hover ? color(this.color).lightness(90) : color(this.color).lightness(95),
color: this.color,
};
} else if (this.type === 'plain') {
return {
borderColor: this.color,
color: this.color,
backgroundColor: this.hover ? color(this.color).lightness(90) : color(this.color).lightness(95),
};
} else if (this.type === 'ghost') {
return {
borderColor: this.color,
color: this.color,
backgroundColor: this.hover ? color(this.color).lightness(95) : undefined,
};
} else {
return {
color: this.hover ? color(this.color).lighten(0.2) : this.color,
};
}
}
return {};
},
},
};
</script>
<style lang="scss">
@import './index.scss';
</style>