more fluent texts

This commit is contained in:
Vincent van der Wal
2026-08-01 15:27:26 +02:00
parent 774afa6c65
commit 0d5dbbc61f
18 changed files with 694 additions and 201 deletions
@@ -2,8 +2,14 @@
import { onMount } from 'svelte';
import { get } from 'svelte/store';
import { page } from '$app/stores';
import { storedEnsembleModel, storedLocation, storedUnits } from '$lib/stores/settings';
import { reportPageReady } from '$lib/stores/page-transition.svelte';
import { syncSearchParams } from '$lib/utils/url-state';
import { ChartContainer, ChartToolbar } from '$lib/components/charts';
import { Label } from '$lib/components/ui/label';
import { Switch } from '$lib/components/ui/switch';
@@ -38,6 +44,9 @@
let { data }: { data: PageData } = $props();
// the page cross-fade waits for this before revealing the new page
reportPageReady(() => fetchedData != null);
useHeroActions(heroActions);
// the URL is the source of truth: location comes from the load function,
@@ -76,11 +85,19 @@
// ─── Lifecycle ──────────────────────────────────────────────────────────────
onMount(() => {
// preselect the persisted ensemble model (client-only, keeps SSR stable)
params.models = [get(storedEnsembleModel)];
// a shared link carries its model; otherwise fall back to the stored choice
const fromUrl = get(page).url.searchParams.get('model');
params.models = [fromUrl || get(storedEnsembleModel)];
mounted = true;
});
// keep the plotted ensemble in the URL
$effect(() => {
const model = params.models?.[0];
if (!mounted || !model) return;
syncSearchParams($page.url, { model });
});
// components persist across refetches; entries are null while unmounted
let liveCharts = $derived(chartComponents.filter((chart) => chart != null));