From 323ead108ddaf8464cae38cbcc31057d9f2d06a6 Mon Sep 17 00:00:00 2001 From: Iain Date: Thu, 12 Nov 2026 22:49:29 +0000 Subject: [PATCH] feat: tidy the footer and flag when rankings are late --- src/app.css | 6 ++ src/lib/components/Footer.svelte | 156 ++++++++++++++++++++++++++++--- src/lib/freshness.ts | 10 ++ src/lib/server/health.ts | 3 +- tests/lib/freshness.test.ts | 20 ++++ 5 files changed, 179 insertions(+), 16 deletions(-) create mode 100644 src/lib/freshness.ts create mode 100644 tests/lib/freshness.test.ts diff --git a/src/app.css b/src/app.css index aba4492..95d6151 100644 --- a/src/app.css +++ b/src/app.css @@ -16,6 +16,9 @@ --on-accent: #ffffff; --star: #c48a00; --danger: #b42318; + --live: #1a7f37; + --late: #bc4c00; + --stale: #cf222e; --selection: #cfe0fa; --series-1: #2a78d6; --series-2: #eb6834; @@ -58,6 +61,9 @@ --on-accent: #0d1117; --star: #e3b341; --danger: #ff8a80; + --live: #3fb950; + --late: #db6d28; + --stale: #f85149; --selection: #1f3a5f; --series-1: #3987e5; --series-2: #d95926; diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte index e79cbbd..794d5cb 100644 --- a/src/lib/components/Footer.svelte +++ b/src/lib/components/Footer.svelte @@ -1,21 +1,40 @@ @@ -23,27 +42,136 @@ .site-footer { margin-block-start: auto; border-block-start: 1px solid var(--border); + background: var(--surface-raised); color: var(--text-muted); font-size: var(--text-sm); + + a { + color: inherit; + + &:hover { + color: var(--accent); + } + } } .bar { max-width: var(--page); margin-inline: auto; - padding: var(--space-5) var(--space-4); - display: flex; - flex-wrap: wrap; - justify-content: space-between; - gap: var(--space-3) var(--space-5); + padding: var(--space-4); + display: grid; + grid-template-columns: 1fr auto; + align-items: start; + gap: var(--space-1) var(--space-5); } - .about { - display: grid; - gap: var(--space-1); + .credits, + .disclaimer { + grid-column: 1 / -1; + text-wrap: pretty; + } + + .credits { + margin-block-start: var(--space-1); + } + + .source { + white-space: nowrap; + } + + .status { + color: var(--text); + } + + .status :global(.updated) { + color: inherit; } nav { + justify-self: end; + color: var(--text); display: flex; - gap: var(--space-4); + flex-wrap: wrap; + gap: var(--space-1) var(--space-4); + + a { + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } + } + + /* inline, so it stays beside the first word when the line wraps */ + .dot { + position: relative; + display: inline-block; + vertical-align: middle; + margin-inline-end: var(--space-1); + inline-size: 0.5rem; + block-size: 0.5rem; + border-radius: 50%; + background: var(--live); + + &::after { + content: ''; + position: absolute; + inset: 0; + border-radius: inherit; + background: inherit; + animation: pulse 5s ease-out infinite; + } + + &.late { + background: var(--late); + } + + &.stale { + background: var(--stale); + } + + /* only a healthy heartbeat pulses */ + &:is(.late, .stale)::after { + animation: none; + } + } + + @keyframes pulse { + from { + opacity: 0.7; + transform: scale(1); + } + + 30%, + to { + opacity: 0; + transform: scale(2.5); + } + } + + @media (prefers-reduced-motion: reduce) { + .dot::after { + animation: none; + } + } + + @media (max-width: 48rem) { + .bar { + grid-template-columns: 1fr; + row-gap: var(--space-2); + text-align: center; + } + + nav { + justify-self: center; + justify-content: center; + } + + /* centred lines look ragged unless they're roughly even */ + .credits, + .disclaimer { + text-wrap: balance; + } } diff --git a/src/lib/freshness.ts b/src/lib/freshness.ts new file mode 100644 index 0000000..8ca371a --- /dev/null +++ b/src/lib/freshness.ts @@ -0,0 +1,10 @@ +const HOUR = 3_600_000; + +/** Two six-hourly snapshots missed in a row, when the uptime check raises the alarm */ +export const SNAPSHOT_LATE = 13 * HOUR; +// a whole day without one +const SNAPSHOT_STALE = 24 * HOUR; + +/** How far behind the rankings are, going by how old the last snapshot is */ +export const lateness = (age: number) => + age > SNAPSHOT_STALE ? 'stale' : age > SNAPSHOT_LATE ? 'late' : 'fresh'; diff --git a/src/lib/server/health.ts b/src/lib/server/health.ts index 4a6657d..e079a9d 100644 --- a/src/lib/server/health.ts +++ b/src/lib/server/health.ts @@ -1,10 +1,9 @@ +import { SNAPSHOT_LATE } from '../freshness.ts'; import { readMeta } from './boards.ts'; import { oldestDue } from './db.ts'; import { ALERT_AT, budget } from './usage.ts'; const HOUR = 3_600_000; -// snapshots land every six hours, so this is two in a row gone missing -const SNAPSHOT_LATE = 13 * HOUR; // a day past due means the crawl isn't keeping up const CRAWL_LATE = 24 * HOUR; diff --git a/tests/lib/freshness.test.ts b/tests/lib/freshness.test.ts new file mode 100644 index 0000000..1e856db --- /dev/null +++ b/tests/lib/freshness.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest'; +import { lateness } from '../../src/lib/freshness.ts'; + +const HOUR = 3_600_000; + +describe('lateness', () => { + it('is fresh through a single missed snapshot', () => { + expect(lateness(0)).toBe('fresh'); + expect(lateness(12 * HOUR)).toBe('fresh'); + }); + + it('is late once two in a row have gone missing, same as the uptime check', () => { + expect(lateness(14 * HOUR)).toBe('late'); + expect(lateness(23 * HOUR)).toBe('late'); + }); + + it('is stale after a whole day without one', () => { + expect(lateness(25 * HOUR)).toBe('stale'); + }); +});