feat(Button): loading-auto (#2198)

This commit is contained in:
Romain Hamel
2024-09-16 11:37:38 +02:00
committed by GitHub
parent 6f20f243fb
commit ed18e74549
15 changed files with 191 additions and 35 deletions

View File

@@ -35,8 +35,8 @@ function onError(event: any) {
:state="state"
:schema="schema"
class="gap-4 flex flex-col w-60"
@submit="(event) => onSubmit(event)"
@error="(event) => onError(event)"
@submit="onSubmit"
@error="onError"
>
<UFormField label="Email" name="email">
<UInput v-model="state.email" placeholder="john@lennon.com" />

View File

@@ -4,6 +4,10 @@ import theme from '#build/ui/button'
const sizes = Object.keys(theme.variants.size) as Array<keyof typeof theme.variants.size>
const variants = Object.keys(theme.variants.variant) as Array<keyof typeof theme.variants.variant>
function onClick() {
return new Promise<void>(res => setTimeout(res, 5000))
}
</script>
<template>
@@ -23,7 +27,7 @@ const variants = Object.keys(theme.variants.variant) as Array<keyof typeof theme
</UButton>
</div>
<div class="flex items-center gap-2">
<UButton loading>
<UButton loading-auto @click="onClick">
Loading
</UButton>
</div>

View File

@@ -25,7 +25,7 @@ function onSubmit(event: FormSubmitEvent<Schema>) {
:state="state"
:schema="schema"
class="gap-4 flex flex-col w-60"
@submit="(event) => onSubmit(event)"
@submit="onSubmit"
>
<UFormField label="Email" name="email">
<UInput v-model="state.email" placeholder="john@lennon.com" />
@@ -51,7 +51,7 @@ function onSubmit(event: FormSubmitEvent<Schema>) {
:schema="schema"
class="gap-4 flex flex-col w-60"
:validate-on-input-delay="2000"
@submit="(event) => onSubmit(event)"
@submit="onSubmit"
>
<UFormField label="Email" name="email">
<UInput v-model="state2.email" placeholder="john@lennon.com" />