MapComplete/src/UI/Base/ModalRight.svelte

43 lines
1 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { createEventDispatcher } from "svelte"
import { XCircleIcon } from "@rgossiaux/svelte-heroicons/solid"
import { trapFocus } from "trap-focus-svelte"
/**
* The slotted element will be shown on the right side
*/
const dispatch = createEventDispatcher<{ close }>()
</script>
<div
2023-12-19 23:02:02 +01:00
aria-modal="true"
autofocus
2023-12-21 01:46:18 +01:00
class="normal-background absolute top-0 right-0 flex h-screen w-full flex-col overflow-y-auto drop-shadow-2xl md:w-6/12 lg:w-5/12 xl:w-4/12"
role="dialog"
style="max-width: 100vw; max-height: 100vh"
2023-12-19 23:02:02 +01:00
tabindex="-1"
2024-04-24 02:44:31 +02:00
id="modal-right"
use:trapFocus
>
<slot name="close-button">
<button
class="absolute right-10 top-10 h-8 w-8 cursor-pointer rounded-full"
on:click={() => dispatch("close")}
>
<XCircleIcon />
</button>
</slot>
2023-12-19 23:02:02 +01:00
<div role="document">
<slot />
</div>
</div>
2024-04-24 02:44:31 +02:00
<!-- Experimental support for foldable devices -->
<style lang="scss">
@media (horizontal-viewport-segments: 2) {
#modal-right {
width: 50%;
}
}
</style>