-
Notifications
You must be signed in to change notification settings - Fork 13
/
BaseButton.vue
85 lines (78 loc) · 1.88 KB
/
BaseButton.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
<template>
<Button
:disabled="disabled || isLoading"
:class="buttonClass"
class="Button"
:type="type"
:html-type="htmlType"
@click="$emit('click')"
>
<template v-if="isLoading">
<span><loading-icon class="h-3 w-3 fill-current text-gray-400 animate-spin mr-2 my-auto" /></span>
<slot />
</template>
<slot v-else />
</Button>
</template>
<script lang="ts">
import Vue from 'vue';
import { Button } from 'ant-design-vue';
import LoadingIcon from '~/assets/icons/loading.svg';
export default Vue.extend({
components: {
Button,
LoadingIcon,
},
props: {
type: {
type: String,
default: '',
},
disabled: {
type: Boolean,
default: false,
},
isLoading: {
type: Boolean,
default: false,
},
htmlType: {
type: String,
default: 'button',
},
},
computed: {
buttonClass() {
if (this.type === 'primary') {
return 'Primary';
}
if (this.type === 'link') {
return 'Link';
}
return 'Default';
},
},
});
</script>
<style scoped>
.Button {
@apply w-auto;
}
.Button.Default:enabled {
@apply border-primary text-primary hover:text-white hover:bg-primary-light hover:border-primary-light;
}
.Primary:enabled,
.dark .Primary:enabled {
@apply text-white bg-primary border-primary focus:bg-primary-light focus:border-primary-light hover:bg-primary-light hover:border-primary-light;
}
.Link,
.dark .Link {
@apply inline-flex items-center p-0 h-auto leading-4;
}
.Link span {
@apply text-primary underline overflow-auto transition-colors;
}
.Link:hover span {
@apply text-primary-light no-underline;
}
</style>