|
| 1 | +<script setup lang="ts"> |
| 2 | +import { useConfirm } from '@/composables/useConfirm' |
| 3 | +
|
| 4 | +const { visible, title, message, confirmText, cancelText, isAlertMode, onConfirm, onCancel } = useConfirm() |
| 5 | +</script> |
| 6 | + |
| 7 | +<template> |
| 8 | + <Teleport to="body"> |
| 9 | + <Transition name="modal-fade"> |
| 10 | + <div v-if="visible" class="modal-overlay" @click.self="isAlertMode ? onConfirm() : onCancel()"> |
| 11 | + <div class="modal-card" role="dialog" :aria-modal="true" aria-labelledby="confirm-dialog-title"> |
| 12 | + <p v-if="title" id="confirm-dialog-title" class="modal-title">{{ title }}</p> |
| 13 | + <p class="modal-message">{{ message }}</p> |
| 14 | + <div class="modal-actions"> |
| 15 | + <button v-if="!isAlertMode" class="btn-cancel" @click="onCancel">{{ cancelText }}</button> |
| 16 | + <button class="btn-confirm" @click="onConfirm">{{ confirmText }}</button> |
| 17 | + </div> |
| 18 | + </div> |
| 19 | + </div> |
| 20 | + </Transition> |
| 21 | + </Teleport> |
| 22 | +</template> |
| 23 | + |
| 24 | +<style scoped> |
| 25 | +.modal-overlay { |
| 26 | + position: fixed; |
| 27 | + inset: 0; |
| 28 | + background: rgba(0, 0, 0, 0.45); |
| 29 | + display: flex; |
| 30 | + align-items: center; |
| 31 | + justify-content: center; |
| 32 | + z-index: 9999; |
| 33 | +} |
| 34 | +
|
| 35 | +.modal-card { |
| 36 | + background: var(--card-bg); |
| 37 | + border: 1px solid var(--border); |
| 38 | + border-radius: var(--radius); |
| 39 | + box-shadow: var(--shadow-md); |
| 40 | + padding: 24px; |
| 41 | + min-width: 320px; |
| 42 | + max-width: 480px; |
| 43 | + width: 90%; |
| 44 | +} |
| 45 | +
|
| 46 | +.modal-title { |
| 47 | + font-weight: 600; |
| 48 | + font-size: 1rem; |
| 49 | + color: var(--text-primary); |
| 50 | + margin: 0 0 8px 0; |
| 51 | +} |
| 52 | +
|
| 53 | +.modal-message { |
| 54 | + font-size: 0.9rem; |
| 55 | + color: var(--text-secondary); |
| 56 | + margin: 0 0 20px 0; |
| 57 | + line-height: 1.5; |
| 58 | +} |
| 59 | +
|
| 60 | +.modal-actions { |
| 61 | + display: flex; |
| 62 | + justify-content: flex-end; |
| 63 | + gap: 8px; |
| 64 | +} |
| 65 | +
|
| 66 | +.btn-cancel { |
| 67 | + padding: 7px 16px; |
| 68 | + border: 1px solid var(--border); |
| 69 | + border-radius: var(--radius-sm); |
| 70 | + background: transparent; |
| 71 | + color: var(--text-secondary); |
| 72 | + font-size: 0.875rem; |
| 73 | + cursor: pointer; |
| 74 | + transition: background 0.15s; |
| 75 | +} |
| 76 | +.btn-cancel:hover { background: var(--border-light); } |
| 77 | +
|
| 78 | +.btn-confirm { |
| 79 | + padding: 7px 16px; |
| 80 | + border: none; |
| 81 | + border-radius: var(--radius-sm); |
| 82 | + background: var(--primary); |
| 83 | + color: #fff; |
| 84 | + font-size: 0.875rem; |
| 85 | + cursor: pointer; |
| 86 | + transition: background 0.15s; |
| 87 | +} |
| 88 | +.btn-confirm:hover { background: var(--primary-dark); } |
| 89 | +
|
| 90 | +/* Transition */ |
| 91 | +.modal-fade-enter-active, |
| 92 | +.modal-fade-leave-active { |
| 93 | + transition: opacity 0.15s ease; |
| 94 | +} |
| 95 | +.modal-fade-enter-from, |
| 96 | +.modal-fade-leave-to { |
| 97 | + opacity: 0; |
| 98 | +} |
| 99 | +</style> |
0 commit comments