Profectus-Demo/src/components/system/Modal.vue

120 lines
2 KiB
Vue
Raw Normal View History

2021-05-22 20:29:06 +00:00
<template>
2021-06-12 05:41:25 +00:00
<portal to="modal-root">
<transition name="modal">
<div class="modal-mask" v-show="show" v-on:pointerdown.self="$emit('close')">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
default header
</slot>
</div>
<perfect-scrollbar class="modal-body">
<branches>
<slot name="body">
default body
</slot>
</branches>
</perfect-scrollbar>
<div class="modal-footer">
<slot name="footer">
<div class="modal-default-footer">
<div class="modal-default-flex-grow"></div>
<button class="button modal-default-button" @click="$emit('close')">
Close
</button>
</div>
2021-06-12 04:38:16 +00:00
</slot>
2021-06-12 05:41:25 +00:00
</div>
2021-05-22 20:29:06 +00:00
</div>
</div>
</div>
2021-06-12 05:41:25 +00:00
</transition>
</portal>
2021-05-22 20:29:06 +00:00
</template>
<script>
export default {
name: 'Modal',
props: {
show: Boolean
}
}
</script>
<style scoped>
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
transition: opacity 0.3s ease;
}
.modal-wrapper {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.modal-container {
2021-06-12 04:38:16 +00:00
width: 640px;
max-width: 95vw;
max-height: 95vh;
2021-05-22 20:29:06 +00:00
background-color: var(--background);
padding: 20px;
border-radius: 5px;
transition: all 0.3s ease;
text-align: left;
border: var(--modal-border);
2021-06-12 04:38:16 +00:00
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.modal-header {
width: 100%;
2021-05-22 20:29:06 +00:00
}
.modal-body {
margin: 20px 0;
2021-06-12 04:38:16 +00:00
width: 100%;
}
.modal-footer {
width: 100%;
2021-05-22 20:29:06 +00:00
}
.modal-default-footer {
display: flex;
}
.modal-default-flex-grow {
flex-grow: 1;
}
.modal-enter {
opacity: 0;
}
.modal-leave-active {
opacity: 0;
}
.modal-enter .modal-container,
.modal-leave-active .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
</style>
2021-06-12 04:38:16 +00:00
<style>
.modal-body > .ps__rail-y {
z-index: 100;
}
</style>