forked from Kholid060/inspect-css
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.vue
More file actions
54 lines (53 loc) · 1.23 KB
/
Button.vue
File metadata and controls
54 lines (53 loc) · 1.23 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
<template>
<component
:is="tag"
role="button"
class="ui-button relative transition"
:class="[
color ? color : variants[variant],
icon ? 'p-2' : 'py-2 px-4',
circle ? 'rounded-full' : 'rounded-lg',
{ 'opacity-70': disabled, 'pointer-events-none': disabled },
]"
v-bind="{ disabled: disabled, ...$attrs }"
>
<span class="flex justify-center h-full items-center">
<slot></slot>
</span>
<div v-if="loading" class="vertical-center horizontal-center">
<ui-spinner :color="variant === 'default' ? 'text-primary' : 'text-white'"></ui-spinner>
</div>
</component>
</template>
<script>
export default {
props: {
icon: Boolean,
disabled: Boolean,
circle: Boolean,
loading: Boolean,
color: {
type: String,
default: '',
},
tag: {
type: String,
default: 'button',
},
variant: {
type: String,
default: 'default',
},
},
setup() {
const variants = {
default: 'bg-gray-100 bg-opacity-5 hover:bg-opacity-10 hover:bg-white',
primary: 'bg-primary text-white hover:bg-blue-600',
danger: 'bg-red-500 text-white hover:bg-red-600',
};
return {
variants,
};
},
};
</script>