diff --git a/src/lib/components/ui/station-board/StaffServicesGrid.svelte b/src/lib/components/ui/station-board/StaffServicesGrid.svelte index 2ed0088..e4800d9 100644 --- a/src/lib/components/ui/station-board/StaffServicesGrid.svelte +++ b/src/lib/components/ui/station-board/StaffServicesGrid.svelte @@ -1,6 +1,6 @@
-
+
Arr
@@ -36,9 +36,14 @@
-
+
{service.h}
{#key service.og.t} @@ -50,7 +55,7 @@
{#key service.dt.t}
{service.dt.t}
{/key}
-
+
{#key service.p}
{service.p || '-'}
{/key}
{#if service.wtp} @@ -58,35 +63,47 @@
{formatUkTime(service.wtp)}
-
- {#key realPass} -
- {realPass} -
- {/key} +
+ {#if isRightTime(service.wtp, service.atp || service.etp)} + RT + {:else if service.c} + CANC + {:else} + {realPass} + {/if}
{:else}
{formatUkTime(service.sta)}
-
- {#key realArrival} -
- {realArrival} -
- {/key} +
+ {#if isRightTime(service.sta, service.ata || service.eta)} + RT + {:else if service.sta && service.c} CAN {:else} + {realArrival} + {/if}
{formatUkTime(service.std)}
-
- {#key realDeparture} -
- {realDeparture} -
- {/key} +
+ {#if isRightTime(service.std, service.atd || service.etd)} + RT + {:else if service.std && service.c} CANC {:else} + {realDeparture} + {/if}
{/if}
{service.o}
{#if service?.cr?.r} -
{service.cr.r}
+ {#if service.c} +
{service.cr.r}
+ {:else} +
+ Part of this service has been cancelled +
+ {/if} {:else if service?.dr?.r}
{service.dr.r}
{/if} @@ -104,6 +121,13 @@ overflow: hidden; } + .header.container { + position: sticky; + top: 0; + z-index: 2; + background: var(--color-bg-dark); + } + .row.header { font-weight: 875; } @@ -131,6 +155,17 @@ font-variant-ligatures: additional-ligatures; } + .service.row.passing { + font-style: italic; + opacity: 0.25; + font-weight: 200; + } + + .service.row.nonPax { + opacity: 0.25; + font-weight: 200; + } + .service-block { width: 100%; max-width: 100%; @@ -142,52 +177,11 @@ width: 100%; } - .departure-board td { - font-family: 'Inconsolata Variable', monospace; - font-size: clamp(1rem, 0.475rem + 2.8vw, 1.35rem); - font-variant-ligatures: additional-ligatures; - overflow: hidden; - } - - thead, - .cancel-row td, - .delay-row td { - letter-spacing: -0.15ch; - } - - thead { - position: sticky; - top: 0; - z-index: 2; - background: var(--color-bg-dark); - } - - abbr { - text-decoration: none; - border-bottom: none; - cursor: help; - } - - tbody tr:first-child td { - border-top: 5px solid transparent; - } - /* Row Logic */ - .serviceCancelled { + .service.cancelled { color: rgb(255, 131, 131); } - .servicePass td { - opacity: 0.75; - font-weight: 200; - } - - .serviceNonPassenger td { - opacity: 0.5; - font-weight: 290; - font-style: italic; - } - /* Special Row Styles */ .operator.row, .delay-reason.row, @@ -200,11 +194,13 @@ .cancel-reason.row { color: rgb(255, 131, 131); font-weight: 400; + letter-spacing: -0.1ch; } .delay-reason.row { color: var(--delay-orange); - font-style: italic; + font-weight: 400; + letter-spacing: -0.1ch; } @media (min-width: 375px) { .operator.row, @@ -314,16 +310,12 @@ font-stretch: 110%; } } - .cell.plt.platSup { - font-weight: 200; - opacity: 0.3; + .cell.plt.platsup { + font-weight: 150; } - .cell.plt.platChange { + .cell.plt.platchange { animation: fast-pulse 2s ease-out infinite; } - .service-row.serviceCancelled .plt-cell { - text-decoration: line-through; - } .pass-cell { text-align: center; font-stretch: 100%; @@ -343,6 +335,12 @@ text-align: center; font-stretch: 72%; } + .cell.act.delay-late { + color: var(--delay-orange); + } + .cell.act.delay-early { + color: var(--early-blue); + } @media (min-width: 350px) { .cell.sch, .cell.act { @@ -367,21 +365,10 @@ font-stretch: 100%; } } - - /* RT Logic */ - .time-cell.delay-rt span { - display: none; - } - .time-cell.delay-rt::after { - content: 'RT'; - } - - .time-cell.delay-early { - color: var(--early-blue); - } - - .time-cell.delay-late { - color: var(--delay-orange); + .cell.act.est { + font-style: italic; + font-weight: 300; + opacity: 0.5; } /* Time Types */ @@ -390,7 +377,7 @@ opacity: 0.75; font-weight: 350; } - .cell.act { + .cell.act.actual { font-weight: 600; } diff --git a/src/lib/utils/time.ts b/src/lib/utils/time.ts index dd48a3e..219c0df 100644 --- a/src/lib/utils/time.ts +++ b/src/lib/utils/time.ts @@ -1,6 +1,6 @@ import type { ApiTrainsTrainDetails } from '@owlboard/owlboard-ts'; -export const estClass = (act: any, est: any) => (act ? 'act' : 'est'); +export const estClass = (act: any, est: any) => (act ? 'actual' : 'estimate'); /** * Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds @@ -132,3 +132,23 @@ export function delayClassFromTimePair(sched: any, act: any): string { return diff > 0 ? 'delay-late' : 'delay-early'; } + +/** + * Accepts a pair of times (string or Date) and returns true if service considered 'on-time' + * @param sched Scheduled Time (string, Date) + * @param act Actual Time (string, Date) + */ +export function isRightTime( + sched: string | Date | undefined, + act: string | Date | undefined +): boolean { + console.log(`Checking [sched: ${sched}, act: ${act}]`); + if (!sched || !act) return false; + + const s = new Date(sched).getTime(); + const a = new Date(act).getTime(); + + if (isNaN(s) || isNaN(a)) return false; + + return Math.abs(a - s) < 60000; +} diff --git a/src/routes/board/+page.svelte b/src/routes/board/+page.svelte index 76fb8a7..31651a2 100644 --- a/src/routes/board/+page.svelte +++ b/src/routes/board/+page.svelte @@ -130,6 +130,10 @@
+ {:else} +
+ No services at this location in the next three hours +
{/if}
@@ -145,6 +149,13 @@ gap: 0; } + .no-service { + display: block; + margin: auto; + max-width: 75%; + font-family: 'URW Gothic', sans-serif; + } + .time-data { display: flex; justify-content: space-between;