diff --git a/web/src/api/contract.ts b/web/src/api/contract.ts index 955efd1..9b7eb7e 100644 --- a/web/src/api/contract.ts +++ b/web/src/api/contract.ts @@ -234,3 +234,6 @@ export const TOKEN_META = 'sbe-token' export const TOKEN_HEADER = 'X-SBE-Token' export type { BudgetSnapshot, WebDataset } + +// Icon words (DOCS-web-control-api.md, "Icon words"): types in iconWordsContract.ts. +export * from './iconWordsContract' diff --git a/web/src/api/iconWordsContract.ts b/web/src/api/iconWordsContract.ts new file mode 100644 index 0000000..c9419e2 --- /dev/null +++ b/web/src/api/iconWordsContract.ts @@ -0,0 +1,32 @@ +// Icon words: the TS mirror of DOCS-web-control-api.md, "Icon words". +// Split out of contract.ts like jobContract.ts; contract.ts re-exports it. + +/** One icon's picks. No `word` key: not answered; `word: null`: skipped; `glyph: null`: default. */ +export interface IconChoice { + word?: string | null + glyph?: string | null +} + +/** `web/src/ui/icon_words.json`; an absent id is unanswered. */ +export interface IconLedger { + version: 1 + icons: Record +} + +/** + * `POST|PUT /api/icon-words/{id}` body: `word` (text, or null to skip) and/or + * `glyph` (one of the icon's 3 alternatives, or null / the default to reset). + * Answers the whole `IconLedger`. + */ +export type IconChoiceUpdate = { word: string | null } | { glyph: string | null } | { word: string | null; glyph: string | null } + +/** Every served page carries the ledger in ` diff --git a/web/src/sections/dashboard.ts b/web/src/sections/dashboard.ts index 331ba6c..4100920 100644 --- a/web/src/sections/dashboard.ts +++ b/web/src/sections/dashboard.ts @@ -4,7 +4,7 @@ import type { FastInstallRun, StatusPayload } from '../api/contract' import { q } from '../api/queries' -import { COMMAND_ICON, commandLabel } from '../commands/catalog' +import { commandIcon, commandLabel } from '../commands/catalog' import '../commands/commandButton' import { fmtDuration, fmtRemaining } from '../format' import { progressBar, stateBadge, type BarTone } from '../jobs/progress' @@ -190,7 +190,7 @@ export class RecentJobsElement extends LiveElement { h( 'a', { href: jobHref(j.id), class: 'row-link' }, - glyph(COMMAND_ICON[j.command], commandLabel(j.command)), + glyph(commandIcon(j.command), commandLabel(j.command)), // The job's summary is a server sentence: spoken here, shown in the job view. h('span', { class: 'sr-only' }, j.summary ?? j.progress?.label ?? ''), h('span', { class: 'grow' }), diff --git a/web/src/sections/jobs.ts b/web/src/sections/jobs.ts index 77b5bda..f7d8d42 100644 --- a/web/src/sections/jobs.ts +++ b/web/src/sections/jobs.ts @@ -6,7 +6,7 @@ import { ApiFailure } from '../api/client' import { explain } from '../api/errors' import type { Job } from '../api/jobContract' import { q } from '../api/queries' -import { COMMAND_ICON, commandLabel } from '../commands/catalog' +import { commandIcon, commandLabel } from '../commands/catalog' import '../jobs/jobProgress' import { stateBadge } from '../jobs/progress' import { define, h, hx } from '../lib/dom' @@ -29,7 +29,7 @@ function params(j: Job): string { /** The command's glyph painted, its name spoken. */ function commandGlyph(command: Job['command']): HTMLSpanElement { - return glyph(COMMAND_ICON[command], commandLabel(command), 'job-cmd') + return glyph(commandIcon(command), commandLabel(command), 'job-cmd') } /** One row, plus its duration cell so ticks can refresh just that. */ diff --git a/web/src/shell/boot.ts b/web/src/shell/boot.ts index 6d1c436..a1bf498 100644 --- a/web/src/shell/boot.ts +++ b/web/src/shell/boot.ts @@ -4,6 +4,7 @@ import { q, refreshAfterJob } from '../api/queries' import { go } from '../commands/palette' +import { decorateChrome } from '../icons/render' import { hub } from '../jobs/hub' import { runner } from '../lib/runner' import { NAV } from './nav' @@ -67,6 +68,8 @@ export function boot(): void { runner.openPalette() }) watchSetup(window.location.pathname) + // The sidebar and palette button are static HTML: give them the user's words. + decorateChrome() const build = document.querySelector(`meta[name="${BUILD_META}"]`)?.content if (build) setInterval(() => void checkBuild(build), BUILD_POLL_MS) } diff --git a/web/src/shell/jobIndicator.ts b/web/src/shell/jobIndicator.ts index 5757239..ab90db8 100644 --- a/web/src/shell/jobIndicator.ts +++ b/web/src/shell/jobIndicator.ts @@ -3,7 +3,7 @@ import type { Job } from '../api/jobContract' import { isActive, q } from '../api/queries' -import { COMMAND_ICON, commandLabel } from '../commands/catalog' +import { commandIcon, commandLabel } from '../commands/catalog' import { hub } from '../jobs/hub' import { progressBar } from '../jobs/progress' import { define, h } from '../lib/dom' @@ -29,7 +29,7 @@ export function jobChip(job: Job): HTMLAnchorElement { h( 'span', { class: 'jobchip-label' }, - glyph(COMMAND_ICON[job.command], label), + glyph(commandIcon(job.command), label), h('span', { class: 'jobchip-sub' }, waiting ? glyph('โœ‹', 'needs input') : p?.total ? `${p.step}/${p.total}` : 'โ€ฆ'), ), progressBar(fraction, label, waiting ? 'warning' : 'accent', true), diff --git a/web/src/shell/nav.ts b/web/src/shell/nav.ts index 67cb8e8..f50496c 100644 --- a/web/src/shell/nav.ts +++ b/web/src/shell/nav.ts @@ -1,22 +1,36 @@ import type { SectionPath } from '../commands/catalog' +import type { IconId } from '../icons/registry' export interface NavItem { to: SectionPath | '/jobs' - /** Spoken only (aria-label); the sidebar paints `icon`. */ + /** Spoken (aria-label); the sidebar paints `icon` and the user's word for it. */ label: string blurb: string - icon: string + icon: IconId /** 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', 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' }, + { to: '/', label: 'Dashboard', blurb: 'Status, budget and quick actions', icon: 'nav.dashboard', key: '1' }, + { to: '/backlog', label: 'Backlog', blurb: 'Planner, stats and the full game list', icon: 'nav.backlog', key: '2' }, + { to: '/picks', label: 'Picks', blurb: 'Check, done, pick, scan, manual picks', icon: 'nav.picks', key: '3' }, + { to: '/gaming', label: 'Gaming', blurb: 'Daily budget, reset, block, unblock', icon: 'nav.gaming', key: '4' }, + { to: '/library', label: 'Library', blurb: 'All your games, installed, install, uninstall, hide', icon: 'nav.library', key: '5' }, + { to: '/store', label: 'Store', blurb: 'Unblock, buy DLC, exceptions', icon: 'nav.store', key: '6' }, + { to: '/jobs', label: 'Jobs', blurb: 'Running and past jobs', icon: 'nav.jobs', key: '7' }, + { to: '/system', label: 'System', blurb: 'Daemon, server, backups, reset, setup', icon: 'nav.system', key: '8' }, +] + +/** Pages reached from the palette only: no sidebar slot, no Alt key. */ +export interface PalettePage { + to: string + label: string + blurb: string + /** A raw glyph: these pages are not in the icon registry yet. */ + icon: string +} + +export const PALETTE_PAGES: PalettePage[] = [ + { to: '/words', label: 'Icon words', blurb: 'Pick the word shown next to each icon', icon: '๐Ÿท๏ธ' }, ] diff --git a/web/src/styles/app.css b/web/src/styles/app.css index 2c68f41..d450dac 100644 --- a/web/src/styles/app.css +++ b/web/src/styles/app.css @@ -45,8 +45,8 @@ kbd { /* โ”€โ”€ Shell โ”€โ”€ */ .shell { display: grid; - /* Icon rail: nav paints glyph + digit only (textgate). */ - grid-template-columns: 6rem minmax(0, 1fr); + /* Icon rail: glyph + digit; it widens to fit the user's icon words (icons.css). */ + grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr); min-height: 100dvh; } .sidebar { diff --git a/web/src/styles/icons.css b/web/src/styles/icons.css new file mode 100644 index 0000000..2b3f440 --- /dev/null +++ b/web/src/styles/icons.css @@ -0,0 +1,41 @@ +/* Icon words (icons/render.ts) and the /words picker. Tokens only. */ + +/* The word sits RIGHT of its icon, vertically centred on it, never under. */ +.has-word { display: inline-flex; flex-direction: row; align-items: center; gap: var(--space-1); } +.icon-word { white-space: nowrap; line-height: 1.2; font-size: var(--text-body); } +.pill .icon-word { font-size: var(--text-caption); } +.pill.has-word, .pill:has(.icon-word) { gap: var(--space-1); } + +/* Sidebar: icon + word on the left, the Alt digit pushed right. */ +.nav-link.has-word { display: flex; justify-content: flex-start; gap: var(--space-2); } +.nav-link.has-word kbd { margin-left: auto; } +.notice-mark { align-self: flex-start; } +.runner-mark { display: inline-flex; align-items: center; gap: var(--space-1); } + +/* โ”€โ”€ /words picker โ”€โ”€ */ +icon-words-picker { display: flex; flex-direction: column; gap: var(--space-4); } +.picker-head { display: flex; align-items: baseline; gap: var(--space-3); font-size: var(--text-title); } +.picker-id { font-size: var(--text-body); color: var(--text-muted); } +.picker-saved { color: var(--accent); } +.picker-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-5); align-items: start; } +.picker-stage { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding: var(--space-5); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md); } +.picker-big { font-size: 9rem; line-height: 1; } +.picker-context { display: flex; justify-content: center; min-width: 12rem; max-width: 100%; overflow-x: auto; padding: var(--space-3); background: var(--bg); border-radius: var(--radius-sm); } +.picker-context .nav-link { min-width: 10rem; } +.picker-desc { font-size: var(--text-subtitle); max-width: var(--measure); } +.picker-words, .picker-glyphs { display: flex; flex-wrap: wrap; gap: var(--space-2); } +.picker-choice { font-size: var(--text-subtitle); justify-content: flex-start; } +.picker-choice kbd { margin-right: var(--space-2); } +.picker-choice[aria-pressed='true'] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); } +.picker-own { display: flex; align-items: flex-end; gap: var(--space-2); } +.picker-own-label { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 auto; } +.picker-own .input { font-size: var(--text-subtitle); } +.picker-own .input[aria-invalid='true'] { border-color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); } +.picker-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); } +.picker-toggle { display: flex; align-items: center; gap: var(--space-2); } +.picker-done { align-items: center; padding: var(--space-6); } +.picker-summary { font-size: var(--text-display); } + +@media (max-width: 800px) { + .picker-body { grid-template-columns: minmax(0, 1fr); } +} diff --git a/web/src/test/iconLedger.ts b/web/src/test/iconLedger.ts new file mode 100644 index 0000000..a950afb --- /dev/null +++ b/web/src/test/iconLedger.ts @@ -0,0 +1,21 @@ +// Test helpers for the icon-word ledger: set it directly, or plant the +// `