2023-04-02 02:59:20 +02:00
|
|
|
<script lang="ts">
|
2023-12-19 23:02:02 +01:00
|
|
|
import { createEventDispatcher } from "svelte"
|
2023-12-19 22:08:00 +01:00
|
|
|
import { XCircleIcon } from "@rgossiaux/svelte-heroicons/solid"
|
|
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
import { trapFocus } from "trap-focus-svelte"
|
2023-12-19 23:02:02 +01:00
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
/**
|
|
|
|
* The slotted element will be shown on top, with a lower-opacity border
|
|
|
|
*/
|
2023-12-19 22:08:00 +01:00
|
|
|
const dispatch = createEventDispatcher<{ close }>()
|
2023-12-07 21:57:20 +01:00
|
|
|
|
2023-12-19 22:08:00 +01:00
|
|
|
export let extraClasses = "p-4 md:p-6"
|
2023-12-07 21:57:20 +01:00
|
|
|
|
2023-04-02 02:59:20 +02:00
|
|
|
</script>
|
|
|
|
|
2023-12-19 22:08:00 +01:00
|
|
|
<!-- Draw the background over the total screen -->
|
|
|
|
<div
|
|
|
|
class="absolute top-0 left-0 h-screen w-screen"
|
|
|
|
on:click={() => {
|
2023-10-16 14:27:05 +02:00
|
|
|
dispatch("close")
|
2023-12-19 22:08:00 +01:00
|
|
|
}}
|
2023-12-19 23:02:02 +01:00
|
|
|
style="background-color: #00000088; z-index: 20"
|
2023-12-19 22:08:00 +01:00
|
|
|
/>
|
2023-12-07 21:57:20 +01:00
|
|
|
<!-- draw a _second_ absolute div, placed using 'bottom' which will be above the navigation bar on mobile browsers -->
|
|
|
|
<div
|
|
|
|
class={twMerge("absolute bottom-0 right-0 h-full w-screen", extraClasses)}
|
|
|
|
style="z-index: 21"
|
2023-12-19 23:02:02 +01:00
|
|
|
use:trapFocus
|
2023-06-14 20:39:36 +02:00
|
|
|
>
|
2023-12-19 22:08:00 +01:00
|
|
|
<div
|
|
|
|
class="content normal-background"
|
|
|
|
on:click|stopPropagation={() => {}}
|
|
|
|
>
|
2023-06-14 20:44:01 +02:00
|
|
|
<div class="h-full rounded-xl">
|
2023-06-14 20:39:36 +02:00
|
|
|
<slot />
|
2023-05-07 23:19:30 +02:00
|
|
|
</div>
|
2023-06-14 20:39:36 +02:00
|
|
|
<slot name="close-button">
|
|
|
|
<!-- The close button is placed _after_ the default slot in order to always paint it on top -->
|
2023-12-07 21:57:20 +01:00
|
|
|
<button
|
2023-12-20 02:50:08 +01:00
|
|
|
class="absolute right-10 top-10 h-8 w-8 cursor-pointer border-none bg-white rounded-full p-0"
|
2023-06-14 20:39:36 +02:00
|
|
|
on:click={() => dispatch("close")}
|
|
|
|
>
|
|
|
|
<XCircleIcon />
|
2023-12-07 21:57:20 +01:00
|
|
|
</button>
|
2023-06-14 20:39:36 +02:00
|
|
|
</slot>
|
|
|
|
</div>
|
2023-04-02 02:59:20 +02:00
|
|
|
</div>
|
2023-05-07 23:19:30 +02:00
|
|
|
|
|
|
|
<style>
|
2023-12-07 21:57:20 +01:00
|
|
|
.content {
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 0.5rem;
|
|
|
|
overflow-x: hidden;
|
|
|
|
box-shadow: 0 0 1rem #00000088;
|
|
|
|
}
|
2023-05-07 23:19:30 +02:00
|
|
|
</style>
|