development #1

Merged
luke-else merged 4 commits from development into main 2025-06-18 20:50:12 +00:00
3 changed files with 26 additions and 4 deletions
Showing only changes of commit 215f4a0e2a - Show all commits

3
src/lib/stores/icao.ts Normal file
View File

@ -0,0 +1,3 @@
import { writable } from 'svelte/store';
export const icao = writable('');

View File

@ -5,33 +5,21 @@
import Section from '$lib/components/Section.svelte'; import Section from '$lib/components/Section.svelte';
import Card from '$lib/components/Cards/Card.svelte'; import Card from '$lib/components/Cards/Card.svelte';
import { goto } from '$app/navigation'; import { icao } from '$lib/stores/icao';
let icaoInput = $state<string>('');
// ICAO input state handler
let icao = $state('');
$effect(() => { $effect(() => {
const params = new URLSearchParams(); // Watch for changes to icaoInput and update the store if exactly 4 chars
if (icaoInput.length === 4) {
if (icao.length === 4) { icao.set(icaoInput);
// If the ICAO code is exactly 4 characters long, add it to the URL parameters
if (icao) params.set('icao', icao);
// This will trigger a navigation and reload the page data from the server
goto(`?${params.toString()}`, {
keepFocus: true,
replaceState: true,
noScroll: true
});
} else { } else {
// Otherwise, clear the parameter icao.set('');
goto(`?${params.toString()}`, {
keepFocus: true,
replaceState: true,
noScroll: true
});
} }
}); });
let { children } = $props(); let { children } = $props();
</script> </script>
@ -71,7 +59,7 @@
maxlength="4" maxlength="4"
required required
placeholder="EGKK" placeholder="EGKK"
bind:value={icao} bind:value={icaoInput}
/> />
</div> </div>
</div> </div>

View File

@ -4,14 +4,9 @@
import { toasts } from 'svelte-toasts'; import { toasts } from 'svelte-toasts';
import Loading from '$lib/components/Loading.svelte'; import Loading from '$lib/components/Loading.svelte';
import { page } from '$app/stores'; import { icao } from '$lib/stores/icao';
import { derived } from 'svelte/store';
// Get the ICAO parameter from the URL
const icao = derived(page, ($page) => $page.url.searchParams.get('icao'));
</script> </script>
<div style="display: none;"> <div style="display: none;">
{toasts.add({ {toasts.add({
title: 'Welcome', title: 'Welcome',