examples: add confirm delete example (#1466)

* examples: add confirm delete example

* docs: add confirm delete example
This commit is contained in:
Braks
2024-06-09 13:04:20 +02:00
committed by braks
parent 67da354917
commit 257c7aa704
12 changed files with 339 additions and 1 deletions
+57
View File
@@ -0,0 +1,57 @@
<script setup>
import { useDialogState } from './useDialog.js'
const { isVisible, message, resolve } = useDialogState()
function confirm() {
resolve(true)
isVisible.value = false
}
function cancel() {
resolve(false)
isVisible.value = false
}
</script>
<template>
<div v-if="isVisible" class="dialog-overlay">
<div class="dialog">
<p>{{ message }}</p>
<div class="dialog-actions">
<button @click="confirm">Confirm</button>
<button @click="cancel">Cancel</button>
</div>
</div>
</div>
</template>
<style>
.dialog-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
.dialog {
background: white;
padding: 20px;
border-radius: 5px;
text-align: center;
}
.dialog-actions {
margin-top: 20px;
display: flex;
justify-content: center;
gap: 8px;
}
</style>