Skip to content

Commit

Permalink
feat(Modal): Improve programmatic example
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD committed Jan 17, 2025
1 parent 3af77cc commit 0945a18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion docs/app/components/content/examples/modal/ModalExample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ const modal = useModal()
defineProps<{
count: number
}>()
const emit = defineEmits(['success'])
function onSuccess() {
emit('success')
}
</script>

<template>
<UModal :title="`This modal was opened programmatically ${count} times`">
<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>
</UModal>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ import { LazyModalExample } from '#components'
const count = ref(0)
const toast = useToast()
const modal = useModal()
function open() {
count.value++
modal.open(LazyModalExample, {
description: 'And you can even provide a description!',
count: count.value
count: count.value,
onSuccess() {
toast.add({
title: 'Success !',
id: 'modal-success'
})
}
})
}
</script>
Expand Down

0 comments on commit 0945a18

Please sign in to comment.