2023-04-02 02:59:20 +02:00
|
|
|
<script lang="ts">
|
2023-12-06 17:27:30 +01:00
|
|
|
import { createEventDispatcher, onMount } from "svelte";
|
2023-06-14 20:39:36 +02:00
|
|
|
import { XCircleIcon } from "@rgossiaux/svelte-heroicons/solid"
|
2023-12-05 18:35:18 +01:00
|
|
|
import { twMerge } from "tailwind-merge"
|
2023-04-06 01:33:08 +02:00
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
/**
|
|
|
|
* The slotted element will be shown on top, with a lower-opacity border
|
|
|
|
*/
|
|
|
|
const dispatch = createEventDispatcher<{ close }>()
|
2023-12-05 18:35:18 +01:00
|
|
|
|
|
|
|
export let extraClasses = "p-4 md:p-6"
|
2023-12-06 17:27:30 +01:00
|
|
|
|
|
|
|
let mainContent: HTMLElement
|
|
|
|
onMount(() => {
|
|
|
|
console.log("Mounting floatover")
|
|
|
|
mainContent?.focus()
|
|
|
|
})
|
2023-04-02 02:59:20 +02:00
|
|
|
</script>
|
|
|
|
|
2023-06-14 20:39:36 +02:00
|
|
|
<div
|
2023-12-05 18:35:18 +01:00
|
|
|
class={twMerge("absolute top-0 right-0 h-screen w-screen", extraClasses)}
|
2023-10-25 00:03:51 +02:00
|
|
|
style="background-color: #00000088; z-index: 20"
|
2023-10-16 14:27:05 +02:00
|
|
|
on:click={() => {
|
|
|
|
dispatch("close")
|
|
|
|
}}
|
2023-06-14 20:39:36 +02:00
|
|
|
>
|
2023-12-06 17:27:30 +01:00
|
|
|
<div bind:this={mainContent} 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 -->
|
|
|
|
<div
|
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")}
|
|
|
|
>
|
|
|
|
<XCircleIcon />
|
|
|
|
</div>
|
|
|
|
</slot>
|
|
|
|
</div>
|
2023-04-02 02:59:20 +02:00
|
|
|
</div>
|
2023-05-07 23:19:30 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.content {
|
2023-12-05 18:35:18 +01:00
|
|
|
height: 100%;
|
2023-05-07 23:19:30 +02:00
|
|
|
border-radius: 0.5rem;
|
2023-12-05 18:35:18 +01:00
|
|
|
overflow-x: hidden;
|
2023-05-07 23:19:30 +02:00
|
|
|
box-shadow: 0 0 1rem #00000088;
|
|
|
|
}
|
|
|
|
</style>
|