89 lines
1.5 KiB
Vue
89 lines
1.5 KiB
Vue
<template>
|
|
<div class="overlay" @click="close" v-show="visible">
|
|
<div class="popup" @click.stop>
|
|
<div class="popup__header">
|
|
<h2>{{ heading }}</h2>
|
|
<UiButton icon="close" @click="() => close()" class="square"></UiButton>
|
|
</div>
|
|
<div class="popup__body">
|
|
<slot></slot>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
const visible = ref(false);
|
|
|
|
function close() {
|
|
enableScrolling();
|
|
visible.value = false;
|
|
}
|
|
|
|
function open() {
|
|
disableScrolling();
|
|
visible.value = true;
|
|
}
|
|
|
|
defineProps({
|
|
heading: String
|
|
})
|
|
|
|
defineExpose({
|
|
close,
|
|
open
|
|
})
|
|
|
|
function disableScrolling()
|
|
{
|
|
const body = document.getElementsByTagName('body');
|
|
for(const element of body)
|
|
{
|
|
element.style.overflow = "hidden";
|
|
}
|
|
}
|
|
|
|
function enableScrolling()
|
|
{
|
|
const body = document.getElementsByTagName('body');
|
|
for(const element of body)
|
|
{
|
|
element.style.overflow = "visible";
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.overlay {
|
|
background-color: rgba(0, 0, 0, 0.514);
|
|
backdrop-filter: blur(0.1rem);
|
|
position: fixed;
|
|
top: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
padding: 1rem;
|
|
padding: 2rem;
|
|
z-index: 2;
|
|
}
|
|
|
|
.popup {
|
|
display: grid;
|
|
grid-template-rows: auto 1fr;
|
|
align-content: flex-start;
|
|
width: 100%;
|
|
height: 100%;
|
|
padding: 1rem;
|
|
background-color: white;
|
|
}
|
|
|
|
.popup__header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 1rem;
|
|
}
|
|
.popup__body {
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
</style> |