From ae92622578e679bc17d9b175b40b56b3ab56db5a Mon Sep 17 00:00:00 2001 From: Aaron Brethorst Date: Thu, 11 Jul 2024 15:14:21 -0700 Subject: [PATCH 1/2] Extracts a reusable ModalPane component from StopPane --- src/components/navigation/ModalPane.svelte | 41 ++++++++++++++++++++++ src/components/oba/StopPane.svelte | 20 ++--------- src/routes/+page.svelte | 12 +++---- svelte.config.js | 4 ++- 4 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 src/components/navigation/ModalPane.svelte diff --git a/src/components/navigation/ModalPane.svelte b/src/components/navigation/ModalPane.svelte new file mode 100644 index 0000000..f3b829e --- /dev/null +++ b/src/components/navigation/ModalPane.svelte @@ -0,0 +1,41 @@ + + + + + diff --git a/src/components/oba/StopPane.svelte b/src/components/oba/StopPane.svelte index 0c017ab..a235df2 100644 --- a/src/components/oba/StopPane.svelte +++ b/src/components/oba/StopPane.svelte @@ -1,8 +1,4 @@ -
+
{#if loading}
-
+

{stop.name}

Stop #{stop.name}

Routes: {stop.name}

-
- -

diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c3db15b..23df7f8 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,6 +1,6 @@ {#if stop} -
- -
+ + + {/if} diff --git a/svelte.config.js b/svelte.config.js index 1b9bd7f..b5d2a9a 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,4 +1,5 @@ import adapter from '@sveltejs/adapter-auto'; +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; /** @type {import('@sveltejs/kit').Config} */ const config = { @@ -10,7 +11,8 @@ const config = { alias: { $images: './src/assets/images' } - } + }, + preprocess: vitePreprocess() }; export default config; From 9c27ccccb75927c83e910b3dd149e5c9cd192107 Mon Sep 17 00:00:00 2001 From: Aaron Brethorst Date: Thu, 11 Jul 2024 15:36:40 -0700 Subject: [PATCH 2/2] Fills in the stop ID and route list on the stop pane --- src/components/oba/StopPane.svelte | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/oba/StopPane.svelte b/src/components/oba/StopPane.svelte index a235df2..6b5fff7 100644 --- a/src/components/oba/StopPane.svelte +++ b/src/components/oba/StopPane.svelte @@ -5,6 +5,7 @@ let arrivalsAndDepartures; let loading = false; let error; + let routeShortNames = null; async function loadData(stopID) { loading = true; @@ -12,6 +13,10 @@ if (response.ok) { const json = await response.json(); arrivalsAndDepartures = json.data.entry; + routeShortNames = json.data.references.routes + .filter((r) => stop.routeIds.includes(r.id)) + .map((r) => r.nullSafeShortName) + .sort(); } else { error = 'Unable to fetch arrival/departure data'; } @@ -58,8 +63,10 @@

{stop.name}

-

Stop #{stop.name}

-

Routes: {stop.name}

+

Stop #{stop.id}

+ {#if routeShortNames} +

Routes: {routeShortNames.join(', ')}

+ {/if}