From ca59039ba07b8951d13f6a44dc7acc75c5ba3895 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Wed, 11 Nov 2026 02:23:47 +0100 Subject: [PATCH] web: icon rail nav, spoken-only page heads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- web/scripts/visible_words.mjs | 50 +++++++++++++++++++++++++++++++ web/src/components/Actions.astro | 2 +- web/src/components/PageHead.astro | 8 ++--- web/src/layouts/Shell.astro | 12 ++++---- web/src/pages/404.astro | 2 +- web/src/shell/nav.ts | 20 +++++++------ web/src/styles/app.css | 4 ++- 7 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 web/scripts/visible_words.mjs diff --git a/web/scripts/visible_words.mjs b/web/scripts/visible_words.mjs new file mode 100644 index 0000000..2ebd275 --- /dev/null +++ b/web/scripts/visible_words.mjs @@ -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) diff --git a/web/src/components/Actions.astro b/web/src/components/Actions.astro index aa06c18..be7e647 100644 --- a/web/src/components/Actions.astro +++ b/web/src/components/Actions.astro @@ -7,6 +7,6 @@ const { title = 'Actions' } = Astro.props ---
-

{title}

+

{title}

diff --git a/web/src/components/PageHead.astro b/web/src/components/PageHead.astro index ac424f3..e0b97da 100644 --- a/web/src/components/PageHead.astro +++ b/web/src/components/PageHead.astro @@ -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')
-

{title}

- {sub &&

{sub}

} - {Astro.slots.has('sub') &&

} +

{title}

+ {sub &&

{sub}

} + {Astro.slots.has('sub') &&

}
{hasActions &&
}
diff --git a/web/src/layouts/Shell.astro b/web/src/layouts/Shell.astro index b2607eb..9339fde 100644 --- a/web/src/layouts/Shell.astro +++ b/web/src/layouts/Shell.astro @@ -38,7 +38,7 @@ const href = (to: string) => (to === '/' ? '/' : `${to}/`)
- diff --git a/web/src/pages/404.astro b/web/src/pages/404.astro index 0dcdfe1..0c8b0e9 100644 --- a/web/src/pages/404.astro +++ b/web/src/pages/404.astro @@ -6,5 +6,5 @@ import Shell from '../layouts/Shell.astro' - + diff --git a/web/src/shell/nav.ts b/web/src/shell/nav.ts index a84f95a..67cb8e8 100644 --- a/web/src/shell/nav.ts +++ b/web/src/shell/nav.ts @@ -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+ accelerator, shown in the sidebar. */ + icon: string + /** Alt+ 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' }, ] diff --git a/web/src/styles/app.css b/web/src/styles/app.css index 2e59cdb..2c68f41 100644 --- a/web/src/styles/app.css +++ b/web/src/styles/app.css @@ -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 {