From 1f1e215c0cc2432ce5e61f222fd4ee87d4b5b81d Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sun, 10 May 2026 00:26:21 +0100 Subject: [PATCH] Fix layout shifts with the temporary
 element on the
 board page

---
 .../ui/cards/StationAlertCard.svelte          | 205 +++++++++---------
 src/lib/utils/time.ts                         |  54 +++--
 src/routes/board/+page.svelte                 |  96 ++++----
 3 files changed, 180 insertions(+), 175 deletions(-)

diff --git a/src/lib/components/ui/cards/StationAlertCard.svelte b/src/lib/components/ui/cards/StationAlertCard.svelte
index 53287b7..dd72e90 100644
--- a/src/lib/components/ui/cards/StationAlertCard.svelte
+++ b/src/lib/components/ui/cards/StationAlertCard.svelte
@@ -11,8 +11,8 @@
 	
+		{#if isOpen}
+			
+ {#each messages as msg} +
+

+ {msg.t} + {#if msg.l && msg.lt} + + {msg.lt} + + {/if} +

+
+ {/each} +
+ {/if} + {/if} diff --git a/src/lib/utils/time.ts b/src/lib/utils/time.ts index 471e666..890191b 100644 --- a/src/lib/utils/time.ts +++ b/src/lib/utils/time.ts @@ -3,42 +3,50 @@ import type { ApiTrainsTrainDetails } from '@owlboard/owlboard-ts'; * Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds * Ensures Europe/London timezone irrespective of browser timezone. */ -export function formatUkTime(dateStr: string | Date | undefined, includeSeconds: boolean = false): string { +export function formatUkTime( + dateStr: string | Date | undefined, + includeSeconds: boolean = false +): string { if (!dateStr) return '--:--'; const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr; if (isNaN(date.getTime())) return '--:--'; -return date.toLocaleTimeString('en-GB', { - hour: '2-digit', - minute: '2-digit', - ...(includeSeconds && { second: '2-digit' }), - hour12: false, - timeZone: 'Europe/London' - }); + return date.toLocaleTimeString('en-GB', { + hour: '2-digit', + minute: '2-digit', + ...(includeSeconds && { second: '2-digit' }), + hour12: false, + timeZone: 'Europe/London' + }); } /** * Converts ISO/JSON time to UK-formatted DD/MM/YY HH:MM:SS string. * Ensures Europe/London timezone irrespective of browser timezone. */ -export function formatUkDateTime(dateStr: string | Date | undefined, includeSeconds: boolean = false): string { - if (!dateStr) return '--/--/-- --:--:--'; - - const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr; +export function formatUkDateTime( + dateStr: string | Date | undefined, + includeSeconds: boolean = false +): string { + if (!dateStr) return '--/--/-- --:--:--'; - if (isNaN(date.getTime())) return '--/--/-- --:--:--'; + const date = typeof dateStr === 'string' ? new Date(dateStr) : dateStr; - return date.toLocaleString('en-GB', { - day: '2-digit', - month: '2-digit', - year: '2-digit', - hour: '2-digit', - minute: '2-digit', - ...(includeSeconds && { second: '2-digit' }), - hour12: false, - timeZone: 'Europe/London' - }).replace(',', ''); + if (isNaN(date.getTime())) return '--/--/-- --:--:--'; + + return date + .toLocaleString('en-GB', { + day: '2-digit', + month: '2-digit', + year: '2-digit', + hour: '2-digit', + minute: '2-digit', + ...(includeSeconds && { second: '2-digit' }), + hour12: false, + timeZone: 'Europe/London' + }) + .replace(',', ''); } /** diff --git a/src/routes/board/+page.svelte b/src/routes/board/+page.svelte index fb645a0..6d03651 100644 --- a/src/routes/board/+page.svelte +++ b/src/routes/board/+page.svelte @@ -13,7 +13,7 @@ }, 1000); return () => clearInterval(interval); - }) + }); // Update 'QuickLinks' $effect(() => { @@ -33,70 +33,66 @@ // Load Data Invalidation Handling // Refresh countdown logic -
-{#if data.boardData.data.m?.length} - +
+ {#if data.boardData.data.m?.length} + + {/if}
Fetched: {formatUkDateTime(data.boardData.producedAt, true)} {formatUkTime(now, true)}
- -{/if} +
{JSON.stringify(data.boardData.data.s, null, 2)}
-
Live boards are not yet fully implemented on the server
- -
{JSON.stringify(data.boardData.data.s, null, 2)}
-