2023-04-16 04:13:09 +02:00
|
|
|
<script lang="ts">
|
2023-12-06 17:27:30 +01:00
|
|
|
import { createEventDispatcher, onMount } from "svelte";
|
|
|
|
import { XCircleIcon } from "@rgossiaux/svelte-heroicons/solid";
|
|
|
|
import { Utils } from "../../Utils";
|
2023-12-07 21:57:20 +01:00
|
|
|
import { trapFocus } from 'trap-focus-svelte'
|
2023-04-16 04:13:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The slotted element will be shown on the right side
|
|
|
|
*/
|
2023-12-06 17:27:30 +01:00
|
|
|
const dispatch = createEventDispatcher<{ close }>();
|
|
|
|
let mainContent: HTMLElement;
|
|
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
window.setTimeout(
|
|
|
|
() => Utils.focusOnFocusableChild(mainContent), 250
|
2023-12-07 21:57:20 +01:00
|
|
|
);
|
|
|
|
});
|
2023-04-16 04:13:09 +02:00
|
|
|
</script>
|
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
<div
|
2023-12-06 17:27:30 +01:00
|
|
|
bind:this={mainContent}
|
2023-12-07 21:57:20 +01:00
|
|
|
use:trapFocus
|
2023-10-15 00:31:04 +02:00
|
|
|
class="absolute top-0 right-0 h-screen w-full overflow-y-auto drop-shadow-2xl md:w-6/12 lg:w-5/12 xl:w-4/12"
|
2023-06-14 20:39:36 +02:00
|
|
|
style="max-width: 100vw; max-height: 100vh"
|
|
|
|
>
|
2023-06-14 20:44:01 +02:00
|
|
|
<div class="normal-background m-0 flex flex-col">
|
2023-04-16 04:13:09 +02:00
|
|
|
<slot name="close-button">
|
2023-12-06 17:27:30 +01:00
|
|
|
<button
|
2023-06-14 20:44:01 +02:00
|
|
|
class="absolute right-10 top-10 h-8 w-8 cursor-pointer"
|
2023-06-14 20:39:36 +02:00
|
|
|
on:click={() => dispatch("close")}
|
|
|
|
>
|
2023-04-16 04:13:09 +02:00
|
|
|
<XCircleIcon />
|
2023-12-06 17:27:30 +01:00
|
|
|
</button>
|
2023-04-16 04:13:09 +02:00
|
|
|
</slot>
|
2023-06-14 20:39:36 +02:00
|
|
|
<slot />
|
2023-04-16 04:13:09 +02:00
|
|
|
</div>
|
|
|
|
</div>
|