MapComplete/src/UI/Base/FloatOver.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
Svelte
Raw Normal View History

<script lang="ts">
2023-12-19 23:02:02 +01:00
import { createEventDispatcher } from "svelte"
2024-09-02 00:26:02 +02:00
import { CloseButton } from "flowbite-svelte"
2023-12-19 23:02:02 +01: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 }>()
</script>
2023-12-19 22:08:00 +01:00
<!-- Draw the background over the total screen -->
<div
2025-02-10 02:04:58 +01:00
class="absolute left-0 top-0 h-screen w-screen"
2023-12-19 22:08:00 +01:00
on:click={() => {
2024-06-17 04:27:08 +02:00
console.log("OnClose")
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
/>
<!-- draw a _second_ absolute div, placed using 'bottom' which will be above the navigation bar on mobile browsers -->
2024-06-20 04:21:29 +02:00
<div
class="pointer-events-none absolute bottom-0 right-0 h-full w-screen p-4 md:p-6"
style="z-index: 21"
on:click={() => {
console.log("Closing...")
dispatch("close")
}}
>
<div
2024-09-02 12:48:15 +02:00
class="content normal-background pointer-events-auto relative h-full"
2024-06-20 04:21:29 +02:00
on:click|stopPropagation={() => {}}
>
2023-06-14 20:44:01 +02:00
<div class="h-full rounded-xl">
<slot />
</div>
<slot name="close-button">
<!-- The close button is placed _after_ the default slot in order to always paint it on top -->
2025-02-10 02:04:58 +01:00
<div class="absolute right-0 top-0">
<CloseButton class="normal-background mr-2 mt-2" on:click={() => dispatch("close")} />
2024-07-11 19:01:32 +02:00
</div>
</slot>
</div>
</div>
<style>
2024-09-02 12:48:15 +02:00
.content {
border-radius: 0.5rem;
overflow-x: hidden;
box-shadow: 0 0 1rem #00000088;
}
</style>