2021-07-17 22:29:12 +03:00
|
|
|
<script>
|
2021-07-22 08:04:48 +03:00
|
|
|
import { afterUpdate } from 'svelte';
|
2021-07-17 22:29:12 +03:00
|
|
|
import CloseButton from '../Buttons/Close/index.svelte';
|
|
|
|
|
|
2021-08-18 19:47:02 +03:00
|
|
|
export let open = false;
|
|
|
|
|
export let onClose = () => {};
|
|
|
|
|
export let modalHeading = '';
|
|
|
|
|
export let width = '';
|
2021-08-26 13:35:56 +03:00
|
|
|
export let maxWidth = '';
|
2021-08-18 19:47:02 +03:00
|
|
|
export let containerClass = '';
|
2023-06-17 19:11:29 +00:00
|
|
|
export let size = '';
|
2021-07-22 08:04:48 +03:00
|
|
|
|
|
|
|
|
afterUpdate(() => {
|
|
|
|
|
if (open) {
|
|
|
|
|
document.getElementsByTagName('body')[0].style.overflow = 'hidden';
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementsByTagName('body')[0].style.overflow = 'auto';
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-07-17 22:29:12 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if open}
|
|
|
|
|
<div
|
2023-05-05 20:19:45 +00:00
|
|
|
class="dialog fixed overflow-x-hidden overflow-y-auto inset-0 flex justify-center items-center z-50 bg-gray-100 dark:bg-gray-700 bg-opacity-50"
|
2021-12-30 22:30:30 +02:00
|
|
|
on:click={onClose}
|
2021-07-17 22:29:12 +03:00
|
|
|
>
|
|
|
|
|
<div aria-hidden="true" class="backdrop" />
|
2021-08-18 19:47:02 +03:00
|
|
|
<div
|
2023-06-17 19:11:29 +00:00
|
|
|
class="{maxWidth || 'container'} {size === 'sm'
|
|
|
|
|
? 'small'
|
|
|
|
|
: ''} bg-white dark:bg-gray-800 mx-auto {width} shadow-lg p-5 pt-2 rounded-md"
|
2021-12-30 22:30:30 +02:00
|
|
|
on:click={(e) => e.stopPropagation()}
|
2021-08-18 19:47:02 +03:00
|
|
|
>
|
2021-07-17 22:29:12 +03:00
|
|
|
<div class="flex items-center justify-between mb-4">
|
2023-05-05 20:19:45 +00:00
|
|
|
<h3 class="dark:text-white text-xl m-0">
|
2021-07-17 22:29:12 +03:00
|
|
|
{modalHeading}
|
|
|
|
|
</h3>
|
|
|
|
|
<CloseButton onClick={onClose} contained={true} />
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-06-17 19:11:29 +00:00
|
|
|
<div class="body p-1 h-4/5 overflow-y-auto {containerClass}">
|
2021-07-22 08:04:48 +03:00
|
|
|
<slot />
|
|
|
|
|
</div>
|
2021-07-17 22:29:12 +03:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.dialog {
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
|
|
|
}
|
2021-08-18 19:47:02 +03:00
|
|
|
|
|
|
|
|
.container {
|
|
|
|
|
max-width: 1000px;
|
|
|
|
|
}
|
2021-07-22 08:04:48 +03:00
|
|
|
.body {
|
|
|
|
|
max-height: 60vh;
|
|
|
|
|
}
|
2023-06-17 19:11:29 +00:00
|
|
|
|
|
|
|
|
.small {
|
|
|
|
|
max-width: 388px;
|
|
|
|
|
}
|
2021-07-17 22:29:12 +03:00
|
|
|
</style>
|