Create shared toast store and Toast component mounted in root layout. Wire toast.error() into all fitness API calls that previously failed silently, and replace all alert() calls across recipes and cospend.
25 lines
720 B
Svelte
25 lines
720 B
Svelte
<script>
|
|
import '../app.css';
|
|
import { onNavigate } from '$app/navigation';
|
|
import Toast from '$lib/components/Toast.svelte';
|
|
let { children } = $props();
|
|
|
|
onNavigate((navigation) => {
|
|
if (!(/** @type {any} */ (document)).startViewTransition) return;
|
|
|
|
// Skip if staying within the same route group (recipe layout handles its own)
|
|
const fromGroup = navigation.from?.route.id?.split('/')[1] ?? '';
|
|
const toGroup = navigation.to?.route.id?.split('/')[1] ?? '';
|
|
if (fromGroup === toGroup) return;
|
|
|
|
return new Promise((resolve) => {
|
|
(/** @type {any} */ (document)).startViewTransition(async () => {
|
|
resolve();
|
|
await navigation.complete;
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
|
|
{@render children()}
|
|
<Toast /> |