MapComplete/src/UI/Base/DrawerRight.svelte

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

58 lines
1.5 KiB
Svelte
Raw Normal View History

2024-08-30 02:18:29 +02:00
<script lang="ts">
import { Drawer } from "flowbite-svelte"
import { sineIn } from "svelte/easing"
import { Store } from "../../Logic/UIEventSource.js"
import { onMount } from "svelte"
2025-07-18 14:15:37 +02:00
import { AndroidPolyfill } from "../../Logic/Web/AndroidPolyfill"
import InsetSpacer from "./InsetSpacer.svelte"
2024-08-30 02:18:29 +02:00
export let shown: Store<boolean>
let transitionParams = {
x: 640,
duration: 200,
2024-10-19 14:44:55 +02:00
easing: sineIn,
2024-08-30 02:18:29 +02:00
}
let hidden = !shown.data
2024-10-19 14:44:55 +02:00
shown.addCallback((sh) => {
2024-08-30 02:18:29 +02:00
hidden = !sh
})
2025-07-18 14:15:37 +02:00
// Does not need a 'top-inset-spacer' as the code below will apply the padding automatically
2024-08-30 02:18:29 +02:00
let height = 0
2025-07-18 14:15:37 +02:00
function setHeight(){
2024-08-30 02:18:29 +02:00
let topbar = document.getElementById("top-bar")
2025-07-18 14:15:37 +02:00
height = (topbar?.clientHeight ?? 0) + AndroidPolyfill.getInsetSizes().top.data
}
onMount(() => setHeight())
AndroidPolyfill.getInsetSizes().top.addCallback(() => setHeight())
2024-08-30 02:18:29 +02:00
</script>
2024-10-19 14:44:55 +02:00
<Drawer
placement="right"
transitionType="fly"
{transitionParams}
activateClickOutside={false}
divClass="overflow-y-auto z-3"
backdrop={false}
id="drawer-right"
width="w-full sm:w-80 md:w-96"
rightOffset="inset-y-0 right-0"
bind:hidden
>
2025-07-18 14:15:37 +02:00
<div class="flex flex-col h-full">
<div class="low-interaction h-screen">
2025-07-18 14:15:37 +02:00
<div style={`padding-top: ${height}px`}>
2024-10-19 14:44:55 +02:00
<div class="flex h-full flex-col overflow-y-auto">
2024-08-30 02:18:29 +02:00
<slot />
</div>
</div>
</div>
2025-07-18 14:15:37 +02:00
<InsetSpacer clss="low-interaction" height={AndroidPolyfill.getInsetSizes().bottom}/>
</div>
2024-08-30 02:18:29 +02:00
</Drawer>