web: icon rail nav, spoken-only page heads

Sidebar paints a glyph and digit per section, the palette button a
magnifier and ⌃K; page titles, subtitles and the Actions heading are
spoken only. web/scripts/visible_words.mjs lists chrome words in the
built pages (146 -> 4, the command-button labels).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-11 02:23:47 +01:00
parent f5f921ebf4
commit ca59039ba0
7 changed files with 77 additions and 21 deletions

View File

@ -0,0 +1,50 @@
// Textgate check over the built site: list every chrome word a page paints
// before its custom elements hydrate (layout, page heads, command-button
// labels). Spoken-only text (.sr-only, aria-hidden, the focus-only skip link)
// is ignored. Exit 1 when any page paints a word, so it works as a gate.
//
// Usage: node scripts/visible_words.mjs [distDir] (run `pnpm build` first)
import { readdirSync, readFileSync, statSync } from 'node:fs'
import { join, relative } from 'node:path'
import { JSDOM } from 'jsdom'
const WORD_RE = /[A-Za-z]{2,}/
const SPOKEN = '.sr-only, [aria-hidden="true"], .skip, script, style, template'
/** @param {string} dir @returns {string[]} */
function htmlFiles(dir) {
return readdirSync(dir).flatMap((name) => {
const p = join(dir, name)
if (statSync(p).isDirectory()) return htmlFiles(p)
return name.endsWith('.html') ? [p] : []
})
}
/** @param {string} html @returns {string[]} */
export function visibleWords(html) {
const { document } = new JSDOM(html).window
for (const el of document.querySelectorAll(SPOKEN)) el.remove()
const out = []
const walker = document.createTreeWalker(document.body, 4 /* SHOW_TEXT */)
for (let n = walker.nextNode(); n; n = walker.nextNode()) {
const t = n.textContent?.trim() ?? ''
if (WORD_RE.test(t)) out.push(t)
}
// command-button paints its label attribute once it hydrates.
for (const el of document.querySelectorAll('command-button[label]')) {
const t = el.getAttribute('label') ?? ''
if (WORD_RE.test(t)) out.push(`[button] ${t}`)
}
return out
}
const dist = process.argv[2] ?? 'dist'
let total = 0
for (const file of htmlFiles(dist).sort()) {
const words = visibleWords(readFileSync(file, 'utf8'))
total += words.length
if (words.length) console.log(`${relative(dist, file)} (${words.length}): ${words.join(' | ')}`)
}
console.log(`total: ${total}`)
process.exit(total ? 1 : 0)

View File

@ -7,6 +7,6 @@ const { title = 'Actions' } = Astro.props
---
<section class="actions-block" aria-label={title}>
<h2>{title}</h2>
<h2 class="sr-only">{title}</h2>
<div class="cmd-grid"><slot /></div>
</section>

View File

@ -1,5 +1,5 @@
---
// Page title, optional subtitle (text prop or `sub` slot) and action buttons
// Page title and optional subtitle (spoken only, textgate) plus action buttons
// (default slot). Was ui/Page.tsx PageHead.
interface Props {
title: string
@ -11,9 +11,9 @@ const hasActions = Astro.slots.has('default')
<header class="page-head">
<div>
<h1>{title}</h1>
{sub && <p class="sub">{sub}</p>}
{Astro.slots.has('sub') && <p class="sub"><slot name="sub" /></p>}
<h1 class="sr-only">{title}</h1>
{sub && <p class="sr-only">{sub}</p>}
{Astro.slots.has('sub') && <p class="sr-only"><slot name="sub" /></p>}
</div>
{hasActions && <div class="page-actions"><slot /></div>}
</header>

View File

@ -38,7 +38,7 @@ const href = (to: string) => (to === '/' ? '/' : `${to}/`)
<aside class="sidebar">
<div class="brand">
<span class="brand-mark" aria-hidden="true"></span>
<span>Backlog<br />Enforcer</span>
<span class="sr-only">Backlog Enforcer</span>
</div>
<nav aria-label="Sections">
<ul class="nav">
@ -49,9 +49,11 @@ const href = (to: string) => (to === '/' ? '/' : `${to}/`)
href={href(n.to)}
class={isActive(n.to) ? 'nav-link active' : 'nav-link'}
aria-current={isActive(n.to) ? 'page' : undefined}
aria-label={n.label}
aria-keyshortcuts={`Alt+${n.key}`}
>
<span>{n.label}</span>
<kbd aria-hidden="true">Alt {n.key}</kbd>
<span class="nav-icon" aria-hidden="true">{n.icon}</span>
<kbd aria-hidden="true">{n.key}</kbd>
</a>
</li>
))
@ -61,8 +63,8 @@ const href = (to: string) => (to === '/' ? '/' : `${to}/`)
</aside>
<div class="main-col">
<header class="topbar">
<button type="button" class="btn btn-ghost palette-btn" data-open-palette aria-keyshortcuts="Control+K">
Commands <kbd>Ctrl K</kbd>
<button type="button" class="btn btn-ghost palette-btn" data-open-palette aria-keyshortcuts="Control+K" aria-label="Commands">
<span aria-hidden="true">🔍</span> <kbd aria-hidden="true">⌃K</kbd>
</button>
<job-indicator></job-indicator>
<span class="grow"></span>

View File

@ -6,5 +6,5 @@ import Shell from '../layouts/Shell.astro'
<Shell title="Not found">
<PageHead title="Not found" sub="There is no screen at this address." />
<div class="actions"><a href="/" class="btn btn-primary">Back to the dashboard</a></div>
<div class="actions"><a href="/" class="btn btn-primary" aria-label="Back to the dashboard"><span aria-hidden="true">🏠</span></a></div>
</Shell>

View File

@ -2,19 +2,21 @@ import type { SectionPath } from '../commands/catalog'
export interface NavItem {
to: SectionPath | '/jobs'
/** Spoken only (aria-label); the sidebar paints `icon`. */
label: string
blurb: string
/** Alt+<key> accelerator, shown in the sidebar. */
icon: string
/** Alt+<key> accelerator, shown in the sidebar as the bare digit. */
key: string
}
export const NAV: NavItem[] = [
{ to: '/', label: 'Dashboard', blurb: 'Status, budget and quick actions', key: '1' },
{ to: '/backlog', label: 'Backlog', blurb: 'Planner, stats and the full game list', key: '2' },
{ to: '/picks', label: 'Picks', blurb: 'Check, done, pick, scan, manual picks', key: '3' },
{ to: '/gaming', label: 'Gaming', blurb: 'Daily budget, reset, block, unblock', key: '4' },
{ to: '/library', label: 'Library', blurb: 'All your games, installed, install, uninstall, hide', key: '5' },
{ to: '/store', label: 'Store', blurb: 'Unblock, buy DLC, exceptions', key: '6' },
{ to: '/jobs', label: 'Jobs', blurb: 'Running and past jobs', key: '7' },
{ to: '/system', label: 'System', blurb: 'Daemon, server, backups, reset, setup', key: '8' },
{ to: '/', label: 'Dashboard', blurb: 'Status, budget and quick actions', icon: '🏠', key: '1' },
{ to: '/backlog', label: 'Backlog', blurb: 'Planner, stats and the full game list', icon: '📚', key: '2' },
{ to: '/picks', label: 'Picks', blurb: 'Check, done, pick, scan, manual picks', icon: '🎯', key: '3' },
{ to: '/gaming', label: 'Gaming', blurb: 'Daily budget, reset, block, unblock', icon: '🎮', key: '4' },
{ to: '/library', label: 'Library', blurb: 'All your games, installed, install, uninstall, hide', icon: '🗂️', key: '5' },
{ to: '/store', label: 'Store', blurb: 'Unblock, buy DLC, exceptions', icon: '🛒', key: '6' },
{ to: '/jobs', label: 'Jobs', blurb: 'Running and past jobs', icon: '⚙️', key: '7' },
{ to: '/system', label: 'System', blurb: 'Daemon, server, backups, reset, setup', icon: '🖥️', key: '8' },
]

View File

@ -45,7 +45,8 @@ kbd {
/* ── Shell ── */
.shell {
display: grid;
grid-template-columns: 13rem minmax(0, 1fr);
/* Icon rail: nav paints glyph + digit only (textgate). */
grid-template-columns: 6rem minmax(0, 1fr);
min-height: 100dvh;
}
.sidebar {
@ -86,6 +87,7 @@ kbd {
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-link kbd { opacity: 0.7; }
.nav-icon { font-size: var(--text-subtitle); line-height: 1; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {