create button components - incomplete

This commit is contained in:
kur0nek-o
2023-10-17 20:59:59 +07:00
parent 7c6a28b98d
commit df01b11675
5 changed files with 75 additions and 4 deletions

54
src/components/Button.vue Normal file
View File

@ -0,0 +1,54 @@
<script setup lang="ts">
import { computed } from 'vue';
const props = defineProps({
type: {
type: String as () => "button" | "submit" | "reset",
default: "button",
},
onClick: {
type: Function as unknown as () => (payload: MouseEvent) => void,
default: () => { },
},
label: {
type: String,
default: "",
},
disabled: {
type: Boolean,
default: false,
},
isLoading: {
type: Boolean,
default: false,
},
className: {
type: String,
default: "",
},
styleType: {
type: String as () => "filled" | "secondary" | "outline" | "text",
default: "filled"
}
});
const buttonStyle = computed(() => {
if (props.styleType == 'filled') {
return 'hello'
}
})
</script>
<template>
<button :type="type" @click="onClick" :disabled="disabled"
:class="['px-4 py-2 mt-2 text-sm font-bold text-white border-transparent rounded-lg bg-primary-500 focus:outline-0 disabled:bg-primary-400', className]">
<slot></slot>
<span v-if="!isLoading">{{ label }}</span>
<span v-else>
<center>
<lottie-player autoplay loop mode="normal" src="https://assets2.lottiefiles.com/packages/lf20_lNbR6W7kY6.json"
style="height:1.2rem"></lottie-player>
</center>
</span>
</button>
</template>