Spaces:
Paused
Paused
File size: 1,365 Bytes
83a59ca | 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 | <script setup lang="ts">
const props = withDefaults(
defineProps<{
type?: string
block?: boolean
large?: boolean
xLarge?: boolean
tile?: boolean
text?: boolean
small?: boolean
color?: string
icon?: string | null
loading: boolean
}>(),
{
type: 'submit',
block: false,
large: false,
xLarge: false,
tile: false,
text: false,
small: false,
color: 'primary',
icon: null,
},
)
const emit = defineEmits<{
click: []
'update:loading': [value: boolean]
}>()
const isClicked = ref(false)
watch(
() => props.loading,
(submitting) => {
if (!submitting && isClicked.value) {
isClicked.value = false
}
},
)
function onClick() {
isClicked.value = true
emit('click')
}
const size = computed(() => {
if (props.xLarge) return 'x-large'
if (props.large) return 'large'
if (props.small) return 'small'
return 'default'
})
</script>
<template>
<v-btn
:block="block"
:type="type"
:size="size"
:color="color"
:variant="text ? 'text' : 'elevated'"
:disabled="loading"
@click.prevent="onClick"
>
<v-progress-circular
v-if="isClicked"
:size="small ? 20 : 25"
color="grey"
class="mr-2"
indeterminate
/>
<v-icon v-if="icon && !loading" start :icon="icon" />
<slot />
</v-btn>
</template>
|