2021-08-18 00:01:11 +02:00
|
|
|
<template>
|
2024-05-04 00:25:30 +02:00
|
|
|
<nuxt-link v-if="to" :to="to" class="abs-btn outline-none rounded-md shadow-md relative border border-gray-600 text-center" :disabled="disabled || loading" :class="classList" @click.native="click">
|
2021-09-21 23:42:01 +02:00
|
|
|
<slot />
|
|
|
|
<div v-if="loading" class="text-white absolute top-0 left-0 w-full h-full flex items-center justify-center text-opacity-100">
|
|
|
|
<svg class="animate-spin" style="width: 24px; height: 24px" viewBox="0 0 24 24">
|
|
|
|
<path fill="currentColor" d="M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z" />
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
</nuxt-link>
|
2023-11-11 18:29:59 +01:00
|
|
|
<button v-else class="abs-btn outline-none rounded-md shadow-md relative border border-gray-600" :disabled="disabled || loading" :type="type" :class="classList" @mousedown.prevent @click="click">
|
2021-08-18 00:01:11 +02:00
|
|
|
<slot />
|
2021-08-21 23:23:35 +02:00
|
|
|
<div v-if="loading" class="text-white absolute top-0 left-0 w-full h-full flex items-center justify-center text-opacity-100">
|
|
|
|
<svg class="animate-spin" style="width: 24px; height: 24px" viewBox="0 0 24 24">
|
|
|
|
<path fill="currentColor" d="M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z" />
|
|
|
|
</svg>
|
|
|
|
</div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2021-09-21 23:42:01 +02:00
|
|
|
to: String,
|
2021-08-18 00:01:11 +02:00
|
|
|
color: {
|
|
|
|
type: String,
|
|
|
|
default: 'primary'
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
paddingX: Number,
|
2022-05-27 02:09:46 +02:00
|
|
|
paddingY: Number,
|
2021-08-21 23:23:35 +02:00
|
|
|
small: Boolean,
|
2021-09-04 21:17:26 +02:00
|
|
|
loading: Boolean,
|
|
|
|
disabled: Boolean
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
classList() {
|
|
|
|
var list = []
|
2021-08-21 23:23:35 +02:00
|
|
|
if (this.loading) list.push('text-opacity-0')
|
2021-08-18 00:01:11 +02:00
|
|
|
list.push('text-white')
|
|
|
|
list.push(`bg-${this.color}`)
|
|
|
|
if (this.small) {
|
|
|
|
list.push('text-sm')
|
|
|
|
if (this.paddingX === undefined) list.push('px-4')
|
2022-05-27 02:09:46 +02:00
|
|
|
if (this.paddingY === undefined) list.push('py-1')
|
2021-08-18 00:01:11 +02:00
|
|
|
} else {
|
|
|
|
if (this.paddingX === undefined) list.push('px-8')
|
2022-05-27 02:09:46 +02:00
|
|
|
if (this.paddingY === undefined) list.push('py-2')
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
if (this.paddingX !== undefined) {
|
|
|
|
list.push(`px-${this.paddingX}`)
|
|
|
|
}
|
2022-05-27 02:09:46 +02:00
|
|
|
if (this.paddingY !== undefined) {
|
|
|
|
list.push(`py-${this.paddingY}`)
|
|
|
|
}
|
2021-10-07 04:08:52 +02:00
|
|
|
if (this.disabled) {
|
|
|
|
list.push('cursor-not-allowed')
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
return list
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
click(e) {
|
|
|
|
this.$emit('click', e)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|