feat: shallow routing

This commit is contained in:
2025-03-19 03:25:58 -04:00
parent 8b494430a5
commit f05e745d05
2 changed files with 42 additions and 2 deletions

View File

@ -2,7 +2,8 @@
import { X } from '@lucide/svelte';
import { Dialog } from 'bits-ui';
import { fade } from 'svelte/transition';
import type { Snippet } from 'svelte';
import { type Snippet } from 'svelte';
import { pushState } from '$app/navigation';
let {
trigger,
@ -17,7 +18,24 @@
} = $props();
</script>
<Dialog.Root bind:open>
<svelte:window
onpopstate={() => {
if (open) {
open = false;
}
}}
/>
<Dialog.Root
bind:open
onOpenChange={(e) => {
if (e) {
pushState('', '#modal');
} else {
history.back();
}
}}
>
<Dialog.Trigger>
{#snippet child({ props })}
{@render trigger(props)}