mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-03 21:57:58 +01:00
docs(modal/slideover): improve programmatic examples (#3131)
This commit is contained in:
@@ -4,12 +4,21 @@ const modal = useModal()
|
|||||||
defineProps<{
|
defineProps<{
|
||||||
count: number
|
count: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
|
||||||
|
function onSuccess() {
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UModal :title="`This modal was opened programmatically ${count} times`">
|
<UModal :title="`This modal was opened programmatically ${count} times`">
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<UButton color="neutral" label="Close" @click="modal.close()" />
|
<div class="flex gap-2">
|
||||||
|
<UButton color="neutral" label="Close" @click="modal.close()" />
|
||||||
|
<UButton label="Success" @click="onSuccess" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</UModal>
|
</UModal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { LazyModalExample } from '#components'
|
|||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
|
const toast = useToast()
|
||||||
const modal = useModal()
|
const modal = useModal()
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
@@ -10,7 +11,13 @@ function open() {
|
|||||||
|
|
||||||
modal.open(LazyModalExample, {
|
modal.open(LazyModalExample, {
|
||||||
description: 'And you can even provide a description!',
|
description: 'And you can even provide a description!',
|
||||||
count: count.value
|
count: count.value,
|
||||||
|
onSuccess() {
|
||||||
|
toast.add({
|
||||||
|
title: 'Success !',
|
||||||
|
id: 'modal-success'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ const slideover = useSlideover()
|
|||||||
defineProps<{
|
defineProps<{
|
||||||
count: number
|
count: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
|
||||||
|
function onSuccess() {
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -13,7 +19,10 @@ defineProps<{
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<UButton color="neutral" label="Close" @click="slideover.close()" />
|
<div class="flex gap-2">
|
||||||
|
<UButton color="neutral" label="Close" @click="slideover.close()" />
|
||||||
|
<UButton label="Success" @click="onSuccess" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</USlideover>
|
</USlideover>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { LazySlideoverExample } from '#components'
|
|||||||
|
|
||||||
const count = ref(0)
|
const count = ref(0)
|
||||||
|
|
||||||
|
const toast = useToast()
|
||||||
const slideover = useSlideover()
|
const slideover = useSlideover()
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
@@ -10,7 +11,13 @@ function open() {
|
|||||||
|
|
||||||
slideover.open(LazySlideoverExample, {
|
slideover.open(LazySlideoverExample, {
|
||||||
title: 'Slideover',
|
title: 'Slideover',
|
||||||
count: count.value
|
count: count.value,
|
||||||
|
onSuccess() {
|
||||||
|
toast.add({
|
||||||
|
title: 'Success !',
|
||||||
|
id: 'modal-success'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user