2024-07-04 16:55:57 +01:00
|
|
|
<script>
|
2024-07-05 14:51:32 +01:00
|
|
|
import { beforeUpdate } from "svelte";
|
2024-07-04 16:55:57 +01:00
|
|
|
export let visible = true;
|
|
|
|
export let centered = false;
|
|
|
|
|
2024-07-05 14:51:32 +01:00
|
|
|
beforeUpdate(() => {
|
|
|
|
// disable scrolling hack: this has to be on body
|
|
|
|
if(visible) {
|
|
|
|
document.body.style.overflowY = "hidden";
|
|
|
|
} else {
|
|
|
|
document.body.style.overflowY = "scroll";
|
|
|
|
}
|
|
|
|
})
|
2024-07-04 16:55:57 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if visible}
|
|
|
|
<div class="overlay" on:click={() => visible = !visible}></div>
|
|
|
|
<div class="container">
|
|
|
|
<div class="modal" class:modal-top={!centered} class:modal-center={centered}>
|
|
|
|
<slot/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.container {
|
|
|
|
z-index: 101;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
position: absolute;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal {
|
|
|
|
background-color: var(--bg-800);
|
|
|
|
z-index: 101;
|
|
|
|
|
|
|
|
padding: 16px;
|
|
|
|
width: 732px;
|
|
|
|
border-radius: 8px;
|
|
|
|
box-shadow: 0px 16px 64px 4px rgba(0,0,0,0.5);
|
|
|
|
animation: modal_pop_up .15s cubic-bezier(0.22, 1, 0.36, 1);
|
|
|
|
height: fit-content;
|
2024-07-05 14:51:32 +01:00
|
|
|
|
|
|
|
pointer-events: all;
|
2024-07-04 16:55:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.overlay {
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vw;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 100;
|
|
|
|
|
2025-01-19 21:54:07 +00:00
|
|
|
background-color: rgba(0,0,0,0.5);
|
|
|
|
backdrop-filter: blur(10px) saturate(1.25);
|
2024-07-04 16:55:57 +01:00
|
|
|
user-select: none;
|
|
|
|
|
|
|
|
animation: modal_bg .15s cubic-bezier(0.22, 1, 0.36, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal-top {
|
|
|
|
margin-top: 8em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal-center {
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes modal_bg {
|
|
|
|
from {
|
|
|
|
background-color: rgba(0,0,0,0);
|
|
|
|
backdrop-filter: blur(0px) saturate(1.0);
|
|
|
|
}
|
2025-01-19 21:54:07 +00:00
|
|
|
/*
|
2024-07-04 16:55:57 +01:00
|
|
|
to {
|
2025-01-19 21:54:07 +00:00
|
|
|
background-color: rgba(0,0,0,0.5);
|
|
|
|
backdrop-filter: blur(10px) saturate(1.25);
|
2024-07-04 16:55:57 +01:00
|
|
|
}
|
2025-01-19 21:54:07 +00:00
|
|
|
*/
|
2024-07-04 16:55:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes modal_pop_up {
|
|
|
|
from {
|
2024-07-05 14:51:32 +01:00
|
|
|
opacity: 0%;
|
2024-07-04 16:55:57 +01:00
|
|
|
transform: translateY(16px) scale(0.95);
|
|
|
|
}
|
|
|
|
|
|
|
|
to {
|
2024-07-05 14:51:32 +01:00
|
|
|
opacity: 100%;
|
2024-07-04 16:55:57 +01:00
|
|
|
transform: translateY(0px) scale(1);
|
|
|
|
}
|
|
|
|
}
|
2025-01-19 21:54:07 +00:00
|
|
|
</style>
|