Switch departure board to use Inconsolata monospaced font (varying widths, weights, etc.)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { ApiStationsBoard } from '@owlboard/owlboard-ts';
|
||||
import { formatUkTime, estClass, delayClassFromTimePair } from '$lib/utils/time';
|
||||
import { formatUkTime, estClass, delayClassFromTimePair } from '$lib/utils/time';
|
||||
|
||||
let { services }: { services: ApiStationsBoard.BoardService[] } = $props();
|
||||
|
||||
@@ -8,141 +8,263 @@
|
||||
`${s.r}${s.sta ?? ''}${s.std ?? ''}${s.wtp ?? ''}`;
|
||||
</script>
|
||||
|
||||
<table class="departure-board">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" aria-hidden="true"></th>
|
||||
<th scope="colgroup" colspan="2" class="upper-head"><abbr title="Arrival">Arr</abbr></th>
|
||||
<th scope="colgroup" colspan="2" class="upper-head"><abbr title="Departure">Dep</abbr></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><abbr title="Headcode">ID</abbr></th>
|
||||
<th scope="col"><abbr title="Origin">Orig</abbr></th>
|
||||
<th scope="col"><abbr title="Destination">Dest</abbr></th>
|
||||
<th scope="col"><abbr title="Platform">Plt</abbr></th>
|
||||
<th scope="col"><abbr title="Scheduled">Sch</abbr></th>
|
||||
<th scope="col"><abbr title="Actual/Expected">Act</abbr></th>
|
||||
<th scope="col"><abbr title="Scheduled">Sch</abbr></th>
|
||||
<th scope="col"><abbr title="Actual/Expected">Act</abbr></th>
|
||||
<table class="departure-board">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" aria-hidden="true"></th>
|
||||
<th scope="colgroup" colspan="2" class="upper-head"><abbr title="Arrival">Arr</abbr></th>
|
||||
<th scope="colgroup" colspan="2" class="upper-head"><abbr title="Departure">Dep</abbr></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><abbr title="Headcode">ID</abbr></th>
|
||||
<th scope="col"><abbr title="Origin">Orig</abbr></th>
|
||||
<th scope="col"><abbr title="Destination">Dest</abbr></th>
|
||||
<th scope="col"><abbr title="Platform">Plt</abbr></th>
|
||||
<th scope="col"><abbr title="Scheduled">Sch</abbr></th>
|
||||
<th scope="col"><abbr title="Actual/Expected">Act</abbr></th>
|
||||
<th scope="col"><abbr title="Scheduled">Sch</abbr></th>
|
||||
<th scope="col"><abbr title="Actual/Expected">Act</abbr></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
{#each services as service (getRowKey(service))}
|
||||
<tbody>
|
||||
<tr class="service-row" class:serviceCancelled={service.c} class:servicePass={service.wtp} class:serviceNonPassenger={!service.ip}>
|
||||
<td class="id-cell">{service.h}</td>
|
||||
<td class="orig-cell"><abbr title={service.og.n.toLocaleUpperCase()}>{service.og.t}</abbr></td>
|
||||
<td class="dest-cell"><abbr title={service.dt.n.toLocaleUpperCase()}>{service.dt.t}</abbr></td>
|
||||
<td class="plt-cell" class:platSup={service.ps} class:platChange={service.pc}
|
||||
>{service.p || '-'}</td
|
||||
>
|
||||
|
||||
<!-- Handle different display for a passing train -->
|
||||
{#if service.wtp}
|
||||
<td class="pass-cell" colspan="2">Pass</td>
|
||||
<td class="time-cell">{formatUkTime(service.wtp)}</td>
|
||||
<!-- If cancelled, show '-', otherwise check for RT or show time -->
|
||||
<td
|
||||
class="time-cell {estClass(service.atp, service.etp)} {delayClassFromTimePair(
|
||||
service.wtp,
|
||||
service.atp || service.etp
|
||||
)}"
|
||||
>
|
||||
<span>
|
||||
{service.c
|
||||
? '-'
|
||||
: delayClassFromTimePair(service.wtp, service.atp || service.etp) === 'delay-rt'
|
||||
? 'RT'
|
||||
: formatUkTime(service.atp || service.etp)}
|
||||
</span>
|
||||
</td>
|
||||
{:else}
|
||||
<td class="time-cell">{formatUkTime(service.sta)}</td>
|
||||
|
||||
<!-- Arrival Actual/Expected -->
|
||||
<td
|
||||
class="time-cell {estClass(service.ata, service.eta)} {delayClassFromTimePair(
|
||||
service.sta,
|
||||
service.ata || service.eta
|
||||
)}"
|
||||
>
|
||||
<span>
|
||||
{service.c
|
||||
? '-'
|
||||
: delayClassFromTimePair(service.sta, service.ata || service.eta) === 'delay-rt'
|
||||
? 'RT'
|
||||
: formatUkTime(service.ata || service.eta)}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="time-cell">{formatUkTime(service.std)}</td>
|
||||
|
||||
<!-- Departure Actual/Expected -->
|
||||
<td
|
||||
class="time-cell {estClass(service.atd, service.etd)} {delayClassFromTimePair(
|
||||
service.std,
|
||||
service.atd || service.etd
|
||||
)}"
|
||||
>
|
||||
<span>
|
||||
{service.c
|
||||
? '-'
|
||||
: delayClassFromTimePair(service.std, service.atd || service.etd) === 'delay-rt'
|
||||
? 'RT'
|
||||
: formatUkTime(service.atd || service.etd)}
|
||||
</span>
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
{#each services as service (getRowKey(service))}
|
||||
<tbody>
|
||||
<tr class="service-row" class:serviceCancelled={service.c} class:servicePass={service.wtp}>
|
||||
<td class="id-cell">{service.h}</td>
|
||||
<td class="orig-cell">{service.og.t}</td>
|
||||
<td class="dest-cell">{service.dt.t}</td>
|
||||
<td class="plt-cell" class:platSup={service.ps} class:platChange={service.pc}>{service.p}</td>
|
||||
|
||||
<!-- Handle different display for a passing train -->
|
||||
{#if service.wtp}
|
||||
<td class="pass-cell" colspan="2">Pass</td>
|
||||
<td class="time-cell">{formatUkTime(service.wtp)}</td>
|
||||
<td class="time-cell {estClass(service.atp, service.etp)} {delayClassFromTimePair(service.wtp, service.atp || service.etp)}">{formatUkTime(service.atp || service.etp)}</td>
|
||||
{:else}
|
||||
<td class="time-cell">{formatUkTime(service.sta)}</td>
|
||||
<td class="time-cell {estClass(service.ata, service.eta)} {delayClassFromTimePair(service.sta, service.ata || service.eta)}">{formatUkTime(service.ata || service.eta)}</td>
|
||||
<td class="time-cell">{formatUkTime(service.std)}</td>
|
||||
<td class="time-cell {estClass(service.atd, service.etd)} {delayClassFromTimePair(service.std, service.atd || service.etd)}">{formatUkTime(service.atd || service.etd)}</td>
|
||||
{/if}
|
||||
</tr>
|
||||
|
||||
{#if service.c && service.cr?.r}
|
||||
<tr>
|
||||
<td aria-hidden="true"></td>
|
||||
<td colspan="8">
|
||||
{service.cr.r}
|
||||
{#if service.cr.l}
|
||||
{service.cr.n ? "near" : "at"}
|
||||
{service.cr.l}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{#if service.dr?.r}
|
||||
<tr>
|
||||
<td aria-hidden="true"></td>
|
||||
<td colspan="8">
|
||||
{service.dr.r}
|
||||
{#if service.dr.l}
|
||||
{service.dr.n ? "near" : "at"}
|
||||
{service.dr.l}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
{/each}
|
||||
|
||||
</table>
|
||||
{#if service.c && service.cr?.r}
|
||||
<tr class="cancel-row">
|
||||
<td colspan="9">
|
||||
{service.cr.r}
|
||||
{#if service.cr.l}
|
||||
{service.cr.n ? 'near' : 'at'}
|
||||
{service.cr.l}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{#if service.dr?.r}
|
||||
<tr class="delay-row">
|
||||
<td colspan="9">
|
||||
{service.dr.r}
|
||||
{#if service.dr.l}
|
||||
{service.dr.n ? 'near' : 'at'}
|
||||
{service.dr.l}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
{/each}
|
||||
</table>
|
||||
|
||||
<style>
|
||||
.departure-board {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
font-family: 'URW Gothic', sans-serif;
|
||||
font-variant-numeric: tabular-nums;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
thead {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background: var(--color-bg-dark);
|
||||
}
|
||||
.serviceCancelled {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.servicePass {
|
||||
font-style: italic;
|
||||
.departure-board {
|
||||
width: 100%;
|
||||
margin: 5px auto;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.departure-board td {
|
||||
font-family: 'Inconsolate Variable', monospace;
|
||||
font-size: 1rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-variant-ligatures: additional-ligatures;
|
||||
}
|
||||
|
||||
thead,
|
||||
.cancel-row td,
|
||||
.delay-row td {
|
||||
font-family: 'URW Gothic', sans-serif;
|
||||
letter-spacing: 0.02ch;
|
||||
}
|
||||
|
||||
thead {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background: var(--color-bg-dark);
|
||||
}
|
||||
|
||||
abbr {
|
||||
text-decoration: none;
|
||||
border-bottom: none;
|
||||
cursor:help;
|
||||
}
|
||||
|
||||
/* Row Logic */
|
||||
.serviceCancelled {
|
||||
color: rgb(255, 131, 131);
|
||||
}
|
||||
|
||||
.servicePass td {
|
||||
opacity: 0.75;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
.serviceNonPassenger td {
|
||||
opacity: 0.5;
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
}
|
||||
.id-cell{
|
||||
font-family:'Courier New', Courier, monospace;
|
||||
text-align: center;
|
||||
}
|
||||
.orig-cell, .dest-cell {
|
||||
color: var(--location-yellow);
|
||||
}
|
||||
.orig-cell {
|
||||
text-align: left;
|
||||
}
|
||||
.dest-cell {
|
||||
text-align: right;
|
||||
}
|
||||
.plt-cell {
|
||||
text-align: center;
|
||||
}
|
||||
.platChange {
|
||||
animation: 2s fast-pulse ease-in-out infinite;
|
||||
}
|
||||
.platSup {
|
||||
filter: opacity(0.5);
|
||||
}
|
||||
.pass-cell {
|
||||
text-align: center;
|
||||
}
|
||||
.time-cell {
|
||||
text-align: center;
|
||||
}
|
||||
.est {
|
||||
font-style: oblique;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.act {
|
||||
font-weight: 600;
|
||||
color: green;
|
||||
}
|
||||
.delay-cell {
|
||||
text-align: center;
|
||||
}
|
||||
.delay-late {
|
||||
color: var(--delay-orange);
|
||||
animation: 2s fast-pulse ease-in-out infinite;
|
||||
}
|
||||
.delay-early {
|
||||
color: var(--early-blue);
|
||||
animation: 2s fast-pulse ease-in-out infinite;
|
||||
}
|
||||
</style>
|
||||
|
||||
/* Special Row Styles */
|
||||
.cancel-row td,
|
||||
.delay-row td {
|
||||
font-size: 0.88rem;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.cancel-row td[colspan],
|
||||
.delay-row td[colspan] {
|
||||
padding-left: 0.75ch;
|
||||
}
|
||||
|
||||
.cancel-row td {
|
||||
color: rgb(255, 131, 131);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.delay-row td {
|
||||
color: var(--delay-orange);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Column Specifics */
|
||||
.id-cell {
|
||||
text-align: center;
|
||||
font-weight: 400;
|
||||
font-stretch: 80%;
|
||||
filter: brightness(0.75);
|
||||
}
|
||||
.orig-cell,
|
||||
.dest-cell {
|
||||
font-stretch: 90%;
|
||||
font-weight: 400;
|
||||
}
|
||||
.orig-cell {
|
||||
text-align: left;
|
||||
color: var(--location-yellow);
|
||||
}
|
||||
.dest-cell {
|
||||
text-align: right;
|
||||
color: var(--location-yellow);
|
||||
}
|
||||
.plt-cell {
|
||||
text-align: center;
|
||||
font-weight: 405;
|
||||
font-stretch: 70%;
|
||||
}
|
||||
.plt-cell.platSup {
|
||||
font-weight: 200;
|
||||
opacity: 0.3;
|
||||
}
|
||||
.plt-cell.platChange {
|
||||
animation: fast-pulse 2s ease-out infinite;
|
||||
}
|
||||
.service-row.serviceCancelled .plt-cell {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.pass-cell {
|
||||
text-align: center;
|
||||
}
|
||||
/* Colour orig and dest values when cancelled */
|
||||
.service-row.serviceCancelled .orig-cell,
|
||||
.service-row.serviceCancelled .dest-cell {
|
||||
color: rgb(255, 131, 131);
|
||||
}
|
||||
|
||||
.time-cell {
|
||||
text-align: center;
|
||||
font-stretch: 70%;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* Time Types */
|
||||
.est {
|
||||
font-style: italic;
|
||||
opacity: 0.75;
|
||||
font-weight: 200;
|
||||
}
|
||||
.act {
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user