/
UiButton.vue
75 lines (64 loc) · 1.81 KB
/
UiButton.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
<script setup lang="ts">
// Common
import { computed } from 'vue';
// Types
import type { TypeClassList } from '~/assets/utils/types';
// Composable
import { classNameProps, useClassName } from '~/composables/useClassName';
import { routableProps, useRoutable } from '~/composables/useRoutable';
import { sizeProps, useSize } from '~/composables/useSize';
import { colorProps, useColor } from '~/composables/useColor';
import { stateProps, useState } from '~/composables/useState';
import { styleProps, useStyle } from '~/composables/useStyle';
const props = defineProps({
...routableProps,
...classNameProps,
...sizeProps,
...colorProps,
...stateProps,
...styleProps,
});
const { getClassName } = useClassName(props);
const { componentTag, routableClassList } = useRoutable(props);
const { sizeClassList } = useSize(props);
const { colorClassList } = useColor(props);
const { stateClassList } = useState(props);
const { styleClassList } = useStyle(props);
const classList = computed((): TypeClassList => [
routableClassList.value,
sizeClassList.value,
colorClassList.value,
stateClassList.value,
styleClassList.value,
]);
</script>
<template>
<component
:is="componentTag"
v-bind="$attrs"
:class="[getClassName('Button'), classList]"
>
<slot v-bind="props"></slot>
</component>
</template>
<style lang="scss">
@import "src/assets/style/shared/mixins";
.UiButton {
@include reset-button;
display: inline-flex;
align-items: center;
justify-content: center;
text-align: center;
text-decoration: none;
user-select: none;
-webkit-appearance: none;
transition: all .3s ease;
&.--is-disabled,
&.--is-loading {
pointer-events: none;
}
&.--is-interactive {
cursor: pointer;
}
}
</style>