ptitlutins/app/components/atoms/Dialog.vue
2025-09-18 04:45:31 +02:00

67 lines
1 KiB
Vue

<template>
<dialog ref="dialog" class="modal">
<h2 class="modal__title">{{ title }}</h2>
<slot></slot>
</dialog>
</template>
<script setup>
const props = defineProps({
open: {
type: Boolean,
required: true,
},
title: {
type: String,
default: '',
},
});
const dialog = useTemplateRef('dialog')
watch(
() => props.open,
(newVal) => {
if (newVal) {
dialog.value.showModal();
} else {
dialog.value.close();
}
},
);
onMounted(() => {
if (props.open) {
dialog.value.showModal();
}
});
</script>
<style>
.modal {
margin: auto;
width: 600px;
max-width: calc(100% - 2rem);
border: 1px solid var(--neutral-20);
box-shadow: var(--shadow-3);
border-radius: 12px;
padding: 1rem;
padding-top: 0px;
background-color: var(--app-background);
&::backdrop {
background-color: transparent;
backdrop-filter: blur(10px);
}
}
.modal__title {
margin-bottom: 1rem;
text-align: center;
margin-top: 1rem;
font-size: 2rem;
}
</style>