Fix layout shifts with the temporary <pre> element on the board page

This commit is contained in:
2026-05-10 00:26:21 +01:00
parent 909e36ebc2
commit 1f1e215c0c
3 changed files with 180 additions and 175 deletions

View File

@@ -46,6 +46,7 @@
background: transparent;
position: relative;
z-index: 10;
margin-bottom: 0;
width: 95%;
max-width: 750px;
}
@@ -112,7 +113,7 @@
filter: brightness(1.2);
color: var(--color-title);
font-family: 'URW Gothic', sans-serif;
font-size: 1.0rem;
font-size: 1rem;
font-weight: 600;
line-height: 1.2;
z-index: 1;

View File

@@ -3,7 +3,10 @@ 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;
@@ -22,14 +25,18 @@ return date.toLocaleTimeString('en-GB', {
* 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 {
export function formatUkDateTime(
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.toLocaleString('en-GB', {
return date
.toLocaleString('en-GB', {
day: '2-digit',
month: '2-digit',
year: '2-digit',
@@ -38,7 +45,8 @@ export function formatUkDateTime(dateStr: string | Date | undefined, includeSeco
...(includeSeconds && { second: '2-digit' }),
hour12: false,
timeZone: 'Europe/London'
}).replace(',', '');
})
.replace(',', '');
}
/**

View File

@@ -13,7 +13,7 @@
}, 1000);
return () => clearInterval(interval);
})
});
// Update 'QuickLinks'
$effect(() => {
@@ -33,21 +33,17 @@
// Load Data Invalidation Handling
// Refresh countdown logic
</script>
<section class="board-wrapper">
{#if data.boardData.data.m?.length}
<StationAlertCard messages={data.boardData.data.m} />
{/if}
<div class="time-data">
<span class="time-loaded">Fetched: {formatUkDateTime(data.boardData.producedAt, true)}</span>
<span class="time-now">{formatUkTime(now, true)}</span>
</div>
{/if}
</section>
<section class="section-t">Live boards are not yet fully implemented on the server</section>
<pre class="json-dump">{JSON.stringify(data.boardData.data.s, null, 2)}</pre>
</section>
<style>
.board-wrapper {
@@ -65,11 +61,12 @@
align-items: center;
width: 90%;
max-width: 700px;
margin: 0 auto;
margin: 10px auto;
font-family: 'URW Gothic', sans-serif;
}
.time-loaded, .time-now {
.time-loaded,
.time-now {
font-variant-numeric: tabular-nums;
}
@@ -81,22 +78,21 @@
font-weight: 600;
font-size: 1rem;
}
.section-t {
font-family: 'URW Gothic', sans-serif;
text-align: center;
font-size: 2rem;
width: 90%;
margin: auto;
padding-top: 25px;
max-width: 500px;
pre {
max-width: 100%;
white-space: pre-wrap;
word-wrap: break-word;
box-sizing: border-box;
overflow-x: auto;
}
.json-dump {
background: #222;
color: #0f0;
padding: 1rem;
border-radius: 4px;
font-size: 0.9rem;
max-height: 500px;
width: 95%;
margin: 1rem auto; }
margin: 1rem auto;
}
</style>