mail/front/src/views/modals/Modal.vue
2023-04-02 16:44:54 +02:00

75 lines
1.4 KiB
Vue

<script setup>
import { vOnClickOutside } from "@vueuse/components";
import { defineEmits, defineProps } from "vue";
const emit = defineEmits(["close-modal"]);
const props = defineProps({ title: String });
// todo close on escape
function close() {
emit("close-modal");
}
</script>
<template>
<div class="modal-wrapper">
<div class="modal" v-on-click-outside="close">
<header class="modal-header">
<h2>{{ props.title }}</h2>
<div class="close-button" @click="close"></div>
</header>
<div class="modal-body">
<slot name="body"> This is the default body! </slot>
</div>
</div>
</div>
</template>
<style scoped>
.modal-wrapper {
display: flex;
align-items: center;
position: fixed;
height: 100%;
width: 100%;
justify-content: center;
left: 0;
top: 0;
z-index: 4000;
background-color: rgba(0, 0, 0, 0.8);
}
.modal {
display: flex;
flex-direction: column;
border-radius: 5px;
color: white;
background-color: #1d1d23;
padding: 20px;
}
.modal-header {
margin-bottom: 10px;
}
h2 {
display: inline-block;
font-size: 2.4rem;
margin: 0;
}
.close-button {
background-color: #9fa9ba;
cursor: pointer;
height: 18px;
mask: url(../../assets/close.svg);
mask-repeat: no-repeat;
mask-size: cover;
width: 18px;
float: right;
margin-top: 5px;
}
</style>