<template>
<div
v-if="isOpen"
class="modal-overlay"
@click="handleOverlayClick"
>
<div
class="modal-content"
@click.stop
>
<h2 class="modal-title">
{{ title }}
</h2>
<p class="modal-message">
{{ message }}
</p>
<div class="modal-actions">
<button
class="btn-cancel"
@click="handleCancel"
>
Cancel
</button>
<button
class="btn-confirm"
@click="handleConfirm"
>
Confirm
</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
interface Props {
isOpen: boolean;
title: string;
message: string;
}
defineProps<Props>();
const emit = defineEmits<{
confirm: [];
cancel: [];
}>();
function handleConfirm() {
emit('confirm');
}
function handleCancel() {
emit('cancel');
}
function handleOverlayClick() {
emit('cancel');
}
</script>
<style scoped>
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 2000;
}
.modal-content {
background-color: white;
border-radius: 0.5rem;
padding: 1.5rem;
min-width: 300px;
max-width: 500px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.modal-title {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 0.75rem;
color: #1f2937;
}
.modal-message {
font-size: 0.875rem;
color: #6b7280;
margin-bottom: 1.5rem;
line-height: 1.5;
}
.modal-actions {
display: flex;
gap: 0.5rem;
justify-content: flex-end;
}
.btn-cancel,
.btn-confirm {
padding: 0.5rem 1rem;
border-radius: 0.25rem;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.15s;
border: 1px solid transparent;
}
.btn-cancel {
background-color: #f3f4f6;
color: #374151;
}
.btn-cancel:hover {
background-color: #e5e7eb;
}
.btn-confirm {
background-color: #ef4444;
color: white;
border-color: #ef4444;
}
.btn-confirm:hover {
background-color: #dc2626;
border-color: #dc2626;
}
</style>