Compare commits

...

6 Commits

Author SHA1 Message Date
b1424a5bea Type health tone so the fallback is gone
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYNS1qAMRdgAtbr5Rq
2026-11-16 10:54:12 +01:00
fee4ccdd88 Route commands, jobs and prompt icons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYNS1qAMRdgAtbr5Rq
2026-11-16 10:51:32 +01:00
b913ff67f5 Route gaming, backlog and library icons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYNS1qAMRdgAtbr5Rq
2026-11-16 10:51:26 +01:00
173d296517 Route shell and system icons through registry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYNS1qAMRdgAtbr5Rq
2026-11-16 10:51:22 +01:00
6aa40636e7 Register every UI icon word in the registry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYNS1qAMRdgAtbr5Rq
2026-11-16 10:50:45 +01:00
2df84b30b9 Add kuhy's pass 2 icon word picks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYNS1qAMRdgAtbr5Rq
2026-11-16 10:50:37 +01:00
68 changed files with 2684 additions and 529 deletions

View File

@ -7,7 +7,7 @@ Part of the web control API ([DOCS-web-control-api.md](DOCS-web-control-api.md))
`GET /api/icon-words` → `IconLedger`; `POST` or `PUT /api/icon-words/{icon_id}` with `{word?, glyph?}` → `IconLedger` (200). Writes need Host, Origin and `X-SBE-Token` like every non-GET. TS mirror: `web/src/api/iconWordsContract.ts`.
- **Ledger** `web/src/ui/icon_words.json` (a repo file the user commits; `SBE_ICON_WORDS` overrides the path): `{"version":1,"icons":{"<id>":{"word":"<text>"|null,"glyph":"<emoji>"|null}}}`. Absent id = unanswered; no `word` key = only a glyph chosen; `word: null` = skipped (no label); `glyph: null` = default. The server reads it per request and never builds from it (`_web_build` ignores it); writes go to a sibling temp file, then rename.
- **Registry** `web/src/icons/registry.json`: id → default glyph, spoken name, description, 3 suggested words, 3 alternative glyphs (`registry.ts` types it).
- **Registry** `web/src/icons/registry.json`: id → default glyph, spoken name, description, 3 suggested words, 3 alternative glyphs (`registry.ts` types it). It lists every icon the UI paints, in picker order: new ids go at the end so answered icons keep their place and the picker opens at the first unanswered one. Ids match `[a-z][a-z0-9_.-]{0,63}`. `web/src/icons/coverage.test.ts` fails on any pictograph or icon symbol typed as a literal in non-test source; draw icons with `glyph(id)`, `iconInline(id)`, `iconMark(id)` or `pill(tone, text, id)`.
- **`word`**: any text; casing kept, whitespace runs collapsed; 1–40 characters, no control characters, else `invalid_params`. `null` skips. **`glyph`**: the default or one of the icon's 3 alternatives (the default is stored as `null`), else `invalid_params`. Unknown id → `not_found`; empty body or unknown key → `invalid_params`.
- Every served `.html` page carries the ledger as `<script type="application/json" id="sbe-icon-words">` (`<` escaped), so a pick shows on the next page load.
- **Corrupt ledger** (bad JSON or schema): copied to `<ledger>.corrupt` (an older copy is never overwritten) and left in place; every read and write answers `op_failed` (500) naming the copy until someone fixes it. Pages then carry that error body and draw no words.

View File

@ -0,0 +1,59 @@
"""The shipped icon registry and the user's ledger against the server's rules."""
from __future__ import annotations
import json
from pathlib import Path
import re
from typing import Any
from steam_backlog_enforcer import _web_icon_words
LEDGER_FILE = (
Path(_web_icon_words.__file__).resolve().parent.parent
/ "web"
/ "src"
/ "ui"
/ "icon_words.json"
)
# The same shape the route accepts for ``/api/icon-words/{icon}``.
ICON_ID = re.compile(r"[a-z][a-z0-9_.-]{0,63}")
VARIATION_SELECTOR = "️"
def _registry() -> dict[str, dict[str, Any]]:
return _web_icon_words.load_registry()
def _look(glyph: str) -> str:
"""The glyph without its emoji variation selector."""
return glyph.replace(VARIATION_SELECTOR, "")
def test_every_registered_id_fits_the_route() -> None:
"""A registered id the route cannot match could never be saved."""
registry = _registry()
assert len(registry) > 45
assert [i for i in registry if not ICON_ID.fullmatch(i)] == []
def test_every_entry_is_complete() -> None:
"""Each icon has a description, 3 one-word suggestions and 3 alternatives."""
for icon, entry in _registry().items():
looks = {_look(entry["glyph"]), *(_look(a) for a in entry["alts"])}
assert entry["spoken"], icon
assert len(entry["desc"]) > 20, icon
assert len({w.lower() for w in entry["words"]}) == 3, icon
assert all(re.fullmatch(r"\S+", w) for w in entry["words"]), icon
assert len(entry["alts"]) == 3, icon
assert len(looks) == 4, icon
def test_the_users_ledger_only_names_registered_icons() -> None:
"""Every ledger answer belongs to an icon, and a chosen glyph is one of its own."""
registry = _registry()
icons = json.loads(LEDGER_FILE.read_text("utf-8"))["icons"]
assert [i for i in icons if i not in registry] == []
for icon, choice in icons.items():
glyph = choice.get("glyph")
assert glyph is None or glyph in registry[icon]["alts"], icon

View File

@ -5,7 +5,6 @@
import type { CommandName, CommandSpec, InstalledGame } from '../api/contract'
import type { IconId } from '../icons/registry'
import { iconFor } from '../icons/render'
export type SectionPath =
| '/'
@ -51,21 +50,6 @@ export function commandIcon(name: CommandName): IconId {
return `cmd.${name}` as const satisfies IconId
}
/**
* The glyph a command paints, for sites not yet on `glyph(commandIcon(…))`
* (they get the chosen alternative glyph, not the word). Live getters, so a
* ledger change shows without re-importing.
*/
export const COMMAND_ICON: Readonly<Record<CommandName, string>> = Object.defineProperties(
{},
Object.fromEntries(
(Object.keys(COMMAND_HOME) as CommandName[]).map((name) => [
name,
{ enumerable: true, get: () => iconFor(commandIcon(name)).glyph },
]),
),
) as Record<CommandName, string>
/** Title-case label for buttons and the palette (`pick-manual` → `Pick manual`). */
export function commandLabel(name: CommandName): string {
const s = name.replace(/-/g, ' ')

View File

@ -6,7 +6,8 @@
import type { CommandName } from '../api/contract'
import { q } from '../api/queries'
import { iconMark, iconWord } from '../icons/render'
import type { IconId } from '../icons/registry'
import { iconInline, iconMark, iconWord } from '../icons/render'
import { define, h, jsonAttr } from '../lib/dom'
import { LiveElement } from '../lib/element'
import { pageHref, runner, type Preset } from '../lib/runner'
@ -54,13 +55,13 @@ export function commandButton({ name, preset, label, tone = 'ghost' }: ButtonPro
},
},
glyph,
locked === null ? null : h('span', { class: 'cmd-lock', 'aria-hidden': 'true' }, '🔒'),
locked === null ? null : h('span', { class: 'cmd-lock', 'aria-hidden': 'true' }, iconInline('state.locked')),
)
}
/** A card flag (root, countdown): glyph painted, its word spoken. */
function flag(glyph: string, spoken: string): HTMLSpanElement {
return h('span', { class: 'pill pill-neutral', 'aria-label': spoken, role: 'img' }, glyph)
function flag(id: IconId, spoken: string): HTMLSpanElement {
return h('span', { class: 'pill pill-neutral', 'aria-label': spoken, role: 'img' }, iconInline(id))
}
export class CommandButtonElement extends LiveElement {
@ -90,8 +91,8 @@ export class CommandCardElement extends LiveElement {
'h3',
{ class: 'cmd-name' },
h('span', { class: 'sr-only' }, commandLabel(p.name)),
spec?.privileged ? flag('🔑', 'root') : null,
spec?.friction?.countdown_seconds ? flag('⏳', 'countdown') : null,
spec?.privileged ? flag('cmdflag.root', 'root') : null,
spec?.friction?.countdown_seconds ? flag('cmdflag.countdown', 'countdown') : null,
),
h('p', { class: 'cmd-desc sr-only' }, locked ?? spec?.description ?? '…'),
commandButton(p),

View File

@ -0,0 +1,109 @@
// Pass-2 icon wiring for the command UI: the user's word shows right of the
// icon, a chosen alternative glyph replaces the default, and the spoken
// names (aria-label, .sr-only) stay as they were.
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { makeSpec, makePending } from '../test/fixtures'
import { mount, stubApi } from '../test/harness'
import { useIcons } from '../test/iconLedger'
import { must } from '../test/events'
import { painted } from '../test/painted'
import { visibleWords } from '../test/visibleWords'
import { NAV } from '../shell/nav'
import './commandButton'
import { CommandPaletteElement } from './palette'
import { PendingCountdown } from './pendingCountdown'
import { commandFlags, fillHint, lockedNotice, terminalFallback } from './runnerParts'
describe('command button and card', () => {
it('draws the lock badge with its word and glyph, aria unchanged', async () => {
useIcons({ 'state.locked': { word: 'closed', glyph: '🔐' } })
stubApi({ 'GET /api/commands': [makeSpec('scan', { locked_reason: 'A pick is active' })] })
const el = mount('<command-button name="scan"></command-button>')
await vi.waitFor(() => { expect(el.querySelector('.cmd-lock')).not.toBeNull() })
const lock = must(el.querySelector('.cmd-lock'))
expect(lock.textContent).toBe('🔐Closed')
expect(lock.querySelector('.icon-word')).toHaveAttribute('data-icon-word', 'state.locked')
expect(el.querySelector('button')).toHaveAttribute('aria-label', 'Run scan')
expect(el.querySelector('button')).toHaveAttribute('aria-description', 'A pick is active')
expect(visibleWords(el)).toEqual([])
})
it('draws the root and countdown flags of a card by id', async () => {
useIcons({ 'cmdflag.root': { word: 'admin' }, 'cmdflag.countdown': { glyph: '⏲️' } })
stubApi({ 'GET /api/commands': [makeSpec('gaming-reset', { privileged: true, friction: { phrase_template: 'x', countdown_seconds: 300 } })] })
const el = mount('<command-card name="gaming-reset"></command-card>')
await vi.waitFor(() => { expect(el.querySelector('.cmd-name .pill')).not.toBeNull() })
const flags = [...el.querySelectorAll('.cmd-name .pill')]
expect(flags.map((f) => f.getAttribute('aria-label'))).toEqual(['root', 'countdown'])
expect(flags[0]?.textContent).toBe('🔑Admin')
expect(flags[1]?.textContent).toBe('⏲️')
})
})
describe('command palette', () => {
it('shows the search icon and its word in the placeholder, hint icons by id', async () => {
useIcons({ 'cmdpal.search': { word: 'find' }, 'cmdpal.open': { word: 'page', glyph: '🔗' }, 'cmdpal.go': { word: 'jump' } })
stubApi({ 'GET /api/commands': [makeSpec('status', { kind: 'view', description: 'Show status.' })] })
const el = new CommandPaletteElement()
document.body.append(el)
el.open()
await vi.waitFor(() => { expect(document.querySelectorAll('[role=option]').length).toBeGreaterThan(NAV.length + 1) })
expect(document.querySelector<HTMLInputElement>('[role=combobox]')).toHaveAttribute('placeholder', '🔍 Find')
const hints = [...document.querySelectorAll('.palette-hint')]
expect(hints[0]?.textContent).toContain('🔗Page')
expect(hints[0]?.querySelector('.sr-only')?.textContent).toBe('open /')
expect(hints.at(-1)?.textContent).toContain('🧭Jump')
})
})
describe('run dialog parts', () => {
it('draws the command flags by id', () => {
useIcons({ 'cmdflag.readonly': { word: 'safe' }, 'cmdflag.cancellable': { glyph: '🛑' } })
const flags = commandFlags(makeSpec('scan', { mutating: false, cancellable: true }))
const [, readonly, cancellable] = flags
expect(painted(readonly)).toBe('👁️Safe')
expect(readonly?.querySelector('.sr-only')?.textContent).toBe('Read-only')
expect(painted(cancellable)).toBe('🛑')
})
it('paints the lock mark in the warning notice and keeps the spoken reason', () => {
useIcons({ 'state.locked': { word: 'sealed' } })
const el = lockedNotice('Daemon is down')
expect(el).toHaveAttribute('aria-label', 'Locked: Daemon is down')
expect(el.textContent).toBe('🔒Sealed')
expect(el.querySelector('.notice-icon')).toHaveAttribute('data-icon', 'state.locked')
})
it('draws the fill hint and the terminal fallback by id', () => {
useIcons({ 'runner.fill': { word: 'above' }, 'runner.terminal': { glyph: '🐚' } })
expect(fillHint(['app_id']).textContent).toContain('⬆️Above')
const [line] = terminalFallback('sudo ./run.sh gaming-unblock')
expect(line).toHaveAttribute('aria-label', 'Run it from a terminal instead:')
expect(line.textContent).toBe('🐚')
})
})
describe('pending countdown', () => {
beforeEach(() => {
vi.useFakeTimers({ now: Date.parse('2026-10-10T10:00:00Z') })
})
const made: PendingCountdown[] = []
afterEach(() => {
for (const c of made.splice(0)) c.dispose()
})
it('draws the lock beside the clock and the heartbeat, words and glyphs from the ledger', () => {
useIcons({ 'state.locked': { word: 'locked' }, 'pending.beat': { word: 'pulse', glyph: '💗' } })
const cbs = { onCommitted: vi.fn(), onCancel: vi.fn(), onRearm: vi.fn() }
const countdown = new PendingCountdown(makePending({ ready_at: '2026-10-10T10:00:30Z' }), cbs)
made.push(countdown)
document.body.append(countdown.el)
const clock = must(countdown.el.querySelector('.countdown-clock'))
expect(clock.textContent).toContain('🔒Locked')
expect(clock.querySelector('.sr-only')?.textContent).toBe('until commit unlocks')
expect(countdown.el.textContent).toContain('💗Pulse 0s')
expect(countdown.el.querySelector('button')).toHaveAttribute('aria-label', 'Cancel countdown')
expect(countdown.el.querySelector('button')?.textContent).toBe('✖️')
})
})

View File

@ -4,6 +4,8 @@
// via aria-activedescendant.
import { q } from '../api/queries'
import { iconText } from '../icons/iconText'
import type { IconId } from '../icons/registry'
import { define, h } from '../lib/dom'
import { uid } from '../lib/ids'
import { pageHref, runner } from '../lib/runner'
@ -17,10 +19,9 @@ interface Entry {
title: string
detail: string
hint: string
/** A registered icon id (painted with the user's word) or a raw glyph. */
icon: string
/** Painted in place of the hint: ▶️ run, ↗️ open, 🧭 navigate. */
hintIcon: string
icon: IconId
/** Painted in place of the hint: run, open the page, or navigate. */
hintIcon: IconId
locked: string | null
act: () => void
}
@ -49,7 +50,7 @@ export class CommandPaletteElement extends HTMLElement {
'aria-expanded': 'true',
'aria-controls': `${this.listId}-list`,
'aria-label': 'Search commands',
placeholder: '🔍',
placeholder: iconText('cmdpal.search'),
autofocus: true,
})
this.list = h('ul', { id: `${this.listId}-list`, role: 'listbox', class: 'palette-list', 'aria-label': 'Commands' })
@ -112,13 +113,13 @@ export class CommandPaletteElement extends HTMLElement {
private entries(): Entry[] {
return [
...(q.commands.state.data ?? []).map((c) => ({
...(q.commands.state.data ?? []).map((c): Entry => ({
key: c.name,
title: commandLabel(c.name),
detail: c.description,
hint: c.kind === 'job' ? (c.friction ? 'run · confirm' : 'run') : `open ${COMMAND_HOME[c.name]}`,
icon: commandIcon(c.name),
hintIcon: c.kind === 'job' ? (c.friction ? '▶️⌨️' : '▶️') : '↗️',
hintIcon: c.kind === 'job' ? (c.friction ? 'cmdpal.run-phrase' : 'runner.run') : 'cmdpal.open',
locked: c.locked_reason,
act: () => {
if (c.kind === 'job') runner.run(c.name)
@ -128,13 +129,13 @@ export class CommandPaletteElement extends HTMLElement {
}
},
})),
...[...NAV, ...PALETTE_PAGES].map((n) => ({
...[...NAV, ...PALETTE_PAGES].map((n): Entry => ({
key: `nav:${n.to}`,
title: `Go to ${n.label}`,
detail: n.blurb,
hint: 'navigate',
icon: n.icon,
hintIcon: '🧭',
hintIcon: 'cmdpal.go',
locked: null,
act: () => {
this.close()
@ -157,7 +158,7 @@ export class CommandPaletteElement extends HTMLElement {
'li',
{ id: `${this.listId}-${i}`, role: 'option', 'aria-selected': String(i === this.active), class: i === this.active ? 'palette-item active' : 'palette-item' },
// Textgate: glyphs painted; title, detail and hint spoken only.
h('span', { class: 'palette-title' }, glyph(e.icon, e.title), e.locked ? pill('warning', 'locked', '🔒') : null),
h('span', { class: 'palette-title' }, glyph(e.icon, e.title), e.locked ? pill('warning', 'locked', 'state.locked') : null),
h('span', { class: 'palette-detail sr-only' }, e.locked ?? e.detail),
h('span', { class: 'palette-hint' }, glyph(e.hintIcon, e.hint)),
)

View File

@ -3,34 +3,32 @@
// never re-creates an input.
import type { ParamSpec } from '../api/contract'
import type { IconId } from '../icons/registry'
import { iconInline } from '../icons/render'
import { h } from '../lib/dom'
import { uid } from '../lib/ids'
import { glyph } from '../ui/build'
import { paramError, type GameOption, type ParamValues } from './params'
/** Painted glyph per parameter (textgate); the catalog label is spoken only. */
const PARAM_ICON: Record<string, string> = {
app_id: '🎮',
backup_id: '🗄️',
days: '📅',
minutes: '⏱️',
reason: '💬',
replace: '🔁',
demo: '🧪',
/** Painted icon per parameter (textgate); the catalog label is spoken only. */
const PARAM_ICON: Record<string, IconId> = {
app_id: 'params.app_id',
backup_id: 'params.backup_id',
days: 'params.days',
minutes: 'params.minutes',
reason: 'params.reason',
replace: 'params.replace',
demo: 'params.demo',
}
function paramGlyph(spec: ParamSpec): HTMLSpanElement {
return h(
'span',
{},
h('span', { 'aria-hidden': 'true' }, PARAM_ICON[spec.name] ?? '✏️'),
h('span', { class: 'sr-only' }, spec.label),
)
return glyph(PARAM_ICON[spec.name] ?? 'params.other', spec.label)
}
/** Field help: optional painted mark, sentence spoken only. */
function spokenHelp(el: HTMLElement, mark: string | null, sentence: string): void {
function spokenHelp(el: HTMLElement, mark: IconId | null, sentence: string): void {
el.replaceChildren(
mark ? h('span', { 'aria-hidden': 'true' }, mark) : '',
mark ? iconInline(mark) : '',
sentence ? h('span', { class: 'sr-only' }, sentence) : '',
)
}
@ -137,9 +135,9 @@ export class ParamsForm {
input.setAttribute('aria-invalid', String(bad))
help.className = bad ? 'field-help text-danger' : 'field-help'
const game = spec.type === 'app_id' ? this.games.find((g) => g.app_id === Number(raw)) : undefined
// Textgate: an error paints ⚠️, a matched game paints its name (content);
// the error sentence and the field help are spoken only.
if (bad) spokenHelp(help, '⚠️', err)
// Textgate: an error paints the warn mark, a matched game paints its name
// (content); the error sentence and the field help are spoken only.
if (bad) spokenHelp(help, 'state.warn', err)
else if (game) help.replaceChildren(game.name)
else spokenHelp(help, null, spec.help ?? (spec.type === 'app_id' ? 'Type an app id or pick a game from the list.' : ''))
if (datalist && datalist.childElementCount !== this.games.length) {

View File

@ -6,6 +6,7 @@
import { api, ApiFailure } from '../api/client'
import type { Job, PendingAction } from '../api/jobContract'
import { iconInline } from '../icons/render'
import { progressBar } from '../jobs/progress'
import { Action } from '../lib/action'
import { h } from '../lib/dom'
@ -21,9 +22,9 @@ import { PhraseField } from './phraseField'
*/
export const CLOCK_SLACK_MS = 1000
/** ⚠️ 🚪: leaving cancels the countdown; the sentence is spoken only. */
/** Warning plus the leave mark: leaving cancels the countdown; the sentence is spoken only. */
function stayNotice(): HTMLDivElement {
const el = notice('warning', null, h('span', { 'aria-hidden': 'true' }, '🚪✖️'))
const el = notice('warning', null, iconInline('pending.leave'))
el.setAttribute('aria-label', 'Closing this dialog, navigating away or closing the tab cancels the countdown.')
return el
}
@ -109,7 +110,7 @@ export class PendingCountdown {
this.el.className = 'stack'
this.el.replaceChildren(
errorNotice(this.beatError),
h('div', { class: 'actions' }, h('button', { type: 'button', class: 'btn btn-primary', autofocus: true, 'aria-label': 'Arm again', onclick: this.cb.onRearm }, '🔁')),
h('div', { class: 'actions' }, h('button', { type: 'button', class: 'btn btn-primary', autofocus: true, 'aria-label': 'Arm again', onclick: this.cb.onRearm }, iconInline('pending.rearm'))),
)
this.el.querySelector<HTMLElement>('[autofocus]')?.focus()
return
@ -120,17 +121,18 @@ export class PendingCountdown {
const left = Math.max(0, (ready - now) / 1000)
const isReady = left <= 0
this.parts.num.textContent = clock(left)
// Textgate: 🔓/🔒 painted beside the clock; 💓 + seconds since the last
// heartbeat (red 💔 when failing). Sentences are spoken only.
// Textgate: the lock mark painted beside the clock; the heartbeat mark +
// seconds since the last heartbeat (red broken heart when failing).
// Sentences are spoken only.
this.parts.caption.replaceChildren(
h('span', { 'aria-hidden': 'true' }, isReady ? '🔓' : '🔒'),
iconInline(isReady ? 'state.unlocked' : 'state.locked'),
h('span', { class: 'sr-only' }, isReady ? 'Ready to commit' : 'until commit unlocks'),
)
this.parts.bar.replaceChildren(progressBar(Math.min(1, (now - armed) / (ready - armed)), 'Countdown', isReady ? 'success' : 'warning'))
const sinceBeat = Math.round((now - this.lastBeat) / 1000)
const failing = this.beatError !== null
this.parts.beat.replaceChildren(
h('span', { 'aria-hidden': 'true', class: failing ? 'text-danger' : '' }, `${failing ? '💔' : '💓'} ${sinceBeat}s`),
h('span', { 'aria-hidden': 'true', class: failing ? 'text-danger' : '' }, iconInline(failing ? 'pending.beat-lost' : 'pending.beat'), ` ${sinceBeat}s`),
h(
'span',
{ class: 'sr-only' },
@ -154,7 +156,7 @@ export class PendingCountdown {
h(
'button',
{ type: 'button', class: 'btn btn-ghost', autofocus: true, 'aria-label': this.cancel.pending ? 'Cancelling…' : 'Cancel countdown', onclick: () => void this.doCancel() },
this.cancel.pending ? '⏳' : '✖️',
iconInline(this.cancel.pending ? 'state.wait' : 'action.cancel'),
),
),
)
@ -176,7 +178,7 @@ export class PendingCountdown {
{ class: 'stack' },
this.phrase.el,
errorSlot,
h('div', { class: 'actions' }, submitBtn, h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Cancel', onclick: () => void this.doCancel() }, '✖️')),
h('div', { class: 'actions' }, submitBtn, h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Cancel', onclick: () => void this.doCancel() }, iconInline('action.cancel'))),
)
form.addEventListener('submit', (e) => {
e.preventDefault()
@ -188,7 +190,7 @@ export class PendingCountdown {
}
const { submit, errors } = this.commitForm as { submit: HTMLButtonElement; errors: HTMLDivElement }
submit.disabled = !phraseMatches(this.pending.phrase, this.phrase.value) || this.commit.pending
submit.textContent = this.commit.pending ? '⏳' : '✔️'
submit.replaceChildren(iconInline(this.commit.pending ? 'state.wait' : 'action.confirm'))
submit.setAttribute('aria-label', this.commit.pending ? 'Committing…' : 'Commit')
errors.replaceChildren(...(this.commit.error ? [errorNotice(this.commit.error)] : []))
}

View File

@ -3,8 +3,10 @@
// is the friction. The server re-checks; this field only helps get it right.
// The input is built once, so typing never loses focus or caret position.
import { iconInline } from '../icons/render'
import { h } from '../lib/dom'
import { uid } from '../lib/ids'
import { glyph } from '../ui/build'
import { phraseMatches } from './catalog'
export interface PhraseFieldOptions {
@ -48,7 +50,7 @@ export class PhraseField {
this.el = h(
'div',
{ class: 'phrase' },
h('label', { for: id, class: 'field-label' }, h('span', { 'aria-hidden': 'true' }, '⌨️'), h('span', { class: 'sr-only' }, label)),
h('label', { for: id, class: 'field-label' }, glyph('phrase.field', label)),
this.target,
this.input,
h('p', { class: 'sr-only' }, `Phrase: ${phrase}`),
@ -71,12 +73,12 @@ export class PhraseField {
this.input.className = `input mono ${ok ? 'input-ok' : prefixOk ? '' : 'input-bad'}`.trim()
this.input.setAttribute('aria-invalid', String(!prefixOk))
this.status.className = `field-help ${ok ? 'text-success' : prefixOk ? '' : 'text-danger'}`.trim()
// Textgate: ✅ / count / ❌ painted; the sentence is spoken only.
// Textgate: yes mark / count / no mark painted; the sentence is spoken only.
const [mark, spoken] = ok
? ['✅', 'Matches.']
? [iconInline('state.yes'), 'Matches.']
: prefixOk
? [`${typed.length}/${this.phrase.length}`, `${typed.length} of ${this.phrase.length} characters`]
: ['❌', 'Does not match — check case and spacing.']
: [iconInline('state.no'), 'Does not match — check case and spacing.']
this.status.replaceChildren(h('span', { 'aria-hidden': 'true' }, mark), h('span', { class: 'sr-only' }, spoken))
}
}

View File

@ -5,7 +5,7 @@
import { api } from '../api/client'
import { q } from '../api/queries'
import { iconMark, iconWord } from '../icons/render'
import { iconInline, iconMark, iconWord } from '../icons/render'
import { define, h, hx } from '../lib/dom'
import { runner, jobHref, type RunRequest } from '../lib/runner'
import { errorNotice, loading, notice } from '../ui/build'
@ -117,8 +117,8 @@ export class RunnerDialogElement extends HTMLElement {
h(
'div',
{ class: 'actions' },
h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Close (job keeps running)', onclick: () => { this.close() } }, '✖️'),
h('a', { href: jobHref(next.id), class: 'btn btn-ghost', 'aria-label': 'Open in Jobs' }, '⚙️'),
h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Close (job keeps running)', onclick: () => { this.close() } }, iconInline('action.cancel')),
h('a', { href: jobHref(next.id), class: 'btn btn-ghost', 'aria-label': 'Open in Jobs' }, iconInline('nav.jobs')),
),
),
)

View File

@ -5,11 +5,11 @@
import { ApiFailure, startJob } from '../api/client'
import type { CommandName, CommandSpec } from '../api/contract'
import { q } from '../api/queries'
import { iconMark, iconWord } from '../icons/render'
import { iconInline, iconMark, iconWord } from '../icons/render'
import { Action } from '../lib/action'
import { h } from '../lib/dom'
import type { Preset } from '../lib/runner'
import { commandLine, errorNotice, notice, pill } from '../ui/build'
import { errorNotice } from '../ui/build'
import { commandIcon, fillPhrase, phraseMatches } from './catalog'
import { enforcePreset } from './enforcePreset'
import { gameLookup } from './gameLookup'
@ -17,29 +17,13 @@ import { initialValues, paramError, toParams, type ParamValues } from './params'
import { ParamsForm } from './paramsForm'
import { PendingCountdown } from './pendingCountdown'
import { PhraseField } from './phraseField'
import { commandFlags, fillHint, lockedNotice, terminalFallback } from './runnerParts'
/** Recovery commands the UI offers when the root daemon is down. */
const FALLBACK: Partial<Record<CommandName, string>> = {
'gaming-unblock': 'sudo ./run.sh gaming-unblock',
}
/** ⏳ plus the minutes (a number, so painted); the word is spoken only. */
function countdownPill(seconds: number): HTMLSpanElement {
const minutes = Math.round(seconds / 60)
const el = pill('warning', `${minutes} min countdown`, '⏳')
el.append(h('span', { class: 'pill-num', 'aria-hidden': 'true' }, `${minutes}′`))
return el
}
/** 🔒 warning notice; the server's lock reason is spoken only. */
function lockedNotice(reason: string): HTMLDivElement {
const el = notice('warning', null)
el.querySelector('.notice-icon')?.replaceChildren('🔒')
el.setAttribute('aria-label', `Locked: ${reason}`)
return el
}
export type NextPhase = { k: 'pending'; countdown: PendingCountdown } | { k: 'job'; id: string } | { k: 'form'; runner: Runner }
export interface RunnerCallbacks {
@ -85,7 +69,6 @@ export class Runner {
this.start = new Action(startJob, () => {
this.refresh()
})
const countdown = spec.friction?.countdown_seconds
this.submitBtn = h('button', {
type: 'submit',
class: 'btn btn-primary',
@ -100,10 +83,7 @@ export class Runner {
'div',
{ class: 'tags' },
h('span', { class: 'runner-mark' }, iconMark(commandIcon(spec.name), 'runner-glyph'), iconWord(commandIcon(spec.name))),
spec.privileged ? pill('neutral', 'Runs as root via the daemon', '🔑') : null,
spec.mutating ? pill('neutral', 'Changes state', '✏️') : pill('neutral', 'Read-only', '👁️'),
spec.cancellable ? pill('neutral', 'Cancellable', '⏹️') : null,
countdown ? countdownPill(countdown) : null,
commandFlags(spec),
),
spec.locked_reason !== null ? lockedNotice(spec.locked_reason) : null,
this.form.nodes,
@ -113,7 +93,7 @@ export class Runner {
'div',
{ class: 'actions' },
this.submitBtn,
h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Cancel', onclick: () => { cb.onClose() } }, '✖️'),
h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Cancel', onclick: () => { cb.onClose() } }, iconInline('action.cancel')),
),
)
this.el.addEventListener('submit', (e) => {
@ -159,10 +139,7 @@ export class Runner {
if (key !== this.phraseKey) {
this.phraseKey = key
if (phrase && phrase.missing.length > 0) {
// ℹ️ ⬆️: fill the fields above first; the sentence is spoken only.
const hint = notice('info', null, h('span', { 'aria-hidden': 'true' }, '⬆️'))
hint.setAttribute('aria-label', `Fill in the fields above to see the exact phrase (${phrase.missing.join(', ')}).`)
this.phraseSlot.replaceChildren(hint)
this.phraseSlot.replaceChildren(fillHint(phrase.missing))
} else if (phrase && !locked) {
this.typed = ''
const field = new PhraseField({
@ -187,7 +164,7 @@ export class Runner {
errorNotice(
err,
failure?.code === 'daemon_unreachable' && fallback
? [h('p', { class: 'm0', 'aria-label': 'Run it from a terminal instead:' }, h('span', { 'aria-hidden': 'true' }, '💻')), commandLine(fallback)]
? terminalFallback(fallback)
: null,
),
]
@ -196,8 +173,8 @@ export class Runner {
const countdown = this.spec.friction?.countdown_seconds
this.submitBtn.className = phrase ? 'btn btn-danger' : 'btn btn-primary'
this.submitBtn.disabled = !this.canSubmit() || this.start.pending
// Glyph painted, label spoken: ⏳ starting, ⏲️ arm countdown, ▶️ run.
this.submitBtn.textContent = this.start.pending ? '⏳' : countdown ? '⏲️' : '▶️'
// Icon painted, label spoken: busy while starting, arm countdown, or run.
this.submitBtn.replaceChildren(iconInline(this.start.pending ? 'state.wait' : countdown ? 'runner.arm' : 'runner.run'))
this.submitBtn.setAttribute('aria-label', this.start.pending ? 'Starting…' : countdown ? 'Arm countdown' : `Run ${this.spec.name}`)
}

View File

@ -0,0 +1,50 @@
// The small painted parts of the runner form: the command's flags, the lock
// notice, the "fill the fields" hint and the terminal fallback. Every icon is
// a registered id, so the user's word and glyph apply; each sentence is
// spoken only (aria-label / pill text).
import type { CommandSpec } from '../api/contract'
import { iconInline } from '../icons/render'
import { h } from '../lib/dom'
import { commandLine, notice, pill } from '../ui/build'
/** The countdown flag plus the minutes (a number, so painted); the word is spoken only. */
function countdownPill(seconds: number): HTMLSpanElement {
const minutes = Math.round(seconds / 60)
const el = pill('warning', `${minutes} min countdown`, 'cmdflag.countdown')
el.append(h('span', { class: 'pill-num', 'aria-hidden': 'true' }, `${minutes}′`))
return el
}
/** What the command is: root, state-changing or read-only, cancellable, countdown. */
export function commandFlags(spec: CommandSpec): (HTMLSpanElement | null)[] {
const countdown = spec.friction?.countdown_seconds
return [
spec.privileged ? pill('neutral', 'Runs as root via the daemon', 'cmdflag.root') : null,
spec.mutating ? pill('neutral', 'Changes state', 'cmdflag.mutating') : pill('neutral', 'Read-only', 'cmdflag.readonly'),
spec.cancellable ? pill('neutral', 'Cancellable', 'cmdflag.cancellable') : null,
countdown ? countdownPill(countdown) : null,
]
}
/** Warning notice painted with the lock mark; the server's lock reason is spoken only. */
export function lockedNotice(reason: string): HTMLDivElement {
const el = notice('warning', null)
const mark = iconInline('state.locked', 'notice-icon')
if (mark.classList.contains('icon-inline')) mark.classList.add('notice-mark')
el.firstElementChild?.replaceWith(mark)
el.setAttribute('aria-label', `Locked: ${reason}`)
return el
}
/** Info notice: fill the fields above first; the sentence is spoken only. */
export function fillHint(missing: readonly string[]): HTMLDivElement {
const hint = notice('info', null, iconInline('runner.fill'))
hint.setAttribute('aria-label', `Fill in the fields above to see the exact phrase (${missing.join(', ')}).`)
return hint
}
/** The terminal command to run when the daemon cannot be reached. */
export function terminalFallback(command: string): HTMLElement[] {
return [h('p', { class: 'm0', 'aria-label': 'Run it from a terminal instead:' }, iconInline('runner.terminal')), commandLine(command)]
}

View File

@ -0,0 +1,56 @@
// Completeness gate for the icon words: every icon the UI paints comes from
// the registry (icons/registry.json), so the /words picker covers the whole
// UI. This scans the source, not a rendered page: a pictograph or an icon
// symbol typed as a literal in any non-test file is an unregistered icon.
// Comments are ignored; the picker's own controls and the palette's key
// hints are the only allowed literals, named below.
import { readdirSync, readFileSync } from 'node:fs'
import { join, relative } from 'node:path'
import { describe, expect, it } from 'vitest'
import { ICONS } from './registry'
const SRC = join(import.meta.dirname, '..')
/** Pictographs, plus the symbol icons the UI paints (Σ ∅ ↺ ✕ ↵ ▲ ▼ ∞ and arrows). */
const ICON_LITERAL = /\p{Extended_Pictographic}|[Σ∅↺✕↵▲▼∞←→↑↓]|'×'|\u{FE0F}/u
/** The /words picker's own controls and keyboard hints: text, not UI icons. */
const ALLOWED = ["'← back'", "'forward →'", "'↑↓ · ⏎ · ⎋'", "'↑↓ to move · Enter to run · Esc to close'","{ class: 'm0' }, '✅')"]
function sourceFiles(dir: string): string[] {
return readdirSync(dir, { recursive: true, encoding: 'utf8' })
.map((f) => join(dir, f))
.filter((f) => /\.(ts|astro)$/.test(f) && !f.endsWith('.test.ts') && !f.includes(`${join(SRC, 'test')}/`))
}
function code(text: string): string {
const noBlocks = text.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' ')).replace(/<!--[\s\S]*?-->/g, (m) => m.replace(/[^\n]/g, ' '))
return noBlocks.replace(/(^|\s)\/\/.*$/gm, '$1')
}
/** `file:line` of every line that paints an icon literal. */
function unregistered(): string[] {
const hits: string[] = []
for (const file of sourceFiles(SRC)) {
const lines = code(readFileSync(file, 'utf8')).split('\n')
lines.forEach((line, i) => {
const bare = ALLOWED.reduce((s, a) => s.split(a).join(''), line)
if (ICON_LITERAL.test(bare)) hits.push(`${relative(SRC, file)}:${i + 1}`)
})
}
return hits
}
describe('icon words cover the whole UI', () => {
it('no source file paints an icon outside the registry', () => {
const hits = unregistered()
expect(hits, `${hits.length} unregistered icon sites`).toEqual([])
})
it('the first 45 registry entries are the answered pass-1 icons, so the picker opens after them', () => {
const ids = ICONS.map((e) => e.id)
expect(ids.slice(0, 45).filter((id) => /^(nav|palette|cmd|job\.state|notice)\./.test(id))).toHaveLength(45)
expect(ids[44]).toBe('notice.danger')
})
})

11
web/src/icons/iconText.ts Normal file
View File

@ -0,0 +1,11 @@
// An icon as plain text, for the places that cannot hold markup: an input's
// placeholder or an <option>. The glyph (the user's alternative applied),
// then his word right of it when he chose one.
import type { IconId } from './registry'
import { iconFor } from './render'
export function iconText(id: IconId): string {
const { glyph, word } = iconFor(id)
return word ? `${glyph} ${word}` : glyph
}

View File

@ -0,0 +1,72 @@
// iconInline: the painted-only icon (no spoken text) used inside said(...),
// buttons and labels, plus the shared builders that now take ids.
import { describe, expect, it } from 'vitest'
import { useIcons } from '../test/iconLedger'
import { copyButton, empty, pill } from '../ui/build'
import { setWordsHidden } from './ledger'
import { iconInline } from './render'
describe('iconInline', () => {
it('is the glyph mark alone when there is no word', () => {
const el = iconInline('state.wait', 'x')
expect(el.textContent).toBe('⏳')
expect(el).toHaveAttribute('aria-hidden', 'true')
expect(el).toHaveAttribute('data-icon', 'state.wait')
expect(el).toHaveClass('x')
})
it('paints the chosen alternative glyph', () => {
useIcons({ 'state.wait': { word: null, glyph: '⌛' } })
expect(iconInline('state.wait').textContent).toBe('⌛')
})
it('puts the word right of the icon in one row, both aria-hidden', () => {
useIcons({ 'state.wait': { word: 'busy' } })
const el = iconInline('state.wait')
expect(el).toHaveClass('icon-inline', 'has-word')
const [icon, word] = [...el.children]
expect(icon.textContent).toBe('⏳')
expect(word).toHaveClass('icon-word')
expect(word).toHaveAttribute('aria-hidden', 'true')
expect(word.textContent).toBe('Busy')
})
it('draws no word while words are hidden', () => {
useIcons({ 'state.wait': { word: 'busy' } })
setWordsHidden(true)
expect(iconInline('state.wait').querySelector('.icon-word')).toBeNull()
setWordsHidden(false)
})
})
describe('builders that take ids', () => {
it('empty paints the empty icon and its word, the sentence stays spoken', () => {
useIcons({ 'state.empty': { word: 'nothing' } })
const el = empty('No games')
expect(el.querySelector('.empty-icon')?.textContent).toBe('📭')
expect(el.querySelector('.icon-word')?.textContent).toBe('Nothing')
expect(el.querySelector('.sr-only')?.textContent).toBe('No games')
})
it('pill paints its icon, word and spoken text', () => {
useIcons({ 'state.warn': { word: 'attention', glyph: '🟠' } })
const el = pill('warning', 'locked', 'state.warn')
expect(el.className).toBe('pill pill-warning')
expect(el.querySelector('.pill-icon')?.textContent).toBe('🟠')
expect(el.querySelector('.icon-word')?.textContent).toBe('Attention')
expect(el.querySelector('.sr-only')?.textContent).toBe('locked')
})
it('copyButton paints its icon and word, then the done icon after a copy', async () => {
useIcons({ 'copy.command': { word: 'copy' }, 'copy.done': { word: 'copied', glyph: '🎉' } })
Object.defineProperty(navigator, 'clipboard', { value: { writeText: () => Promise.resolve() }, configurable: true })
const btn = copyButton('sudo x')
expect(btn.textContent).toBe('📋Copy')
btn.click()
await Promise.resolve()
await Promise.resolve()
expect(btn.textContent).toBe('🎉Copied')
expect(btn).toHaveAttribute('aria-label', 'Copied')
})
})

View File

@ -45,6 +45,224 @@
"notice.info": { "glyph": "ℹ️", "spoken": "Information", "desc": "Mark on an information notice: a neutral fact or a hint.", "words": ["info", "note", "hint"], "alts": ["💡", "🔷", "📢"] },
"notice.success": { "glyph": "✅", "spoken": "Success", "desc": "Mark on a success notice: the action worked.", "words": ["success", "ok", "done"], "alts": ["✔️", "🎉", "👍"] },
"notice.warning": { "glyph": "⚠️", "spoken": "Warning", "desc": "Mark on a warning notice: something needs your attention, but nothing failed.", "words": ["warning", "caution", "careful"], "alts": ["🟡", "🔶", "❗"] },
"notice.danger": { "glyph": "⛔", "spoken": "Error", "desc": "Mark on an error notice: something failed or was refused. The server's message follows it.", "words": ["error", "danger", "problem"], "alts": ["🛑", "‼️", "🔴"] }
"notice.danger": { "glyph": "⛔", "spoken": "Error", "desc": "Mark on an error notice: something failed or was refused. The server's message follows it.", "words": ["error", "danger", "problem"], "alts": ["🛑", "‼️", "🔴"] },
"state.yes": { "glyph": "✅", "spoken": "Yes", "desc": "Marks a yes in a row: the thing is on, present, current or matching.", "words": ["yes", "on", "present"], "alts": ["🟢", "👍", "🆗"] },
"state.no": { "glyph": "❌", "spoken": "No", "desc": "Marks a no in a row: the thing is missing, off or does not match.", "words": ["no", "missing", "wrong"], "alts": ["🙅", "🔴", "👎"] },
"state.off": { "glyph": "➖", "spoken": "Off", "desc": "Marks an empty value in a row: off, none or not set.", "words": ["none", "off", "blank"], "alts": ["⚪", "⬜", "🕳️"] },
"state.warn": { "glyph": "⚠️", "spoken": "Needs attention", "desc": "Marks a row or label that needs attention: stale, unavailable or not ready. Nothing has failed yet.", "words": ["attention", "stale", "caution"], "alts": ["🟠", "❗", "🚧"] },
"state.wait": { "glyph": "⏳", "spoken": "Busy", "desc": "Shows that a button or row is busy: saving, sending, restarting or counting down.", "words": ["busy", "waiting", "working"], "alts": ["⌛", "💤", "🌀"] },
"state.empty": { "glyph": "📭", "spoken": "Nothing here", "desc": "Empty state: there is nothing to show yet, such as no data or no games.", "words": ["empty", "nothing", "vacant"], "alts": ["📪", "🕸️", "🫙"] },
"state.unknown": { "glyph": "❔", "spoken": "Unknown", "desc": "Unknown value: the data is missing or its kind is not recognised. It also shows a play style that is not known yet.", "words": ["unknown", "unclear", "mystery"], "alts": ["❓", "🤷", "🫥"] },
"state.locked": { "glyph": "🔒", "spoken": "Locked", "desc": "Locked: the command or action cannot run right now. The reason is read aloud.", "words": ["locked", "closed", "sealed"], "alts": ["🔐", "🚧", "⛓️"] },
"state.unlocked": { "glyph": "🔓", "spoken": "Unlocked", "desc": "Unlocked: the action is open and free to use.", "words": ["unlocked", "open", "free"], "alts": ["🗝️", "🚪", "🔑"] },
"action.cancel": { "glyph": "✖️", "spoken": "Cancel", "desc": "Button that cancels or closes the open form, dialog or countdown without doing anything.", "words": ["cancel", "close", "dismiss"], "alts": ["❌", "↩️", "🚪"] },
"action.confirm": { "glyph": "✔️", "spoken": "Confirm", "desc": "Button that confirms: it saves the form or sends the answer.", "words": ["confirm", "save", "accept"], "alts": ["✅", "💾", "👍"] },
"action.open": { "glyph": "➡️", "spoken": "Open", "desc": "Link on a card that opens the page behind it, such as the details or the full list.", "words": ["open", "details", "more"], "alts": ["↗️", "🔗", "⏩"] },
"copy.command": { "glyph": "📋", "spoken": "Copy command", "desc": "Button that copies a shell command to the clipboard. It is the way out when the UI cannot act itself.", "words": ["copy", "clipboard", "duplicate"], "alts": ["📎", "📄", "🗒️"] },
"copy.done": { "glyph": "✅", "spoken": "Copied", "desc": "Replaces the copy button for two seconds after the copy worked.", "words": ["copied", "done", "saved"], "alts": ["✔️", "👌", "🎉"] },
"dash.ago": { "glyph": "🕓", "spoken": "Ago", "desc": "Shown before a time span that says how long ago something happened, such as a recent job or the live verdict.", "words": ["ago", "age", "since"], "alts": ["🕰️", "⏰", "📆"] },
"dash.finished": { "glyph": "🏆", "spoken": "Games finished", "desc": "Marks the number of games you finished with every achievement. It labels the dashboard row and the base of your pace estimate.", "words": ["finished", "trophies", "completed"], "alts": ["🥇", "🎖️", "🏁"] },
"dash.store": { "glyph": "🛒", "spoken": "Store", "desc": "Row label on the dashboard: whether the Steam store is blocked right now.", "words": ["store", "shop", "market"], "alts": ["🏪", "🛍️", "🧾"] },
"dash.store-blocked": { "glyph": "🔒", "spoken": "Store blocked", "desc": "Value of the store row on the dashboard: the Steam store is blocked.", "words": ["blocked", "closed", "shut"], "alts": ["🚫", "🔐", "🚧"] },
"dash.store-open": { "glyph": "🔓", "spoken": "Store unblocked", "desc": "Value of the store row on the dashboard: the Steam store is unblocked for now. It blocks itself again later.", "words": ["open", "unblocked", "free"], "alts": ["🟢", "🚪", "🗝️"] },
"dash.games": { "glyph": "🗂️", "spoken": "Installed games", "desc": "Row label on the dashboard: how many games are installed on this PC.", "words": ["games", "library", "count"], "alts": ["🎮", "📦", "🗃️"] },
"dash.total-block": { "glyph": "⛔", "spoken": "Total block", "desc": "Row label on the dashboard: the total gaming block. While it is active the row counts down the time left.", "words": ["block", "ban", "lockdown"], "alts": ["🚷", "🧱", "📵"] },
"picks.manual": { "glyph": "📌", "spoken": "Manual picks", "desc": "Marks your manual picks, the games you locked in by hand. It heads the picks card and labels the dashboard row.", "words": ["manual", "pinned", "chosen"], "alts": ["📍", "🧷", "🖐️"] },
"assigned.game": { "glyph": "🎯", "spoken": "Assigned game", "desc": "Marks the game assigned to you. It heads the assignment card, tags the game in the library and sits beside the live verdict.", "words": ["assigned", "target", "current"], "alts": ["🏹", "🥅", "⭐"] },
"dash.block-left": { "glyph": "⏳", "spoken": "Time left", "desc": "Time left on the total gaming block, shown as a countdown.", "words": ["left", "remaining", "countdown"], "alts": ["⌛", "⏲️", "🕰️"] },
"dash.budget": { "glyph": "⏱️", "spoken": "Gaming today", "desc": "Heading of the budget card on the dashboard. It shows how much gaming time is left today.", "words": ["budget", "timer", "allowance"], "alts": ["⏲️", "🕹️", "🪙"] },
"dash.blocked-today": { "glyph": "⛔", "spoken": "Blocked for today", "desc": "Shown on the budget card when gaming is blocked for the rest of the day.", "words": ["blocked", "banned", "stopped"], "alts": ["🚫", "🛑", "🔴"] },
"dash.not-billing": { "glyph": "⏸️", "spoken": "Nothing billing", "desc": "Shown while no game is running, so no gaming time is used. It marks the budget line and the live verdict.", "words": ["idle", "paused", "resting"], "alts": ["⏯️", "💤", "🟦"] },
"dash.billing": { "glyph": "▶️", "spoken": "Billing now", "desc": "Shown while a game is running and its time counts against today's budget. It marks the budget line and the live verdict.", "words": ["playing", "billing", "counting"], "alts": ["⏺️", "🔴", "🎮"] },
"dash.fast-failed": { "glyph": "⛔", "spoken": "Fast install failed", "desc": "A fast install failed. The daemon's own message follows it.", "words": ["failed", "error", "broken"], "alts": ["💥", "❌", "🔴"] },
"dash.steam-took-over": { "glyph": "↪️", "spoken": "Steam took over", "desc": "Note under a failed fast install: Steam's own download took over.", "words": ["fallback", "handover", "detour"], "alts": ["↩️", "🔀", "🔁"] },
"dash.fast-install": { "glyph": "⚡", "spoken": "Fast install", "desc": "A fast install is running. It heads the fast install card and marks each running download.", "words": ["fast", "turbo", "quick"], "alts": ["🚀", "💨", "⏩"] },
"dash.elapsed": { "glyph": "⏳", "spoken": "Elapsed", "desc": "Time a fast install has been running so far.", "words": ["elapsed", "running", "duration"], "alts": ["⌛", "🕐", "⏱️"] },
"dash.recent-jobs": { "glyph": "⚙️", "spoken": "Recent jobs", "desc": "Heading of the recent jobs card on the dashboard. It lists the last five jobs with their state.", "words": ["jobs", "recent", "history"], "alts": ["🛠️", "📜", "🗒️"] },
"dash.outlook": { "glyph": "📚", "spoken": "Backlog outlook", "desc": "Heading of the backlog outlook card on the dashboard: the planner summary at the default filters.", "words": ["backlog", "outlook", "forecast"], "alts": ["📖", "🔮", "🗓️"] },
"picks.age": { "glyph": "🕐", "spoken": "Picked days ago", "desc": "Marks how many days ago a manual pick was made. The app id follows it.", "words": ["picked", "age", "days"], "alts": ["📆", "🕰️", "⏳"] },
"picks.kept": { "glyph": "📌", "spoken": "Kept", "desc": "Marks a pick that was released but kept: the game stays installed and playable.", "words": ["kept", "released", "spared"], "alts": ["📎", "💚", "🔖"] },
"store.blocked": { "glyph": "🛒🔒", "spoken": "Store blocked", "desc": "Notice on the store page: the Steam store is blocked. Unblocking takes a typed phrase and lasts at most 30 minutes.", "words": ["blocked", "closed", "sealed"], "alts": ["🚫", "🔐", "🛑"] },
"store.open": { "glyph": "🛒🔓", "spoken": "Store unblocked", "desc": "Notice on the store page: the Steam store is open right now. It blocks itself again after the timer runs out.", "words": ["open", "unblocked", "live"], "alts": ["🏪", "🟢", "🚪"] },
"setup.help": { "glyph": "🔗", "spoken": "Where to get it", "desc": "Link next to a setup field that opens the page where you get the value.", "words": ["link", "source", "help"], "alts": ["🌍", "🧭", "📎"] },
"setup.key-stored": { "glyph": "🔒", "spoken": "Key stored", "desc": "Shown when the Steam API key is already stored, in the setup field and the system row. The key stays hidden, and typing a new key replaces it.", "words": ["stored", "saved", "secret"], "alts": ["🔐", "🗝️", "🛡️"] },
"setup.api-key": { "glyph": "🔑", "spoken": "Steam Web API key", "desc": "Marks the Steam Web API key: the field on the setup page where you paste it, and the system row that shows if one is stored.", "words": ["key", "token", "secret"], "alts": ["🗝️", "🔐", "🪪"] },
"setup.steam-id": { "glyph": "🆔", "spoken": "SteamID64", "desc": "Marks the SteamID: the field on the setup page for your 17-digit profile number, and the system row that shows it.", "words": ["id", "profile", "account"], "alts": ["🪪", "👤", "🔢"] },
"libpage.all": { "glyph": "🗂️", "spoken": "All games", "desc": "Switch on the library page that shows every game you own as a cover grid.", "words": ["all", "covers", "owned"], "alts": ["🖼️", "🧩", "🗃️"] },
"libpage.game": { "glyph": "🎮", "spoken": "Game", "desc": "Marks a game: the game column of the installed table and the number of installed games.", "words": ["game", "title", "count"], "alts": ["🕹️", "👾", "🃏"] },
"libpage.app-id": { "glyph": "#", "spoken": "App id", "desc": "Header of the app id column in the installed table: the Steam number of each game.", "words": ["number", "appid", "index"], "alts": ["🔢", "🆔", "🔖"] },
"libpage.size": { "glyph": "💽", "spoken": "Size", "desc": "Size on disk: the size column header and the total of all installed games.", "words": ["size", "space", "disk"], "alts": ["📏", "🧮", "⚖️"] },
"libpage.role": { "glyph": "🏷️", "spoken": "Role", "desc": "Header of the role column in the installed table: whether a game is assigned, protected or removable.", "words": ["role", "status", "tag"], "alts": ["🔖", "🎭", "🪪"] },
"libpage.protected": { "glyph": "🛡️", "spoken": "Protected", "desc": "Tags an installed game that is protected, so uninstall never removes it.", "words": ["protected", "safe", "shielded"], "alts": ["🔰", "🔐", "🧱"] },
"libpage.candidate": { "glyph": "🗑️", "spoken": "Uninstall candidate", "desc": "Marks an installed game that is neither assigned nor protected, so uninstall would remove it.", "words": ["removable", "trash", "surplus"], "alts": ["🧹", "♻️", "🪣"] },
"jobs.command": { "glyph": "⌨️", "spoken": "Command", "desc": "Header of the command column in the job history.", "words": ["command", "action", "task"], "alts": ["💻", "🔤", "🧰"] },
"jobs.state": { "glyph": "🚦", "spoken": "State", "desc": "Header of the state column in the job history: queued, running, finished or failed.", "words": ["state", "status", "outcome"], "alts": ["🟢", "📶", "🚥"] },
"jobs.started": { "glyph": "🕐", "spoken": "Started", "desc": "When a job started: the started column of the job history and the created time on a job page.", "words": ["started", "created", "when"], "alts": ["🕒", "📅", "🕰️"] },
"jobs.took": { "glyph": "⏱️", "spoken": "Took", "desc": "Header of the duration column in the job history: how long each job ran.", "words": ["took", "duration", "length"], "alts": ["⏲️", "⌛", "📏"] },
"jobs.not-found": { "glyph": "❓", "spoken": "Job not found", "desc": "Marks a job page whose id does not exist. The history keeps only the last 50 jobs.", "words": ["missing", "unknown", "gone"], "alts": ["❔", "🔍", "🕳️"] },
"jobs.all": { "glyph": "📋", "spoken": "All jobs", "desc": "Link to the job history list, shown on a job page and on a missing job.", "words": ["all", "list", "history"], "alts": ["📜", "🗒️", "📚"] },
"jobs.job": { "glyph": "⚙️", "spoken": "Job", "desc": "Heading of a job page while the job loads.", "words": ["job", "task", "work"], "alts": ["🔧", "🛠️", "🧰"] },
"jobs.waiting": { "glyph": "⏳", "spoken": "Waiting for you", "desc": "Phase mark on a job page when the job waits for your answer.", "words": ["waiting", "paused", "pending"], "alts": ["⌛", "✋", "💤"] },
"jobs.cancel": { "glyph": "✕", "spoken": "Cancel job", "desc": "Button on a running job that asks it to stop. It appears only for jobs that can be cancelled.", "words": ["stop", "cancel", "abort"], "alts": ["🛑", "⏹️", "✖️"] },
"jobs.log": { "glyph": "📋", "spoken": "Log", "desc": "Marks the job log: it shows the number of log lines and opens the log.", "words": ["log", "lines", "output"], "alts": ["📜", "📄", "🧾"] },
"prompt.question": { "glyph": "❓", "spoken": "Job question", "desc": "Marks a question a job asks you. The job waits until you answer.", "words": ["question", "ask", "prompt"], "alts": ["❔", "💬", "🙋"] },
"prompt.own-game": { "glyph": "🗂️", "spoken": "Choose your own game", "desc": "Choice in a job question that lets you pick any game from your library instead of the offered ones.", "words": ["own", "browse", "other"], "alts": ["🔎", "📂", "🎮"] },
"prompt.yes": { "glyph": "✔️", "spoken": "Yes", "desc": "Button that answers yes to a job question.", "words": ["yes", "accept", "agree"], "alts": ["✅", "👍", "🆗"] },
"prompt.no": { "glyph": "✖️", "spoken": "No", "desc": "Button that answers no to a job question.", "words": ["no", "decline", "refuse"], "alts": ["❌", "👎", "🚫"] },
"prompt.answer": { "glyph": "↵", "spoken": "Answer", "desc": "Button that sends your answer to a job question. The Enter key does the same.", "words": ["send", "answer", "submit"], "alts": ["⏎", "📤", "➡️"] },
"prompt.back": { "glyph": "↩️", "spoken": "Back to the list", "desc": "Button that returns from the game picker to the previous question of the job.", "words": ["back", "return", "previous"], "alts": ["◀️", "⬅️", "🔙"] },
"prompt.games": { "glyph": "🎮", "spoken": "Games to pick from", "desc": "Shows how many games a job offers to pick from in a game question.", "words": ["choices", "games", "options"], "alts": ["🕹️", "🔢", "🧮"] },
"prompt.pick": { "glyph": "🎯", "spoken": "Pick this game", "desc": "Button that sends the game you selected as the answer. It shows the game name once you select one.", "words": ["pick", "select", "choose"], "alts": ["🏹", "✅", "📌"] },
"jobchip.needs-input": { "glyph": "✋", "spoken": "Needs input", "desc": "Shown on a job chip in the top bar when the job waits for your answer.", "words": ["answer", "halt", "hand"], "alts": ["🙋", "🔔", "🛑"] },
"dash.installed": { "glyph": "💾", "spoken": "Installed", "desc": "Marks a game that is installed on this PC. It labels the dashboard row, the library filter and table, and the badge on a game.", "words": ["installed", "disk", "local"], "alts": ["📥", "🗃️", "🖥️"] },
"gaming.series.other": { "glyph": "➕", "spoken": "Other games", "desc": "Legend and list entry that groups the many small games of the chart into one segment.", "words": ["other", "rest", "remainder"], "alts": ["🧩", "🗃️", "🔢"] },
"gaming.series.unattributed": { "glyph": "❔", "spoken": "Unattributed", "desc": "Legend entry for gaming time that no single game could be charged for.", "words": ["unattributed", "unclaimed", "orphan"], "alts": ["🫥", "🕳️", "👻"] },
"gaming.launcher": { "glyph": "🚀", "spoken": "Launcher", "desc": "Marks a game launcher such as a store client. It also labels the rule that counts launcher time against the budget.", "words": ["launcher", "client", "starter"], "alts": ["🛫", "🛸", "🏁"] },
"gaming.cutoff.masked": { "glyph": "⛔🔒", "spoken": "Cutoff, launchers masked", "desc": "Badge on a blocked day: the cutoff is engaged and the launchers are masked, so no game can start.", "words": ["cutoff", "masked", "sealed"], "alts": ["🚫🔒", "🛑🔐", "⛓️"] },
"gaming.cutoff.unmasked": { "glyph": "⛔🔓", "spoken": "Cutoff, launchers not masked", "desc": "Badge on a blocked day: the cutoff is engaged but no launcher is masked right now. That happens after a total block released the mounts.", "words": ["unmasked", "exposed", "leaking"], "alts": ["🚫🔓", "🛑🔓", "🪟"] },
"gaming.warn.none": { "glyph": "🔕", "spoken": "No more warnings", "desc": "Shows that no further warning fires today. The enforcer has already sent the last one.", "words": ["silent", "quiet", "muted"], "alts": ["🤫", "🔇", "💤"] },
"gaming.warning": { "glyph": "🔔", "spoken": "Warning", "desc": "The time of the next warning on today's card and the warning times in the rules card. The enforcer warns you when the remaining budget reaches them.", "words": ["warning", "alarm", "bell"], "alts": ["⏰", "📣", "🚨"] },
"gaming.day": { "glyph": "📅", "spoken": "Gaming day", "desc": "The date of the gaming day that today's budget belongs to.", "words": ["date", "day", "calendar"], "alts": ["🗓️", "📆", "📖"] },
"gaming.day_start": { "glyph": "🌅", "spoken": "Day starts", "desc": "The local time when the gaming day rolls over and the budget refills.", "words": ["sunrise", "rollover", "refill"], "alts": ["🌄", "⏰", "🔁"] },
"gaming.by_game": { "glyph": "🎮", "spoken": "Today by game", "desc": "Heading of the list that splits today's billed time by game.", "words": ["games", "split", "breakdown"], "alts": ["🕹️", "🎲", "👾"] },
"gaming.right_now": { "glyph": "📡", "spoken": "Right now", "desc": "Heading of the live card with the daemon's latest verdict on what the budget is charging.", "words": ["live", "now", "verdict"], "alts": ["📶", "🛰️", "🔴"] },
"gaming.qualifying": { "glyph": "⚙️", "spoken": "Qualifying processes", "desc": "The number of running processes that count as gaming and bill the budget.", "words": ["processes", "counted", "running"], "alts": ["🧮", "🔢", "🧩"] },
"gaming.billing_to": { "glyph": "💸", "spoken": "Billing to", "desc": "Names the game or launcher that the budget is charging right now.", "words": ["charging", "spending", "cost"], "alts": ["💰", "🪙", "💳"] },
"gaming.billed_last": { "glyph": "⏮️💸", "spoken": "Last billed to", "desc": "Names the game or launcher that was charged last, once nothing qualifies any more.", "words": ["previous", "last", "former"], "alts": ["🧾", "⏪💸", "📜"] },
"gaming.history": { "glyph": "📊", "spoken": "Last 14 days", "desc": "Heading of the chart with the billed gaming time of each of the last 14 days.", "words": ["history", "chart", "trend"], "alts": ["📈", "🗓️", "📉"] },
"gaming.rules": { "glyph": "📏", "spoken": "Rules in effect", "desc": "Heading of the card that lists the budget rules the enforcer applies right now.", "words": ["rules", "limits", "policy"], "alts": ["📐", "📜", "⚖️"] },
"gaming.budget": { "glyph": "⏱️", "spoken": "Daily budget", "desc": "Row label for how much gaming time one day allows.", "words": ["budget", "allowance", "quota"], "alts": ["⏲️", "🪙", "⌛"] },
"gaming.enforcement": { "glyph": "🛡️", "spoken": "Enforcement", "desc": "Row label that shows whether the enforcer cuts off gaming when the budget runs out.", "words": ["enforcement", "guard", "cutoff"], "alts": ["⚔️", "🚔", "🧱"] },
"gaming.mode": { "glyph": "🧪", "spoken": "Mode", "desc": "Row label for the budget mode, the real one or the demo.", "words": ["mode", "variant", "setting"], "alts": ["🎚️", "🔀", "🧭"] },
"gaming.demo": { "glyph": "🧪", "spoken": "Demo budget", "desc": "Marks the short demo budget with its separate state. As a link it switches the page to that demo.", "words": ["demo", "trial", "sandbox"], "alts": ["🔬", "🎬", "🧫"] },
"gaming.masked": { "glyph": "🔒", "spoken": "Masked launchers", "desc": "Row label that lists the launchers masked right now, so that they cannot start.", "words": ["masked", "hidden", "sealed"], "alts": ["🎭", "🚫", "🕶️"] },
"gaming.production": { "glyph": "🏭", "spoken": "Production budget", "desc": "Link shown on the demo page that switches back to the real daily budget.", "words": ["production", "real", "live"], "alts": ["🏢", "🌍", "🔙"] },
"daemon.heading": { "glyph": "🛡️", "spoken": "Enforcer daemon", "desc": "The root daemon that enforces the rules. It heads the daemon card and is the daemon badge in the top bar.", "words": ["daemon", "guard", "root"], "alts": ["🔐", "👮", "🏰"] },
"daemon.demo_run": { "glyph": "🧪", "spoken": "Demo run", "desc": "Button that opens the runner for a 60-second demo of the enforcer with a short budget.", "words": ["demo", "trial", "rehearsal"], "alts": ["🎬", "🔬", "🎭"] },
"daemon.journal": { "glyph": "📜", "spoken": "Journal", "desc": "Heading of the live tail of the daemon's log.", "words": ["journal", "log", "history"], "alts": ["📓", "🧾", "📰"] },
"daemon.state": { "glyph": "📡", "spoken": "State", "desc": "Row label for the daemon's current state.", "words": ["state", "status", "signal"], "alts": ["📶", "🩺", "🚦"] },
"daemon.running": { "glyph": "🟢", "spoken": "Running", "desc": "Daemon state: the daemon is up and answers.", "words": ["running", "alive", "up"], "alts": ["💚", "🔋", "👍"] },
"daemon.restarting": { "glyph": "🔄", "spoken": "Restarting", "desc": "Daemon state: the daemon is restarting and answers again in a moment.", "words": ["restarting", "cycling", "rebooting"], "alts": ["🔁", "🌀", "🟡"] },
"daemon.unreachable": { "glyph": "🔴", "spoken": "Unreachable", "desc": "Daemon state: the daemon does not answer, so the privileged actions are unavailable.", "words": ["unreachable", "down", "dead"], "alts": ["⚫", "💀", "📵"] },
"daemon.pid": { "glyph": "#️⃣", "spoken": "PID", "desc": "Row label for the process number of the running daemon.", "words": ["process", "number", "pid"], "alts": ["🔢", "🆔", "🪪"] },
"daemon.up_since": { "glyph": "⏱️", "spoken": "Up since", "desc": "Row label for how long the daemon has been running.", "words": ["uptime", "since", "age"], "alts": ["🕰️", "⏲️", "📆"] },
"daemon.restart": { "glyph": "🔄", "spoken": "Restart daemon", "desc": "Button that restarts the root daemon. A rate limit allows it only now and then.", "words": ["restart", "reload", "cycle"], "alts": ["🔁", "♻️", "⚡"] },
"server.heading": { "glyph": "🌐", "spoken": "Web server", "desc": "The web server that serves this UI. It heads the server card and is the server badge in the top bar.", "words": ["server", "web", "host"], "alts": ["🕸️", "📶", "🔌"] },
"server.version": { "glyph": "🏷️", "spoken": "Version", "desc": "Row label for the version of the running web server.", "words": ["version", "build", "release"], "alts": ["🔢", "🔖", "📦"] },
"server.started": { "glyph": "🕒", "spoken": "Started", "desc": "Row label for the time the web server process started.", "words": ["started", "launched", "since"], "alts": ["🕐", "⏰", "🚦"] },
"server.code": { "glyph": "💾", "spoken": "Code", "desc": "Row label that compares the code on disk with the running server. A warning means the server runs old code.", "words": ["code", "source", "files"], "alts": ["💻", "📝", "🧬"] },
"server.restart": { "glyph": "🔄", "spoken": "Restart server", "desc": "Button that restarts the web server, on the server card and in the stale-server banner. The page reloads when the server is back.", "words": ["restart", "reload", "refresh"], "alts": ["🔁", "♻️", "🚀"] },
"backup.item": { "glyph": "🗄️", "spoken": "Backup", "desc": "Heading of the card with the saved state backups, and the mark in front of one backup in the restore dialog.", "words": ["backup", "archive", "snapshot"], "alts": ["🗃️", "📦", "💿"] },
"backup.reason.reset": { "glyph": "♻️", "spoken": "Before reset", "desc": "Reason mark: the backup was taken right before a reset wiped the state.", "words": ["reset", "wipe", "recycle"], "alts": ["🧹", "🔁", "💣"] },
"backup.reason.nightly": { "glyph": "🌙", "spoken": "Nightly", "desc": "Reason mark: the backup was taken by the nightly timer.", "words": ["nightly", "scheduled", "night"], "alts": ["🌛", "🌃", "⭐"] },
"backup.reason.other": { "glyph": "🗄️", "spoken": "Other reason", "desc": "Reason mark for a backup whose reason the UI does not know.", "words": ["other", "unlabelled", "misc"], "alts": ["📁", "🧾", "🔖"] },
"backup.restore": { "glyph": "⏮️", "spoken": "Restore", "desc": "Button that restores the state from a backup. It first asks for a typed phrase.", "words": ["restore", "rewind", "rollback"], "alts": ["⏪", "↩️", "🔙"] },
"syssetup.configured": { "glyph": "⚙️", "spoken": "Configured", "desc": "Row label that shows whether setup is complete.", "words": ["configured", "ready", "complete"], "alts": ["🛠️", "🔩", "🎛️"] },
"syssetup.edit": { "glyph": "✏️", "spoken": "Open setup", "desc": "Link that opens the setup page, where the key and the SteamID can be changed.", "words": ["edit", "change", "pencil"], "alts": ["🖊️", "📝", "🧰"] },
"gaming.today": { "glyph": "📅", "spoken": "Today", "desc": "Heading of the card with today's budget numbers on the gaming page.", "words": ["today", "day", "budget"], "alts": ["🗓️", "📆", "🌞"] },
"basis.rush": { "glyph": "🐇", "spoken": "Rush", "desc": "Rush estimate: how long the games take at a fast completionist pace. It is a choice in the filter panel, a card in the summary and a column in the table.", "words": ["rush", "fast", "sprint"], "alts": ["🐎", "🚀", "🏃"] },
"basis.leisure": { "glyph": "🐢", "spoken": "Leisure", "desc": "Leisure estimate: how long the games take at a slow, comfortable pace. It is a choice in the filter panel, a card in the summary and a column in the table.", "words": ["leisure", "slow", "relaxed"], "alts": ["🦥", "🧘", "🛋️"] },
"basis.worst": { "glyph": "🐌", "spoken": "Worst case", "desc": "Worst-case estimate: the longest time anyone has recorded for each game. It is a choice in the filter panel, a card in the summary and a column in the table.", "words": ["worst", "longest", "maximum"], "alts": ["🐘", "🧱", "🕰️"] },
"basis.pace": { "glyph": "👤", "spoken": "Your pace", "desc": "Your own pace: the estimate built from how fast you finished games before. It marks the pace choice, the pace card and your play-style block.", "words": ["pace", "yours", "personal"], "alts": ["🙋", "🧍", "🪞"] },
"style.fast": { "glyph": "⚡", "spoken": "Faster than HLTB rush", "desc": "Play style: you finish games faster than the fast times on HowLongToBeat.", "words": ["fast", "speedy", "quick"], "alts": ["🚀", "💨", "🏎️"] },
"style.between": { "glyph": "🐇↔🐢", "spoken": "Between rush and leisure", "desc": "Play style: your pace sits between the rush and leisure times on HowLongToBeat.", "words": ["between", "average", "typical"], "alts": ["⚖️", "🔀", "↔️"] },
"style.slow": { "glyph": "🐌", "spoken": "Slower than HLTB leisure", "desc": "Play style: you finish games slower than the slow leisure times on HowLongToBeat.", "words": ["slow", "careful", "thorough"], "alts": ["🦥", "🪨", "🛌"] },
"tier.native": { "glyph": "⭐", "spoken": "Native", "desc": "ProtonDB tier native: the game runs on Linux without Proton. It shows in the tier column and the tier filters.", "words": ["native", "linux", "built-in"], "alts": ["🌟", "✨", "🎖️"] },
"tier.platinum": { "glyph": "💎", "spoken": "Platinum", "desc": "ProtonDB tier platinum: the game runs perfectly under Proton out of the box. It shows in the tier column and the tier filters.", "words": ["platinum", "perfect", "flawless"], "alts": ["💠", "🔷", "👑"] },
"tier.gold": { "glyph": "🥇", "spoken": "Gold", "desc": "ProtonDB tier gold: the game runs perfectly after small tweaks. It shows in the tier column and the tier filters.", "words": ["gold", "great", "tweaked"], "alts": ["🏅", "🟡", "👍"] },
"tier.silver": { "glyph": "🥈", "spoken": "Silver", "desc": "ProtonDB tier silver: the game is playable with minor issues. It shows in the tier column and the tier filters.", "words": ["silver", "playable", "minor"], "alts": ["⚪", "🔘", "🪙"] },
"tier.bronze": { "glyph": "🥉", "spoken": "Bronze", "desc": "ProtonDB tier bronze: the game runs but with frequent problems. It shows in the tier column and the tier filters.", "words": ["bronze", "rough", "shaky"], "alts": ["🟤", "🔶", "🪵"] },
"tier.borked": { "glyph": "💥", "spoken": "Borked", "desc": "ProtonDB tier borked: the game does not run at all. It shows in the tier column and the tier filters.", "words": ["borked", "broken", "unplayable"], "alts": ["💀", "🧨", "☠️"] },
"tier.pending": { "glyph": "⏳", "spoken": "Pending", "desc": "ProtonDB tier pending: there are not enough reports to rate the game yet. It shows in the tier column and the tier filters.", "words": ["pending", "unrated", "waiting"], "alts": ["⌛", "🕓", "🔜"] },
"keep.kept": { "glyph": "📌", "spoken": "Kept", "desc": "Value of the keep filter: the game stays in the plan. Choosing it shows only the kept games.", "words": ["kept", "pinned", "included"], "alts": ["📍", "🔖", "🧷"] },
"keep.excluded": { "glyph": "🚫", "spoken": "Excluded", "desc": "Value of the keep filter: you took the game out of the plan. Choosing it shows only the dropped games.", "words": ["excluded", "dropped", "skipped"], "alts": ["🙅", "🗑️", "✂️"] },
"backlog.any": { "glyph": "✱", "spoken": "Any", "desc": "Any value: in a filter it sets no limit and shows every game.", "words": ["any", "all", "everything"], "alts": ["✳️", "🌐", "♾️"] },
"backlog.cli": { "glyph": "⌨️", "spoken": "CLI default", "desc": "Stands for the command-line tool's own rule. It marks the playable rule, the default game count and what reset restores.", "words": ["cli", "terminal", "default"], "alts": ["💻", "🖥️", "📟"] },
"filter.reset": { "glyph": "↺", "spoken": "Reset to CLI defaults", "desc": "Button in the filter panel that sets every filter back to the CLI defaults.", "words": ["reset", "restore", "defaults"], "alts": ["🔃", "↩️", "🧹"] },
"filter.min-tier": { "glyph": "🥇≥", "spoken": "Min tier", "desc": "Choice of the ProtonDB filter: keep games at or above a minimum tier that you pick.", "words": ["minimum", "tier", "threshold"], "alts": ["🥇+", "🪜", "⬆️"] },
"filter.started": { "glyph": "▶️", "spoken": "Started", "desc": "Choice of the playtime filter: only games you have already started.", "words": ["started", "played", "begun"], "alts": ["🕹️", "⏯️", "🟢"] },
"filter.untouched": { "glyph": "∅", "spoken": "Untouched", "desc": "Choice of the playtime filter: only games with no playtime at all.", "words": ["untouched", "unplayed", "fresh"], "alts": ["🆕", "🧼", "⭕"] },
"filter.daily": { "glyph": "⏰", "spoken": "Daily play time", "desc": "Slider for how many hours you play each day. The time estimates divide by it.", "words": ["daily", "hours", "schedule"], "alts": ["🕰️", "⌚", "📆"] },
"planner.completions": { "glyph": "#", "spoken": "HLTB completions", "desc": "How many completion times HowLongToBeat holds for a game. It is a table column and the minimum slider in the filter panel.", "words": ["completions", "polled", "count"], "alts": ["🔢", "🧮", "🗳️"] },
"filter.min-polled": { "glyph": "💯", "spoken": "Min polled completionist times", "desc": "Slider for the fewest polled completionist times a game needs to count.", "words": ["polled", "completionist", "hundred"], "alts": ["💮", "🧪", "🔟"] },
"filter.min-confidence": { "glyph": "Σ", "spoken": "Min confidence sum", "desc": "Slider for the minimum confidence sum, the total weight of the time reports behind an estimate.", "words": ["confidence", "weight", "sum"], "alts": ["🧮", "➕", "🪙"] },
"filter.max-time": { "glyph": "⏳", "spoken": "Max time per game", "desc": "Slider for the longest game you accept. Longer games are hidden.", "words": ["cap", "longest", "limit"], "alts": ["⌛", "⏲️", "🛑"] },
"filter.no-cap": { "glyph": "∞", "spoken": "No cap", "desc": "Shown in place of the hours when the time cap is off.", "words": ["unlimited", "endless", "uncapped"], "alts": ["♾️", "🌌", "🔓"] },
"filter.fallback": { "glyph": "❓", "spoken": "Fallback estimate", "desc": "Slider for the hours guessed for games that have no time data.", "words": ["guess", "fallback", "default"], "alts": ["🎲", "🤔", "📏"] },
"filter.basis": { "glyph": "📐", "spoken": "Estimate basis", "desc": "Heading of the estimate-basis choice: rush, leisure, worst case or your pace.", "words": ["basis", "model", "method"], "alts": ["📏", "🧭", "🧮"] },
"filter.advanced": { "glyph": "🔬", "spoken": "Advanced confidence", "desc": "Heading of the folded advanced confidence settings. Opening it shows two more sliders.", "words": ["advanced", "expert", "details"], "alts": ["🧪", "🔭", "🛠️"] },
"planner.proton": { "glyph": "🐧", "spoken": "ProtonDB", "desc": "ProtonDB: how well a game runs on Linux. It heads the compatibility filter and the table column.", "words": ["proton", "linux", "compatibility"], "alts": ["🍷", "🧩", "💻"] },
"filter.proton-missing": { "glyph": "❓", "spoken": "Keep games with no ProtonDB data", "desc": "Checkbox in the compatibility filter: keep games that have no ProtonDB data in the list.", "words": ["unrated", "unknown", "missing"], "alts": ["🤷", "🫥", "🌫️"] },
"planner.playtime": { "glyph": "⏱", "spoken": "Playtime", "desc": "Your playtime in a game. It heads the playtime filter and the table column.", "words": ["playtime", "hours", "played"], "alts": ["⌛", "🕒", "📈"] },
"planner.no-data": { "glyph": "❓", "spoken": "No HLTB data", "desc": "Badge on a game that has no HowLongToBeat data. The checkbox with the same mark includes such games, using the fallback hours.", "words": ["blank", "unmeasured", "unrated"], "alts": ["🫥", "🕳️", "🚧"] },
"filter.target-date": { "glyph": "🏁", "spoken": "Target finish date", "desc": "Target finish date: the filter's date field and the by-date marker in the banner. It turns hours into the daily pace you need.", "words": ["deadline", "target", "finish"], "alts": ["🎌", "🗓️", "🚩"] },
"filter.clear-date": { "glyph": "✕", "spoken": "Clear", "desc": "Button that clears the target finish date.", "words": ["clear", "erase", "remove"], "alts": ["✖️", "🧽", "⌫"] },
"backlog.sort-asc": { "glyph": "▲", "spoken": "Ascending", "desc": "Marks the table column that is sorted from low to high.", "words": ["ascending", "up", "lowest"], "alts": ["🔼", "⬆️", "📈"] },
"backlog.sort-desc": { "glyph": "▼", "spoken": "Descending", "desc": "Marks the table column that is sorted from high to low.", "words": ["descending", "down", "highest"], "alts": ["🔽", "⬇️", "📉"] },
"planner.game": { "glyph": "🎮", "spoken": "Game", "desc": "Table column with the game names. Clicking its header sorts by name.", "words": ["game", "title", "name"], "alts": ["🕹️", "🎲", "🔤"] },
"planner.completion": { "glyph": "%", "spoken": "Completion", "desc": "Table column with each game's achievement completion in percent.", "words": ["completion", "progress", "percent"], "alts": ["📶", "🧩", "📏"] },
"planner.keep": { "glyph": "📌", "spoken": "Keep", "desc": "Table column with the checkbox that keeps a game in the plan or drops it.", "words": ["keep", "include", "toggle"], "alts": ["📍", "☑️", "🔖"] },
"summary.to-finish": { "glyph": "🎮", "spoken": "To finish", "desc": "Banner on the backlog page: how many games are left to finish by your target date.", "words": ["remaining", "left", "games"], "alts": ["🕹️", "🎲", "🎯"] },
"summary.games-per-day": { "glyph": "🎮", "spoken": "Games per day", "desc": "Unit on the pace card and banner: games finished per day. It follows the number.", "words": ["rate", "speed", "tempo"], "alts": ["🕹️", "🎲", "🏃"] },
"backlog.in-scope": { "glyph": "🎮", "spoken": "Games in scope", "desc": "Count of games that pass the filters. It sits beside the big number in the summary and in the stats card.", "words": ["scope", "qualifying", "matching"], "alts": ["🧮", "🎲", "📚"] },
"summary.need": { "glyph": "→", "spoken": "You need", "desc": "Arrow in the target banner between the chosen model and the daily time you need.", "words": ["needs", "requires", "equals"], "alts": ["➡️", "⇨", "👉"] },
"summary.no-start": { "glyph": "∅", "spoken": "No start date set", "desc": "Shown on the pace card when no start date is set, so there is no finish date.", "words": ["unset", "empty", "undated"], "alts": ["⭕", "🕳️", "🗓️"] },
"summary.style": { "glyph": "🎭", "spoken": "Play style", "desc": "Label of the play-style row: how your pace compares with the HowLongToBeat times.", "words": ["style", "manner", "persona"], "alts": ["🧠", "🪞", "🎬"] },
"summary.interpolation": { "glyph": "t", "spoken": "Interpolation t", "desc": "Label of the blend value t. It is 0 at rush speed and 1 at leisure speed.", "words": ["blend", "position", "interpolation"], "alts": ["📏", "⚖️", "🔀"] },
"summary.estimated-total": { "glyph": "Σ", "spoken": "Estimated total at your pace", "desc": "Label of your estimated total time to finish all games at your pace.", "words": ["total", "estimate", "sum"], "alts": ["🧮", "⏳", "🏔️"] },
"summary.match": { "glyph": "✓", "spoken": "Match", "desc": "Shown when the number of games in scope equals the CLI default.", "words": ["match", "equal", "same"], "alts": ["✔️", "🟰", "👌"] },
"planner.playing": { "glyph": "▶️", "spoken": "Currently playing", "desc": "On the planner header: the game you are playing right now.", "words": ["playing", "current", "active"], "alts": ["🕹️", "⏯️", "🔵"] },
"planner.since": { "glyph": "📅", "spoken": "Since", "desc": "On the planner header: the date the enforcer started counting.", "words": ["since", "started", "begun"], "alts": ["🗓️", "📆", "🕰️"] },
"planner.candidates": { "glyph": "🎮", "spoken": "Candidates", "desc": "On the planner header: how many games the planner can pick from.", "words": ["candidates", "pool", "options"], "alts": ["🎲", "📚", "🧮"] },
"stats.card": { "glyph": "📊", "spoken": "Estimates", "desc": "Heading of the estimates card on the backlog page. It shows the totals for the default filters.", "words": ["estimates", "totals", "numbers"], "alts": ["📈", "🧮", "🗂️"] },
"backlog.filters": { "glyph": "🎚️", "spoken": "Filters", "desc": "Heading of the filter panel on the backlog page. Its sliders and switches narrow the game list.", "words": ["filters", "sliders", "controls"], "alts": ["🎛️", "🧰", "🔘"] },
"cmdflag.root": { "glyph": "🔑", "spoken": "Runs as root", "desc": "Flag on a command: it runs as root through the daemon. It shows on the command card and in the run dialog.", "words": ["root", "admin", "privileged"], "alts": ["🗝️", "👑", "🔐"] },
"cmdflag.countdown": { "glyph": "⏳", "spoken": "Countdown", "desc": "Flag on a command: it asks for a countdown before it can be committed. In the run dialog it carries the minutes.", "words": ["countdown", "delay", "wait"], "alts": ["⏲️", "🕰️", "⌛"] },
"cmdflag.mutating": { "glyph": "✏️", "spoken": "Changes state", "desc": "Flag in the run dialog: this command changes state on your PC or in the enforcer.", "words": ["changes", "writes", "mutates"], "alts": ["📝", "🖊️", "🛠️"] },
"cmdflag.readonly": { "glyph": "👁️", "spoken": "Read-only", "desc": "Flag in the run dialog: this command only reads and changes nothing.", "words": ["readonly", "safe", "viewing"], "alts": ["📖", "🧐", "🪞"] },
"cmdflag.cancellable": { "glyph": "⏹️", "spoken": "Cancellable", "desc": "Flag in the run dialog: a running job of this command can be stopped.", "words": ["stoppable", "cancel", "abort"], "alts": ["🛑", "✋", "🚦"] },
"cmdpal.search": { "glyph": "🔍", "spoken": "Search commands", "desc": "Search field of the command palette. Typing narrows the list of commands and pages.", "words": ["search", "filter", "find"], "alts": ["🔎", "🔦", "🕵️"] },
"cmdpal.run-phrase": { "glyph": "▶️⌨️", "spoken": "Run, needs a phrase", "desc": "Hint on a palette entry: choosing it opens the run dialog, where you must type a phrase first.", "words": ["confirm", "phrase", "guarded"], "alts": ["▶️🔐", "🛂", "🚧"] },
"cmdpal.open": { "glyph": "↗️", "spoken": "Open page", "desc": "Hint on a palette entry for a command that only views data: choosing it opens the page that shows it.", "words": ["page", "view", "open"], "alts": ["🔗", "🪟", "📄"] },
"cmdpal.go": { "glyph": "🧭", "spoken": "Go to", "desc": "Hint on a palette entry for a page: choosing it navigates there.", "words": ["navigate", "go", "jump"], "alts": ["🚀", "🗺️", "📍"] },
"runner.run": { "glyph": "▶️", "spoken": "Run", "desc": "Button that runs the command in the run dialog. The palette shows it as the hint on entries that run one.", "words": ["run", "start", "go"], "alts": ["🚀", "⏩", "🟢"] },
"runner.arm": { "glyph": "⏲️", "spoken": "Arm countdown", "desc": "Submit button for a command with a countdown: it arms the countdown instead of running at once.", "words": ["arm", "schedule", "delay"], "alts": ["⏰", "🧨", "🔔"] },
"runner.fill": { "glyph": "⬆️", "spoken": "Fill the fields above", "desc": "Hint in the run dialog: the exact phrase appears once the fields above are filled in.", "words": ["fill", "above", "complete"], "alts": ["☝️", "📝", "⏫"] },
"runner.terminal": { "glyph": "💻", "spoken": "Run from a terminal", "desc": "Shown when the root daemon is unreachable. The command beside it runs the same job from a terminal.", "words": ["terminal", "shell", "console"], "alts": ["⌨️", "🖥️", "🐚"] },
"params.app_id": { "glyph": "🎮", "spoken": "Game", "desc": "Field in the run dialog: the game to act on, by app id or by picking its name.", "words": ["game", "app", "title"], "alts": ["🕹️", "👾", "🎲"] },
"params.backup_id": { "glyph": "🗄️", "spoken": "Backup", "desc": "Field in the run dialog: which saved state backup to use.", "words": ["backup", "archive", "snapshot"], "alts": ["💾", "📼", "🗃️"] },
"params.days": { "glyph": "📅", "spoken": "Days", "desc": "Field in the run dialog: how many days the action lasts.", "words": ["days", "duration", "span"], "alts": ["🗓️", "📆", "🌅"] },
"params.minutes": { "glyph": "⏱️", "spoken": "Minutes", "desc": "Field in the run dialog: how many minutes the action lasts.", "words": ["minutes", "timer", "length"], "alts": ["⏲️", "🕐", "⌛"] },
"params.reason": { "glyph": "💬", "spoken": "Reason", "desc": "Field in the run dialog: why you do this. The reason is logged.", "words": ["reason", "why", "note"], "alts": ["📝", "🗨️", "🧾"] },
"params.replace": { "glyph": "🔁", "spoken": "Replace", "desc": "Switch in the run dialog: replace the current game instead of keeping it.", "words": ["replace", "swap", "override"], "alts": ["🔄", "♻️", "🔀"] },
"params.demo": { "glyph": "🧪", "spoken": "Demo", "desc": "Switch in the run dialog: run the short demo budget instead of the real one.", "words": ["demo", "test", "trial"], "alts": ["🎬", "🧫", "🔬"] },
"params.other": { "glyph": "✏️", "spoken": "Field", "desc": "Marks any run-dialog field that has no icon of its own.", "words": ["field", "input", "value"], "alts": ["🖊️", "📝", "🔤"] },
"phrase.field": { "glyph": "⌨️", "spoken": "Type the phrase", "desc": "Label of the typed-phrase field. You retype the shown sentence, and pasting is blocked.", "words": ["type", "phrase", "retype"], "alts": ["🔤", "✍️", "📜"] },
"pending.leave": { "glyph": "🚪✖️", "spoken": "Leaving cancels", "desc": "Warning during a countdown: closing the dialog or leaving the page cancels it.", "words": ["leaving", "stay", "warning"], "alts": ["🚪🚫", "🏃", "⚠️🚪"] },
"pending.rearm": { "glyph": "🔁", "spoken": "Arm again", "desc": "Button shown when the countdown lapsed: it starts the command over.", "words": ["rearm", "retry", "again"], "alts": ["🔄", "↩️", "🆕"] },
"pending.beat": { "glyph": "💓", "spoken": "Heartbeat", "desc": "Seconds since the last heartbeat that keeps the countdown alive. It turns into a broken heart when beats fail.", "words": ["heartbeat", "pulse", "alive"], "alts": ["💗", "📶", "🫀"] },
"pending.beat-lost": { "glyph": "💔", "spoken": "Heartbeat failing", "desc": "Replaces the heartbeat while beats fail. The countdown lapses if they do not recover.", "words": ["failing", "lost", "flatline"], "alts": ["📵", "🥀", "🔌"] },
"lib.sort": { "glyph": "↕️", "spoken": "Sort", "desc": "Label of the sort menu in the game browser. The menu orders the grid by name, last played, completion or length.", "words": ["sort", "order", "rank"], "alts": ["🔃", "🔽", "📊"] },
"lib.name": { "glyph": "🔤", "spoken": "Name", "desc": "Sort option: games in alphabetical order by name.", "words": ["name", "alphabet", "title"], "alts": ["🔡", "🅰️", "📇"] },
"lib.recent": { "glyph": "🕐", "spoken": "Recently played", "desc": "Sort option: the games you played most recently come first.", "words": ["recent", "lately", "latest"], "alts": ["🕓", "📆", "⏪"] },
"lib.completion": { "glyph": "🏆", "spoken": "Completion", "desc": "Share of achievements unlocked. It is a sort option and the first part of each game's meta line.", "words": ["completion", "progress", "percent"], "alts": ["🥇", "🎖️", "📈"] },
"lib.hltb": { "glyph": "⏱️", "spoken": "Time to beat", "desc": "Hours that How Long To Beat lists for the game. It is a sort option, shortest first, and part of the meta line.", "words": ["hltb", "hours", "length"], "alts": ["⏳", "⌛", "🕰️"] },
"lib.played": { "glyph": "▶️", "spoken": "Played", "desc": "Hours you have played the game, shown in its meta line.", "words": ["played", "playtime", "logged"], "alts": ["🎮", "🕹️", "⏯️"] },
"lib.hide-completed": { "glyph": "🙈🏆", "spoken": "Hide completed", "desc": "Filter in the game browser: hide the games you have finished.", "words": ["hide", "unfinished", "remaining"], "alts": ["🚫🏆", "🫥", "🧹"] },
"lib.pickable": { "glyph": "🎯", "spoken": "Pickable", "desc": "Filter in the game browser: show only the games the enforcer lets you pick.", "words": ["pickable", "eligible", "allowed"], "alts": ["🎟️", "🔓", "👌"] },
"lib.count": { "glyph": "🎮", "spoken": "Games shown", "desc": "Count in the game browser: the games shown before the slash, the games in total after it.", "words": ["games", "count", "shown"], "alts": ["🕹️", "👾", "🔢"] },
"lib.relevance": { "glyph": "🔍", "spoken": "By relevance", "desc": "Appears beside the count while a search ranks the games by relevance. The sort menu is off then.", "words": ["relevance", "ranked", "matched"], "alts": ["🎯", "📊", "🧲"] },
"lib.search": { "glyph": "🔍", "spoken": "Search your games", "desc": "Search field of the game browser. Typing filters the grid and lists suggestions.", "words": ["search", "find", "lookup"], "alts": ["🔎", "🕵️", "🧐"] },
"lib.why.complete": { "glyph": "🏆✅", "spoken": "Already complete", "desc": "Reason a game cannot be picked: all its achievements are done.", "words": ["complete", "finished", "maxed"], "alts": ["🥇", "💯", "🎖️"] },
"lib.why.noach": { "glyph": "🏆🚫", "spoken": "No achievements", "desc": "Reason a game cannot be picked: it has no achievements to earn.", "words": ["none", "barren", "empty"], "alts": ["🚫", "🪹", "🕳️"] },
"lib.why.skipped": { "glyph": "⏭️", "spoken": "Skipped", "desc": "Reason a game cannot be picked: it was skipped until the date shown beside it.", "words": ["skipped", "deferred", "paused"], "alts": ["⏩", "🛌", "📅"] },
"lib.why.blocked": { "glyph": "⛔", "spoken": "Not allowed", "desc": "Reason a game cannot be picked, for any other cause. The server's sentence is spoken.", "words": ["blocked", "refused", "banned"], "alts": ["🚫", "🛑", "🔒"] },
"health.ok": { "glyph": "✅", "spoken": "Healthy", "desc": "State mark on a health badge: all is well.", "words": ["healthy", "fine", "up"], "alts": ["🟢", "💚", "👍"] },
"health.warn": { "glyph": "⚠️", "spoken": "Degraded", "desc": "State mark on a health badge: the server runs stale code or the daemon is restarting.", "words": ["degraded", "stale", "shaky"], "alts": ["🟡", "🟠", "🚧"] },
"health.bad": { "glyph": "⛔", "spoken": "Down", "desc": "State mark on a health badge: the server is down or the daemon is unreachable.", "words": ["down", "dead", "offline"], "alts": ["🔴", "💥", "🛑"] },
"health.unknown": { "glyph": "…", "spoken": "Unknown", "desc": "State mark on a health badge before the daemon state is known.", "words": ["unknown", "loading", "pending"], "alts": ["❔", "💤", "🔘"] },
"health.stale": { "glyph": "⚠️🌐", "spoken": "Stale server", "desc": "Banner mark: the running server is older than the code on disk. The restart button beside it fixes that.", "words": ["stale", "outdated", "old"], "alts": ["🕰️🌐", "🥀", "📛"] },
"dialog.close": { "glyph": "×", "spoken": "Close", "desc": "Close button in the corner of every dialog.", "words": ["close", "exit", "dismiss"], "alts": ["✖️", "❌", "🚪"] },
"words.page": { "glyph": "🏷️", "spoken": "Icon words", "desc": "Command palette entry that opens this icon-words picker. You are here now.", "words": ["words", "labels", "names"], "alts": ["🔖", "🗨️", "🔤"] }
}
}

View File

@ -9,10 +9,13 @@ const JOB_STATES: JobState[] = ['queued', 'running', 'waiting_input', 'succeeded
const TONES: Tone[] = ['info', 'success', 'warning', 'danger']
describe('icon registry', () => {
it('registers exactly this pass: 8 nav, the palette, 26 commands, 6 job states, 4 tones', () => {
it('registers pass 1 first (8 nav, the palette, 26 commands, 6 job states, 4 tones), then the rest of the UI', () => {
const ids = ICONS.map((e) => e.id)
expect(new Set(ids).size).toBe(ids.length)
expect(ids).toHaveLength(8 + 1 + 26 + 6 + 4)
const pass1 = /^(nav|palette|cmd|job\.state|notice)\./
expect(ids.slice(0, 8 + 1 + 26 + 6 + 4).every((id) => pass1.test(id))).toBe(true)
expect(ids.slice(8 + 1 + 26 + 6 + 4).some((id) => pass1.test(id))).toBe(false)
expect(ids.length).toBeGreaterThan(45)
for (const n of NAV) expect(isIconId(n.icon)).toBe(true)
expect(isIconId('palette.open')).toBe(true)
for (const name of Object.keys(COMMAND_HOME) as (keyof typeof COMMAND_HOME)[]) {
@ -22,7 +25,9 @@ describe('icon registry', () => {
for (const t of TONES) expect(isIconId(`notice.${t}`)).toBe(true)
})
it.each(ICONS.map((e) => [e.id, e] as const))('%s: glyph, name, description, 3 words, 3 alternatives', (_id, e) => {
it.each(ICONS.map((e) => [e.id, e] as const))('%s: glyph, name, description, 3 words, 3 alternatives', (id, e) => {
// The server's route accepts only this id shape (_web_routes._ICON).
expect(id).toMatch(/^[a-z][a-z0-9_.-]{0,63}$/)
expect(e.glyph).not.toBe('')
expect(e.spoken).not.toBe('')
expect(e.desc.length).toBeGreaterThan(20)
@ -32,6 +37,8 @@ describe('icon registry', () => {
for (const w of e.words) expect(w).toMatch(/^\S+$/)
expect(e.alts).toHaveLength(3)
expect(new Set([e.glyph, ...e.alts]).size).toBe(4)
// Not the same picture twice, even when only the emoji variation selector differs.
expect(new Set([e.glyph, ...e.alts].map((g) => g.replaceAll('️', ''))).size).toBe(4)
})
it('keeps every default glyph the UI painted before the registry', () => {

View File

@ -66,11 +66,10 @@ describe('glyph(id)', () => {
expect(el.querySelector('.icon-word')).toBeNull()
})
it('still paints a raw glyph with the old signature', () => {
const el = glyph('🧭', 'navigate')
expect(el.querySelector('[aria-hidden]')?.textContent).toBe('🧭')
expect(el.querySelector('.sr-only')?.textContent).toBe('navigate')
expect(el.querySelector('.icon-word')).toBeNull()
it('tags the glyph with its id so decorateIcons can refresh it', () => {
const el = glyph('state.warn', 'Stale')
expect(el.querySelector('[data-icon]')?.getAttribute('data-icon')).toBe('state.warn')
expect(el.querySelector('.sr-only')?.textContent).toBe('Stale')
})
})

View File

@ -36,6 +36,17 @@ export function iconWord(id: IconId): HTMLSpanElement | null {
return word ? h('span', { class: 'icon-word', 'aria-hidden': 'true', 'data-icon-word': id }, word) : null
}
/**
* The icon for painted-only places (inside `said(...)`, buttons, labels): the
* glyph mark alone, or mark plus word in one row when the user chose a word.
* No spoken text: the caller keeps its own aria-label / .sr-only sentence.
*/
export function iconInline(id: IconId, className = ''): HTMLSpanElement {
const mark = iconMark(id, className)
const word = iconWord(id)
return word ? h('span', { class: 'icon-inline has-word' }, mark, word) : mark
}
/**
* Refresh static markup (the Astro sidebar and palette button) from the
* ledger: each `[data-icon]` gets its current glyph and, right after it, its
@ -54,7 +65,10 @@ export function decorateIcons(root: ParentNode): void {
}
}
/** The static chrome every page shares (sidebar, top bar); run at boot and after a pick. */
/**
* The static chrome every page shares (sidebar, top bar) plus any static
* markup tagged `data-static-icons` (the 404 home link); run at boot and after a pick.
*/
export function decorateChrome(doc: Document = document): void {
for (const el of doc.querySelectorAll('.sidebar, .topbar')) decorateIcons(el)
for (const el of doc.querySelectorAll('.sidebar, .topbar, [data-static-icons]')) decorateIcons(el)
}

View File

@ -0,0 +1,34 @@
// Static Astro markup outside the sidebar and top bar (the 404 home link) opts
// in with `data-static-icons`; the boot decoration then paints the user's
// word and glyph there too.
import { describe, expect, it } from 'vitest'
import { useIcons } from '../test/iconLedger'
import { decorateChrome } from './render'
const markup = (attr: string) => `
<div class="actions" ${attr}>
<a href="/" aria-label="Back to the dashboard"><span aria-hidden="true" data-icon="nav.dashboard">🏠</span></a>
</div>`
describe('decorateChrome and data-static-icons', () => {
it('decorates a tagged container with the word and the alternative glyph', () => {
useIcons({ 'nav.dashboard': { word: 'home', glyph: '🏡' } })
document.body.innerHTML = markup('data-static-icons')
decorateChrome()
const icon = document.querySelector('[data-icon]')
expect(icon?.textContent).toBe('🏡')
expect(icon?.nextElementSibling).toHaveClass('icon-word')
expect(icon?.nextElementSibling?.textContent).toBe('Home')
expect(icon?.parentElement).toHaveClass('has-word')
expect(document.querySelector('a')).toHaveAttribute('aria-label', 'Back to the dashboard')
})
it('leaves untagged containers alone', () => {
useIcons({ 'nav.dashboard': { word: 'home', glyph: '🏡' } })
document.body.innerHTML = markup('')
decorateChrome()
expect(document.querySelector('[data-icon]')?.textContent).toBe('🏠')
expect(document.querySelector('.icon-word')).toBeNull()
})
})

View File

@ -2,7 +2,7 @@
// right of the icon, a chosen alternative replaces the default glyph.
import { describe, expect, it } from 'vitest'
import { COMMAND_ICON, commandIcon } from '../commands/catalog'
import { commandIcon } from '../commands/catalog'
import { commandButton } from '../commands/commandButton'
import { stateBadge } from '../jobs/progress'
import { NAV } from '../shell/nav'
@ -48,10 +48,4 @@ describe('registered call sites', () => {
expect(commandIcon('gaming-status')).toBe('cmd.gaming-status')
})
it('COMMAND_ICON (sites not yet on ids) is the live glyph, alternative applied', () => {
expect(COMMAND_ICON.done).toBe('🏆')
useIcons({ 'cmd.done': { glyph: '🏁' } })
expect(COMMAND_ICON.done).toBe('🏁')
expect(Object.keys(COMMAND_ICON)).toHaveLength(26)
})
})

View File

@ -7,7 +7,9 @@
import { api } from '../api/client'
import type { JobProgress as Progress, JobState } from '../api/jobContract'
import { q } from '../api/queries'
import { COMMAND_ICON, commandLabel, findCommand } from '../commands/catalog'
import { commandIcon, commandLabel, findCommand } from '../commands/catalog'
import type { IconId } from '../icons/registry'
import { iconInline } from '../icons/render'
import { Action } from '../lib/action'
import { define, h } from '../lib/dom'
import { LiveElement } from '../lib/element'
@ -26,11 +28,11 @@ export function eta(p: Progress, live: LiveJob, now: number): number | null {
}
const DONE: ReadonlySet<JobState> = new Set(['succeeded', 'failed', 'cancelled'])
const DONE_LABEL: Record<'succeeded' | 'failed' | 'cancelled', string> = {
succeeded: '✅',
failed: '⛔',
cancelled: '🚫',
}
const DONE_LABEL = {
succeeded: 'job.state.succeeded',
failed: 'job.state.failed',
cancelled: 'job.state.cancelled',
} as const satisfies Record<'succeeded' | 'failed' | 'cancelled', IconId>
const isDone = (s: JobState): s is keyof typeof DONE_LABEL => DONE.has(s)
export class JobProgressElement extends LiveElement {
@ -130,8 +132,8 @@ export class JobProgressElement extends LiveElement {
f.section.className = compact ? 'job job-compact' : 'job'
f.section.dataset.state = state
f.section.setAttribute('aria-label', `Job ${job ? commandLabel(job.command) : id}`)
// Textgate: the command's glyph painted, its name spoken.
f.title.replaceChildren(...(job ? [glyph(COMMAND_ICON[job.command], title)] : []))
// Textgate: the command's glyph (and its word) painted, its name spoken.
f.title.replaceChildren(...(job ? [glyph(commandIcon(job.command), title)] : []))
f.badge.replaceChildren(stateBadge(state))
f.meta.replaceChildren(
job ? duration(job.started_at, job.ended_at, now) : '',
@ -148,7 +150,7 @@ export class JobProgressElement extends LiveElement {
h(
'span',
{ class: 'job-label' },
isDone(state) ? DONE_LABEL[state] : waiting ? '⏳' : progress ? '▶️' : '',
isDone(state) ? iconInline(DONE_LABEL[state]) : waiting ? iconInline('jobs.waiting') : progress ? iconInline('job.state.running') : '',
progress?.label && !finished ? h('span', { class: 'sr-only' }, progress.label) : null,
),
!finished && progress && progress.total !== null
@ -188,7 +190,7 @@ export class JobProgressElement extends LiveElement {
h(
'button',
{ type: 'button', class: 'btn btn-ghost', disabled: this.cancel.pending, onclick: () => void this.cancel.run(), 'aria-label': this.cancel.pending ? 'Cancelling…' : 'Cancel job' },
this.cancel.pending ? '⏳' : '✕',
iconInline(this.cancel.pending ? 'state.wait' : 'jobs.cancel'),
),
),
]
@ -209,7 +211,7 @@ export class JobProgressElement extends LiveElement {
private updateLog(f: NonNullable<JobProgressElement['frame']>, live: LiveJob, finished: boolean, compact: boolean): void {
const logs = live.logs
f.summary.replaceChildren(
h('span', { class: 'log-count-icon', 'aria-hidden': 'true' }, '📋'),
iconInline('jobs.log', 'log-count-icon'),
h('span', { class: 'log-count', 'aria-hidden': 'true' }, String(logs.length)),
)
f.summary.setAttribute('aria-label', `${logs.length} lines`)

View File

@ -0,0 +1,89 @@
// Pass 2 wiring for the jobs page, the job view, the prompt form and the
// top-bar job chip: ledger words right of the icons, chosen glyphs applied,
// accessible names unchanged.
import { screen } from '@testing-library/dom'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { PromptEvent } from './hub'
import { promptForm } from './promptForm'
import { jobChip } from '../shell/jobIndicator'
import '../sections/jobs'
import { makeJob, makeSpec } from '../test/fixtures'
import { installEventSource, mount, stubApi } from '../test/harness'
import { useIcons } from '../test/iconLedger'
import { mountJob } from '../test/jobHelpers'
beforeEach(installEventSource)
const word = (el: Element | null | undefined) => el?.nextElementSibling?.textContent
const prompt = (over: Partial<PromptEvent>): PromptEvent => ({
seq: 1, ts: 't', type: 'prompt', prompt_id: 'q1', kind: 'confirm', message: 'Sure?', ...over,
})
describe('job view icons', () => {
it('the title shows the command word and chosen glyph (cmd id), the name stays spoken', async () => {
useIcons({ 'cmd.scan': { word: 'survey', glyph: '🛰️' } })
const { el } = mountJob({ job: { state: 'running' } })
await vi.waitFor(() => { expect(el.querySelector('h3 .sr-only')).toHaveTextContent('Scan') })
const icon = el.querySelector('h3 [data-icon="cmd.scan"]')
expect(icon?.textContent).toBe('🛰️')
expect(word(icon)).toBe('Survey')
})
it('the phase mark, the log count and the cancel button use their ids', async () => {
useIcons({ 'job.state.running': { word: 'busy' }, 'jobs.log': { word: 'log' }, 'jobs.cancel': { word: 'stop' } })
const { el, send } = mountJob({ job: { state: 'running' }, cancellable: true })
send('progress', { step: 1, total: 3, label: 'Working' })
await vi.waitFor(() => { expect(el.querySelector('.job-label [data-icon="job.state.running"]')).not.toBeNull() })
expect(word(el.querySelector('.job-label [data-icon="job.state.running"]'))).toBe('Busy')
expect(word(el.querySelector('summary [data-icon="jobs.log"]'))).toBe('Log')
await vi.waitFor(() => { expect(screen.getByRole('button', { name: 'Cancel job' })).toBeInTheDocument() })
expect(word(screen.getByRole('button', { name: 'Cancel job' }).querySelector('[data-icon="jobs.cancel"]'))).toBe('Stop')
})
})
describe('jobs page icons', () => {
it('the history headers paint their words, the column names stay spoken', async () => {
history.replaceState({}, '', '/jobs/')
useIcons({ 'jobs.took': { word: 'duration', glyph: '⌛' } })
stubApi({ 'GET /api/jobs': [makeJob({ id: 'a' })], 'GET /api/commands': [makeSpec('scan')] })
mount('<jobs-page></jobs-page>')
const took = (await screen.findByText('Took', { selector: 'th .sr-only' })).closest('th')
expect(took?.querySelector('[data-icon="jobs.took"]')?.textContent).toBe('⌛')
expect(word(took?.querySelector('[data-icon="jobs.took"]'))).toBe('Duration')
})
})
describe('prompt form icons', () => {
it('Yes and No buttons keep their aria-labels and paint their words', () => {
useIcons({ 'prompt.yes': { word: 'agree' }, 'prompt.no': { word: 'refuse', glyph: '👎' } })
const form = promptForm('j', prompt({}))
document.body.append(form)
const yes = screen.getByRole('button', { name: 'Yes' })
expect(word(yes.querySelector('[data-icon="prompt.yes"]'))).toBe('Agree')
const no = screen.getByRole('button', { name: 'No' })
expect(no.querySelector('[data-icon="prompt.no"]')?.textContent).toBe('👎')
expect(word(no.querySelector('[data-icon="prompt.no"]'))).toBe('Refuse')
})
it('the question mark and the answer button follow the ledger', () => {
useIcons({ 'prompt.question': { word: 'ask' }, 'prompt.answer': { word: 'send', glyph: '📤' } })
const form = promptForm('j', prompt({ kind: 'text' }))
document.body.append(form)
expect(word(form.querySelector('[data-icon="prompt.question"]'))).toBe('Ask')
const answer = screen.getByRole('button', { name: 'Answer' })
expect(answer.querySelector('[data-icon="prompt.answer"]')?.textContent).toBe('📤')
expect(word(answer.querySelector('[data-icon="prompt.answer"]'))).toBe('Send')
})
})
describe('job chip icon', () => {
it('the needs-input mark paints its word, the aria-label keeps the sentence', () => {
useIcons({ 'jobchip.needs-input': { word: 'answer', glyph: '🙋' } })
const chip = jobChip(makeJob({ id: 'chip-wait', command: 'scan', state: 'waiting_input' }))
const mark = chip.querySelector('[data-icon="jobchip.needs-input"]')
expect(mark?.textContent).toBe('🙋')
expect(word(mark)).toBe('Answer')
expect(chip).toHaveAttribute('aria-label', 'Scan: needs your input')
})
})

View File

@ -8,15 +8,17 @@ import { q } from '../api/queries'
import { phraseMatches } from '../commands/catalog'
import { PhraseField } from '../commands/phraseField'
import { Action } from '../lib/action'
import type { IconId } from '../icons/registry'
import { iconInline } from '../icons/render'
import { h, hx } from '../lib/dom'
import type { GameBrowserElement } from '../library/pick'
import { errorNotice, glyph } from '../ui/build'
import { hub, type PromptEvent } from './hub'
/** A glyph-only button: `icon` painted, `spoken` its accessible name. */
function sendButton(btn: HTMLButtonElement, spoken: string, icon: string): void {
function sendButton(btn: HTMLButtonElement, spoken: string, icon: IconId): void {
btn.setAttribute('aria-label', spoken)
btn.textContent = icon
btn.replaceChildren(iconInline(icon))
}
function answerAction(jobId: string, prompt: PromptEvent, onChange: () => void): Action<[string], void> {
@ -40,8 +42,8 @@ function answerForm(jobId: string, prompt: PromptEvent): HTMLFormElement {
const submit = (v: string = value) => {
void send.run(v)
}
// Textgate: the server's question is spoken; ❓ marks that the job waits on you.
const form = h('form', { class: 'prompt', 'aria-label': 'Job question' }, h('p', { class: 'prompt-msg' }, glyph('❓', prompt.message)))
// Textgate: the server's question is spoken; the question icon marks that the job waits on you.
const form = h('form', { class: 'prompt', 'aria-label': 'Job question' }, h('p', { class: 'prompt-msg' }, glyph('prompt.question', prompt.message)))
form.addEventListener('submit', (e) => {
e.preventDefault()
if (ready()) submit()
@ -65,7 +67,7 @@ function answerForm(jobId: string, prompt: PromptEvent): HTMLFormElement {
{ class: 'choice' },
radio,
// Option labels are game names (content); the "own game" escape is a glyph.
o.value === 'own' ? glyph('🗂️', o.label, 'choice-label') : h('span', { class: 'choice-label' }, o.label),
o.value === 'own' ? glyph('prompt.own-game', o.label, 'choice-label') : h('span', { class: 'choice-label' }, o.label),
o.detail ? h('span', { class: 'choice-detail sr-only' }, o.detail) : null,
)
label.dataset.value = o.value
@ -103,14 +105,14 @@ function answerForm(jobId: string, prompt: PromptEvent): HTMLFormElement {
errorSlot.replaceChildren(...(send.error ? [errorNotice(send.error)] : []))
if (prompt.kind === 'confirm') {
actions.replaceChildren(
h('button', { type: 'button', class: 'btn btn-primary', 'aria-label': 'Yes', autofocus: prompt.default !== 'no', disabled: send.pending, onclick: () => { submit('yes') } }, '✔️'),
h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'No', autofocus: prompt.default === 'no', disabled: send.pending, onclick: () => { submit('no') } }, '✖️'),
h('button', { type: 'button', class: 'btn btn-primary', 'aria-label': 'Yes', autofocus: prompt.default !== 'no', disabled: send.pending, onclick: () => { submit('yes') } }, iconInline('prompt.yes')),
h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'No', autofocus: prompt.default === 'no', disabled: send.pending, onclick: () => { submit('no') } }, iconInline('prompt.no')),
)
return
}
const btn = actions.querySelector('button') ?? actions.appendChild(h('button', { type: 'submit', class: 'btn btn-primary' }))
btn.disabled = !ready() || send.pending
sendButton(btn, send.pending ? 'Sending…' : 'Answer', send.pending ? '⏳' : '↵')
sendButton(btn, send.pending ? 'Sending…' : 'Answer', send.pending ? 'state.wait' : 'prompt.answer')
}
refresh()
return form
@ -135,7 +137,7 @@ function gamePrompt(jobId: string, prompt: PromptEvent): HTMLFormElement {
}
browser.pick = { appIds, selected, onSelect: pick }
const pickBtn = h('button', { type: 'submit', class: 'btn btn-primary' })
const backBtn = h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Back to the list', onclick: () => void send.run('') }, '↩️')
const backBtn = h('button', { type: 'button', class: 'btn btn-ghost', 'aria-label': 'Back to the list', onclick: () => void send.run('') }, iconInline('prompt.back'))
const errorSlot = h('div', { class: 'contents' })
const form = h(
'form',
@ -143,9 +145,9 @@ function gamePrompt(jobId: string, prompt: PromptEvent): HTMLFormElement {
h(
'p',
{ class: 'prompt-msg' },
glyph('❓', prompt.message),
glyph('prompt.question', prompt.message),
' ',
h('span', { class: 'muted' }, h('span', { 'aria-hidden': 'true' }, `· 🎮 ${appIds.size}`), h('span', { class: 'sr-only' }, `· ${appIds.size} games can be picked`)),
h('span', { class: 'muted' }, h('span', { 'aria-hidden': 'true' }, '· ', iconInline('prompt.games'), ` ${appIds.size}`), h('span', { class: 'sr-only' }, `· ${appIds.size} games can be picked`)),
),
browser,
errorSlot,
@ -159,12 +161,12 @@ function gamePrompt(jobId: string, prompt: PromptEvent): HTMLFormElement {
function refresh(): void {
const name = q.library.state.data?.games.find((g) => g.app_id === selected)?.name ?? String(selected)
pickBtn.disabled = selected === null || send.pending
// 🎯 + the chosen game's name (content) painted; the verb is spoken.
if (send.pending) sendButton(pickBtn, 'Sending…', '⏳')
else if (selected === null) sendButton(pickBtn, 'Select a game', '🎯')
// The pick icon + the chosen game's name (content) painted; the verb is spoken.
if (send.pending) sendButton(pickBtn, 'Sending…', 'state.wait')
else if (selected === null) sendButton(pickBtn, 'Select a game', 'prompt.pick')
else {
pickBtn.setAttribute('aria-label', `Pick ${name}`)
pickBtn.replaceChildren(h('span', { 'aria-hidden': 'true' }, `🎯 ${name}`))
pickBtn.replaceChildren(h('span', { 'aria-hidden': 'true' }, iconInline('prompt.pick'), ` ${name}`))
}
backBtn.disabled = send.pending
errorSlot.replaceChildren(...(send.error ? [errorNotice(send.error)] : []))

View File

@ -3,7 +3,9 @@
import type { EstimateResult } from '../../estimate'
import { isoDate } from '../../format'
import { iconInline } from '../../icons/render'
import type { Filters, WebStateInfo } from '../../types'
import { h } from '../dom'
const W = 820
const H = 320
@ -83,10 +85,14 @@ export function timelineChart(
const box = document.createElement('div')
box.className = 'chart'
if (pts.length < 2) {
const hint = document.createElement('p')
hint.className = 'hint empty-state'
hint.innerHTML = '<span class="empty-icon" aria-hidden="true">📭</span><span class="sr-only">Not enough games in scope to draw a timeline.</span>'
box.append(hint)
box.append(
h(
'p',
{ class: 'hint empty-state' },
iconInline('state.empty', 'empty-icon'),
h('span', { class: 'sr-only' }, 'Not enough games in scope to draw a timeline.'),
),
)
return box
}
box.append(timelineSvg(pts, now))

View File

@ -2,14 +2,15 @@
// `hash-state` (the Library page only) they live in the URL hash, so a
// reload restores them.
import type { IconId } from '../icons/registry'
import { readHash } from './hashState'
import { NO_FILTERS, SORTS, type Filters, type SortKey } from './view'
/** Filter key, spoken checkbox label, its token in the hash's `f=` list, painted glyph. */
export const FILTERS: [keyof Filters, string, string, string][] = [
['hideCompleted', 'Hide completed', 'completed', '🙈🏆'],
['installedOnly', 'Installed only', 'installed', '💾'],
['pickableOnly', 'Pickable only', 'pickable', '🎯'],
/** Filter key, spoken checkbox label, its token in the hash's `f=` list, painted icon. */
export const FILTERS: [keyof Filters, string, string, IconId][] = [
['hideCompleted', 'Hide completed', 'completed', 'lib.hide-completed'],
['installedOnly', 'Installed only', 'installed', 'dash.installed'],
['pickableOnly', 'Pickable only', 'pickable', 'lib.pickable'],
]
export interface BrowserState {

View File

@ -3,6 +3,8 @@
// caret; the browser only writes values into it and hears every edit back.
import type { LibraryGame } from '../api/contract'
import { iconText } from '../icons/iconText'
import { iconInline } from '../icons/render'
import { h } from '../lib/dom'
import { glyph } from '../ui/build'
import { FILTERS, type BrowserState } from './browserState'
@ -31,7 +33,8 @@ export class BrowserToolbar {
opts.onSort(this.sortSelect.value as SortKey)
},
},
SORTS.map((s) => h('option', { value: s.key, 'aria-label': s.label }, s.icon)),
// An <option> holds text only: the icon, then the user's word right of it.
SORTS.map((s) => h('option', { value: s.key, 'aria-label': s.label }, iconText(s.icon))),
)
this.checks = new Map(
FILTERS.map(([key]) => [
@ -48,7 +51,7 @@ export class BrowserToolbar {
'div',
{ class: 'lib-toolbar' },
this.searchBox.el,
h('label', { class: 'lib-sort' }, glyph('↕️', 'Sort', 'field-label'), this.sortSelect),
h('label', { class: 'lib-sort' }, glyph('lib.sort', 'Sort', 'field-label'), this.sortSelect),
h(
'fieldset',
{ class: 'lib-filters' },
@ -79,7 +82,13 @@ export class BrowserToolbar {
setCount(shown: number, total: number, byRelevance: boolean): void {
const spoken = `${shown} of ${total} games${byRelevance ? ' · by relevance' : ''}`
this.count.replaceChildren(
h('span', { 'aria-hidden': 'true' }, `🎮 ${shown}/${total}${byRelevance ? ' 🔍' : ''}`),
h(
'span',
{ 'aria-hidden': 'true' },
iconInline('lib.count'),
` ${shown}/${total}`,
byRelevance ? [' ', iconInline('lib.relevance')] : null,
),
h('span', { class: 'sr-only' }, spoken),
)
}

View File

@ -42,8 +42,8 @@ export function gameCard(game: LibraryGame): HTMLButtonElement {
? h(
'span',
{ class: 'game-badges' },
game.assigned ? pill('accent', 'assigned', '🎯') : null,
game.installed ? pill('neutral', 'installed', '💾') : null,
game.assigned ? pill('accent', 'assigned', 'assigned.game') : null,
game.installed ? pill('neutral', 'installed', 'dash.installed') : null,
)
: null,
)

View File

@ -0,0 +1,55 @@
// Pass-2 icon wiring for the library browser: sort options and placeholders
// show the glyph plus the user's word as text, badges and counts draw the
// word right of the icon, spoken labels stay.
import { describe, expect, it, vi } from 'vitest'
import { makeLibGame } from '../test/fixtures'
import { useIcons } from '../test/iconLedger'
import { painted } from '../test/painted'
import { BrowserToolbar } from './browserToolbar'
import { gameCard } from './gameCard'
function toolbar(): BrowserToolbar {
const bar = new BrowserToolbar({ onInput: vi.fn(), onChoose: vi.fn(), reason: () => null, onSort: vi.fn(), onFilter: vi.fn() })
document.body.append(bar.el)
return bar
}
describe('library toolbar by id', () => {
it('writes the glyph and word into the search placeholder and the sort options', () => {
useIcons({ 'lib.search': { word: 'find', glyph: '🔎' }, 'lib.hltb': { word: 'length' } })
const bar = toolbar()
expect(bar.el.querySelector('input[type=search]')).toHaveAttribute('placeholder', '🔎 Find')
const options = [...bar.el.querySelectorAll('option')]
expect(options.map((o) => o.textContent)).toEqual(['🔤', '🕐', '🏆', '⏱️ Length'])
expect(options[3]).toHaveAttribute('aria-label', 'Shortest (HLTB)')
})
it('draws the sort label, the filters and the count with words, aria unchanged', () => {
useIcons({
'lib.sort': { word: 'order' },
'dash.installed': { word: 'local' },
'lib.count': { word: 'games' },
'lib.relevance': { glyph: '📊' },
})
const bar = toolbar()
bar.setCount(3, 5, true)
expect(painted(bar.el.querySelector('.lib-sort'))).toContain('↕️Order')
expect(painted(bar.el.querySelector('.lib-filters label:nth-of-type(2)'))).toBe('💾Local')
expect(bar.el.querySelector('.lib-count [aria-hidden]')?.textContent).toBe('🎮Games 3/5 📊')
expect(bar.el.querySelector('.lib-count .sr-only')?.textContent).toBe('3 of 5 games · by relevance')
expect(bar.el.querySelector('.lib-filters .sr-only')?.textContent).toBe('Filters')
})
})
describe('game card badges by id', () => {
it('draws the assigned and installed badges with their words, spoken names unchanged', () => {
useIcons({ 'assigned.game': { word: 'target' }, 'dash.installed': { glyph: '📥' } })
const card = gameCard(makeLibGame({ assigned: true, installed: true }))
const [assigned, installed] = [...card.querySelectorAll('.game-badges .pill')]
expect(painted(assigned)).toBe('🎯Target')
expect(assigned.querySelector('.sr-only')?.textContent).toBe('assigned')
expect(painted(installed)).toBe('📥')
expect(installed.querySelector('.sr-only')?.textContent).toBe('installed')
})
})

View File

@ -4,6 +4,7 @@
// clears. The input is built once; only the list and ARIA state change.
import type { LibraryGame } from '../api/contract'
import { iconText } from '../icons/iconText'
import { h } from '../lib/dom'
import { uid } from '../lib/ids'
import { reasonOrMeta } from './view'
@ -36,7 +37,7 @@ export class SearchBox {
'aria-expanded': 'false',
'aria-controls': this.listId,
'aria-autocomplete': 'list',
placeholder: '🔍',
placeholder: iconText('lib.search'),
})
this.list = h('ul', { id: this.listId, role: 'listbox', class: 'lib-suggest', hidden: true, 'aria-label': 'Suggestions' })
this.el = h('div', { class: 'lib-search' }, this.input, this.list)

View File

@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest'
import { h, type Child } from '../lib/dom'
import { makeLibGame } from '../test/fixtures'
import { useIcons } from '../test/iconLedger'
import { completion, filterGames, isCompleted, metaGlyphs, metaLine, NO_FILTERS, reasonGlyph, reasonOrMeta, sortGames } from './view'
const g = makeLibGame
@ -69,13 +71,23 @@ describe('metaLine', () => {
})
})
/** The text the painted nodes show. */
const text = (nodes: Child[]) => h('span', {}, ...nodes).textContent
describe('metaGlyphs', () => {
it('paints trophy, clock and play with their values', () => {
expect(metaGlyphs(g({ achievements_total: 8, achievements_unlocked: 3, hltb_hours: 12, playtime_minutes: 192 })))
expect(text(metaGlyphs(g({ achievements_total: 8, achievements_unlocked: 3, hltb_hours: 12, playtime_minutes: 192 }))))
.toBe('🏆 37% · ⏱️ 12 h · ▶️ 3.2 h')
})
it('paints a dash for no achievements and drops unknown HLTB and zero playtime', () => {
expect(metaGlyphs(g({ achievements_total: 0, hltb_hours: null, playtime_minutes: 0 }))).toBe('🏆 —')
expect(text(metaGlyphs(g({ achievements_total: 0, hltb_hours: null, playtime_minutes: 0 })))).toBe('🏆 —')
})
it('draws the user word right of each icon and his alternative glyph', () => {
useIcons({ 'lib.hltb': { word: 'length', glyph: '⌛' }, 'lib.completion': { word: 'percent' } })
const meta = h('span', {}, ...metaGlyphs(g({ achievements_total: 8, achievements_unlocked: 3, hltb_hours: 12, playtime_minutes: 0 })))
expect([...meta.querySelectorAll('.icon-word')].map((w) => w.textContent)).toEqual(['Percent', 'Length'])
expect(meta.querySelector('[data-icon="lib.hltb"]')?.textContent).toBe('⌛')
expect(meta.querySelector('[data-icon="lib.hltb"]')?.nextElementSibling).toHaveClass('icon-word')
})
})
@ -88,7 +100,12 @@ describe('reasonGlyph', () => {
['Something else', '⛔'],
['Blocked until 2026-10-02', '⛔ 2026-10-02'],
])('%s paints %s', (reason, painted) => {
expect(reasonGlyph(reason)).toBe(painted)
expect(text(reasonGlyph(reason))).toBe(painted)
})
it('draws the user word beside the reason icon, the date after it', () => {
useIcons({ 'lib.why.skipped': { word: 'skipped' } })
const el = h('span', {}, ...reasonGlyph('Skipped until 2026-09-01'))
expect(el.textContent).toBe('⏭️Skipped 2026-09-01')
})
})
@ -97,7 +114,7 @@ describe('reasonOrMeta', () => {
const game = g({ achievements_total: 8, achievements_unlocked: 3, hltb_hours: 12, playtime_minutes: 192 })
const el = reasonOrMeta(null, game, 'sub')
expect(el.className).toBe('sub')
expect(el.querySelector('[aria-hidden="true"]')?.textContent).toBe(metaGlyphs(game))
expect(el.querySelector('[aria-hidden="true"]')?.textContent).toBe(text(metaGlyphs(game)))
expect(el.querySelector('.sr-only')?.textContent).toBe(metaLine(game))
})
it('paints the reason glyph and speaks the reason when not pickable', () => {

View File

@ -2,16 +2,18 @@
// the grid component only wires state to them.
import type { LibraryGame } from '../api/contract'
import { h } from '../lib/dom'
import type { IconId } from '../icons/registry'
import { iconInline } from '../icons/render'
import { h, type Child } from '../lib/dom'
export type SortKey = 'name' | 'recent' | 'completion' | 'hltb'
/** `label` is spoken only; the sort select paints `icon`. */
export const SORTS: { key: SortKey; label: string; icon: string }[] = [
{ key: 'name', label: 'Name', icon: '🔤' },
{ key: 'recent', label: 'Recently played', icon: '🕐' },
{ key: 'completion', label: 'Completion', icon: '🏆' },
{ key: 'hltb', label: 'Shortest (HLTB)', icon: '⏱️' },
export const SORTS: { key: SortKey; label: string; icon: IconId }[] = [
{ key: 'name', label: 'Name', icon: 'lib.name' },
{ key: 'recent', label: 'Recently played', icon: 'lib.recent' },
{ key: 'completion', label: 'Completion', icon: 'lib.completion' },
{ key: 'hltb', label: 'Shortest (HLTB)', icon: 'lib.hltb' },
]
export interface Filters {
@ -69,30 +71,30 @@ export function metaLine(g: LibraryGame): string {
return parts.join(' · ')
}
/** The painted meta line: "🏆 45% · ⏱️ 12 h · ▶️ 3.2 h" (🏆 — without achievements). */
export function metaGlyphs(g: LibraryGame): string {
/** The painted meta line: "🏆 45% · ⏱️ 12 h · ▶️ 3.2 h" (🏆 — without achievements), icons by id. */
export function metaGlyphs(g: LibraryGame): Child[] {
const pct = completion(g)
const parts = [`🏆 ${pct === null ? '—' : `${Math.floor(pct)}%`}`]
if (g.hltb_hours !== null) parts.push(`⏱️ ${hours(g.hltb_hours)}`)
if (g.playtime_minutes > 0) parts.push(`▶️ ${hours(g.playtime_minutes / 60)}`)
return parts.join(' · ')
const parts: Child[][] = [[iconInline('lib.completion'), ` ${pct === null ? '—' : `${Math.floor(pct)}%`}`]]
if (g.hltb_hours !== null) parts.push([iconInline('lib.hltb'), ` ${hours(g.hltb_hours)}`])
if (g.playtime_minutes > 0) parts.push([iconInline('lib.played'), ` ${hours(g.playtime_minutes / 60)}`])
return parts.flatMap((part, i) => (i === 0 ? part : [' · ', ...part]))
}
function hours(h: number): string {
return h >= 10 ? `${Math.round(h)} h` : `${h.toFixed(1)} h`
}
/** Glyph for a server ineligibility reason; a date in it stays painted. */
export function reasonGlyph(reason: string): string {
/** Icon for a server ineligibility reason; a date in a skip or block stays painted. */
export function reasonGlyph(reason: string): Child[] {
const date = /\d{4}-\d{2}-\d{2}/.exec(reason)?.[0]
if (reason.includes('100%')) return '🏆✅'
if (/no achievements/i.test(reason)) return '🏆🚫'
if (/skip/i.test(reason)) return date ? `⏭️ ${date}` : '⏭️'
return date ? `⛔ ${date}` : '⛔'
if (reason.includes('100%')) return [iconInline('lib.why.complete')]
if (/no achievements/i.test(reason)) return [iconInline('lib.why.noach')]
const id = /skip/i.test(reason) ? 'lib.why.skipped' : 'lib.why.blocked'
return date ? [iconInline(id), ` ${date}`] : [iconInline(id)]
}
/** Glyphs painted, words spoken: `text` shown as `painted` with an sr-only twin. */
export function spokenGlyphs(painted: string, text: string, className: string): HTMLSpanElement {
export function spokenGlyphs(painted: Child, text: string, className: string): HTMLSpanElement {
return h('span', { class: className }, h('span', { 'aria-hidden': 'true' }, painted), h('span', { class: 'sr-only' }, text))
}

View File

@ -1,10 +1,14 @@
---
// Any address with no page (the server serves this with a real 404).
import PageHead from '../components/PageHead.astro'
import { iconEntry } from '../icons/registry'
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" aria-label="Back to the dashboard"><span aria-hidden="true">🏠</span></a></div>
{/* data-static-icons: boot decorates the icon with the user's word and glyph (icons/render.ts). */}
<div class="actions" data-static-icons>
<a href="/" class="btn btn-primary" aria-label="Back to the dashboard"><span aria-hidden="true" data-icon="nav.dashboard">{iconEntry('nav.dashboard').glyph}</span></a>
</div>
</Shell>

View File

@ -1,32 +1,34 @@
// The planner's estimate filters (was FilterPanel.tsx). Built once; `sync()`
// writes values, active segments and conditional rows in place, so a slider
// being dragged or a date being typed never loses focus.
// Textgate: every label is a glyph (glyphs.ts) with its words spoken only;
// slider values (numbers + units) stay painted.
// Textgate: every label is an icon (registry ids, glyphs.ts) with its words
// spoken only; slider values (numbers + units) stay painted.
import type { IconId } from '../../icons/registry'
import { iconInline } from '../../icons/render'
import { h } from '../../lib/dom'
import { SELECTABLE_TIERS } from '../../protondb'
import type { EstimateBasis, Filters, PlaytimeMode, ProtonMode, WebDefaults } from '../../types'
import { glyph } from '../../ui/build'
import { ANY_GLYPH, BASIS_GLYPH, TIER_GLYPH } from './glyphs'
import { BASIS_ICON, tierText } from './glyphs'
type Update = (patch: Partial<Filters>) => void
interface Seg<T> { id: T; label: string; icon: string }
interface Seg<T> { id: T; label: string; icon: IconId }
const BASES: readonly Seg<EstimateBasis>[] = [
{ id: 'rush', label: 'Rush', icon: BASIS_GLYPH.rush },
{ id: 'leisure', label: 'Leisure', icon: BASIS_GLYPH.leisure },
{ id: 'worst', label: 'Worst', icon: BASIS_GLYPH.worst },
{ id: 'pace', label: 'Pace', icon: BASIS_GLYPH.pace },
{ id: 'rush', label: 'Rush', icon: BASIS_ICON.rush },
{ id: 'leisure', label: 'Leisure', icon: BASIS_ICON.leisure },
{ id: 'worst', label: 'Worst', icon: BASIS_ICON.worst },
{ id: 'pace', label: 'Pace', icon: BASIS_ICON.pace },
]
const PROTON: readonly Seg<ProtonMode>[] = [
{ id: 'playable', label: 'Playable (CLI rule)', icon: '⌨️' },
{ id: 'minTier', label: 'Min tier', icon: '🥇≥' },
{ id: 'playable', label: 'Playable (CLI rule)', icon: 'backlog.cli' },
{ id: 'minTier', label: 'Min tier', icon: 'filter.min-tier' },
]
const PLAYTIME: readonly Seg<PlaytimeMode>[] = [
{ id: 'all', label: 'All', icon: ANY_GLYPH },
{ id: 'started', label: 'Started', icon: '▶️' },
{ id: 'untouched', label: 'Untouched', icon: '∅' },
{ id: 'all', label: 'All', icon: 'backlog.any' },
{ id: 'started', label: 'Started', icon: 'filter.started' },
{ id: 'untouched', label: 'Untouched', icon: 'filter.untouched' },
]
type NumberKey = 'dailyHours' | 'minCountComp' | 'minComp100' | 'minConfidenceSum' | 'maxHoursPerGame' | 'fallbackHours'
@ -35,7 +37,7 @@ interface Slider {
key: NumberKey
input: HTMLInputElement
val: HTMLSpanElement
show: (f: Filters) => string
show: (f: Filters) => string | HTMLSpanElement
}
const hint = (text: string) => h('p', { class: 'hint sr-only' }, text)
@ -45,7 +47,7 @@ export class FilterPanel {
private readonly syncs: ((f: Filters) => void)[] = []
constructor(defaults: WebDefaults, update: Update, onReset: () => void) {
const slider = (key: NumberKey, icon: string, label: string, min: number, max: number, step: number, show: Slider['show']) => {
const slider = (key: NumberKey, icon: IconId, label: string, min: number, max: number, step: number, show: Slider['show']) => {
const val = h('span', { class: 'val' })
const input = h('input', { type: 'range', min, max, step, 'aria-label': label })
input.addEventListener('input', () => {
@ -55,13 +57,13 @@ export class FilterPanel {
})
this.syncs.push((f) => {
input.value = String(f[key])
val.textContent = show(f)
val.replaceChildren(show(f))
})
return { label: h('label', {}, glyph(icon, label), ' ', val), input }
}
const segmented = <T extends string>(items: readonly Seg<T>[], current: (f: Filters) => T, set: (id: T) => void) => {
const buttons = items.map((it) =>
h('button', { type: 'button', class: 'seg', 'aria-label': it.label, onclick: () => { set(it.id) } }, it.icon),
h('button', { type: 'button', class: 'seg', 'aria-label': it.label, onclick: () => { set(it.id) } }, iconInline(it.icon)),
)
this.syncs.push((f) => {
buttons.forEach((b, i) => {
@ -72,7 +74,7 @@ export class FilterPanel {
})
return h('div', { class: 'segmented' }, buttons)
}
const check = (icon: string, label: string, read: (f: Filters) => boolean, set: (on: boolean) => void) => {
const check = (icon: IconId, label: string, read: (f: Filters) => boolean, set: (on: boolean) => void) => {
const input = h('input', { type: 'checkbox' })
input.addEventListener('change', () => {
set(input.checked)
@ -88,21 +90,21 @@ export class FilterPanel {
})
return el
}
const heading = (icon: string, label: string) => h('label', {}, glyph(icon, label))
const heading = (icon: IconId, label: string) => h('label', {}, glyph(icon, label))
const daily = slider('dailyHours', '⏰', 'Daily play time', 0.5, 16, 0.5, (f) => `${f.dailyHours} h/day`)
const minComp = slider('minCountComp', '#', 'Min HLTB completions', 0, 100, 1, (f) => String(f.minCountComp))
const min100 = slider('minComp100', '💯', 'Min polled completionist times', 0, 50, 1, (f) => String(f.minComp100))
const minConf = slider('minConfidenceSum', 'Σ', 'Min confidence sum', 0, 150, 1, (f) => String(f.minConfidenceSum))
const maxH = slider('maxHoursPerGame', '⏳', 'Max time per game', 0, 200, 5, (f) =>
f.maxHoursPerGame > 0 ? `${f.maxHoursPerGame} h` : '∞',
const daily = slider('dailyHours', 'filter.daily', 'Daily play time', 0.5, 16, 0.5, (f) => `${f.dailyHours} h/day`)
const minComp = slider('minCountComp', 'planner.completions', 'Min HLTB completions', 0, 100, 1, (f) => String(f.minCountComp))
const min100 = slider('minComp100', 'filter.min-polled', 'Min polled completionist times', 0, 50, 1, (f) => String(f.minComp100))
const minConf = slider('minConfidenceSum', 'filter.min-confidence', 'Min confidence sum', 0, 150, 1, (f) => String(f.minConfidenceSum))
const maxH = slider('maxHoursPerGame', 'filter.max-time', 'Max time per game', 0, 200, 5, (f) =>
f.maxHoursPerGame > 0 ? `${f.maxHoursPerGame} h` : iconInline('filter.no-cap'),
)
const fallback = slider('fallbackHours', '❓', 'Fallback estimate', 1, 100, 1, (f) => `${f.fallbackHours} h`)
const fallback = slider('fallbackHours', 'filter.fallback', 'Fallback estimate', 1, 100, 1, (f) => `${f.fallbackHours} h`)
const tier = h(
'select',
{ 'aria-label': 'Minimum ProtonDB tier' },
SELECTABLE_TIERS.map((t) => h('option', { value: t, 'aria-label': t }, TIER_GLYPH[t])),
SELECTABLE_TIERS.map((t) => h('option', { value: t, 'aria-label': t }, tierText(t))),
)
tier.addEventListener('change', () => {
update({ protonMinTier: tier.value })
@ -119,7 +121,7 @@ export class FilterPanel {
date.value = f.targetDate
})
const clear = shownWhen(
h('button', { type: 'button', class: 'ghost', 'aria-label': 'Clear', onclick: () => { update({ targetDate: '' }) } }, '✕'),
h('button', { type: 'button', class: 'ghost', 'aria-label': 'Clear', onclick: () => { update({ targetDate: '' }) } }, iconInline('filter.clear-date')),
(f) => f.targetDate !== '',
)
@ -129,10 +131,16 @@ export class FilterPanel {
h(
'div',
{ class: 'panel-head' },
h('h2', {}, glyph('🎚️', 'Filters')),
h('button', { type: 'button', class: 'ghost', 'aria-label': 'Reset to CLI defaults', onclick: () => { onReset() } }, '↺ ⌨️'),
h('h2', {}, glyph('backlog.filters', 'Filters')),
h(
'button',
{ type: 'button', class: 'ghost', 'aria-label': 'Reset to CLI defaults', onclick: () => { onReset() } },
iconInline('filter.reset'),
' ',
iconInline('backlog.cli'),
),
),
h('section', { class: 'field' }, heading('📐', 'Estimate basis'), segmented(BASES, (f) => f.basis, (basis) => { update({ basis }) })),
h('section', { class: 'field' }, heading('filter.basis', 'Estimate basis'), segmented(BASES, (f) => f.basis, (basis) => { update({ basis }) })),
h('section', { class: 'field' }, daily.label, daily.input),
h(
'section',
@ -141,18 +149,18 @@ export class FilterPanel {
minComp.input,
hint(`Higher = more reliable HLTB times (CLI default ${defaults.min_count_comp}).`),
),
h('details', { class: 'field' }, h('summary', {}, glyph('🔬', 'Advanced confidence')), min100.label, min100.input, minConf.label, minConf.input),
h('details', { class: 'field' }, h('summary', {}, glyph('filter.advanced', 'Advanced confidence')), min100.label, min100.input, minConf.label, minConf.input),
h(
'section',
{ class: 'field' },
heading('🐧', 'ProtonDB compatibility'),
heading('planner.proton', 'ProtonDB compatibility'),
segmented(PROTON, (f) => f.protonMode, (protonMode) => { update({ protonMode }) }),
shownWhen(
h(
'div',
{ class: 'subfield' },
tier,
check('❓', 'Keep games with no ProtonDB data', (f) => f.protonTreatMissingAsPass, (on) => {
check('filter.proton-missing', 'Keep games with no ProtonDB data', (f) => f.protonTreatMissingAsPass, (on) => {
update({ protonTreatMissingAsPass: on })
}),
),
@ -163,13 +171,13 @@ export class FilterPanel {
h(
'section',
{ class: 'field' },
heading('⏱', 'Playtime'),
heading('planner.playtime', 'Playtime'),
segmented(PLAYTIME, (f) => f.playtimeMode, (playtimeMode) => { update({ playtimeMode }) }),
),
h(
'section',
{ class: 'field' },
check('❓', 'Include games with no HLTB data', (f) => f.includeNoData, (on) => {
check('planner.no-data', 'Include games with no HLTB data', (f) => f.includeNoData, (on) => {
update({ includeNoData: on })
}),
shownWhen(h('div', { class: 'subfield' }, fallback.label, fallback.input), (f) => f.includeNoData),
@ -177,7 +185,7 @@ export class FilterPanel {
h(
'section',
{ class: 'field' },
heading('🏁', 'Target finish date'),
heading('filter.target-date', 'Target finish date'),
h('div', { class: 'subfield row' }, date, clear),
hint('Pick a date to see the hours/day required.'),
),

View File

@ -1,57 +1,69 @@
// Backlog pictograms (textgate: these are painted, the words are spoken only).
// One glyph per idea across the stats card, the planner filters, the summary
// cards and the table headers, so a glyph learned in one place reads the same
// everywhere.
// Backlog pictograms by registry id (textgate: these are painted, the words
// are spoken only). One icon per idea across the stats card, the planner
// filters, the summary cards and the table headers, so an icon learned in one
// place reads the same everywhere, and the user's word follows it.
import type { IconId } from '../../icons/registry'
import { iconText } from '../../icons/iconText'
import { iconInline } from '../../icons/render'
import type { EstimateBasis } from '../../types'
import { glyph } from '../../ui/build'
export const BASIS_GLYPH: Record<EstimateBasis, string> = {
rush: '🐇',
leisure: '🐢',
worst: '🐌',
pace: '👤',
}
export const BASIS_ICON = {
rush: 'basis.rush',
leisure: 'basis.leisure',
worst: 'basis.worst',
pace: 'basis.pace',
} as const satisfies Record<EstimateBasis, IconId>
/** Player style vs HLTB; the `--<style>` class adds the colour channel. */
export const STYLE_GLYPH: Record<string, string> = {
faster_than_rush: '⚡',
rush_to_leisure: '🐇↔🐢',
slower_than_leisure: '🐌',
unknown: '❔',
const STYLE_ICON: Record<string, IconId> = {
faster_than_rush: 'style.fast',
rush_to_leisure: 'style.between',
slower_than_leisure: 'style.slow',
unknown: 'state.unknown',
}
export const STYLE_SPOKEN: Record<string, string> = {
const STYLE_SPOKEN: Record<string, string> = {
faster_than_rush: 'Faster than HLTB rush',
rush_to_leisure: 'Between rush and leisure',
slower_than_leisure: 'Slower than HLTB leisure',
unknown: 'Not enough finished games yet',
}
/** A player style: its glyph painted (the class adds colour), its sentence spoken. */
/** A player style: its icon painted (the class adds colour), its sentence spoken. */
export const styleGlyph = (style: string) =>
glyph(STYLE_GLYPH[style] ?? '❔', STYLE_SPOKEN[style] ?? style, `player-insight-style player-insight-style--${style}`)
glyph(STYLE_ICON[style] ?? 'state.unknown', STYLE_SPOKEN[style] ?? style, `player-insight-style player-insight-style--${style}`)
/** ProtonDB tiers, best to worst: medals, then a crash and an hourglass. */
export const TIER_GLYPH: Record<string, string> = {
native: '⭐',
platinum: '💎',
gold: '🥇',
silver: '🥈',
bronze: '🥉',
borked: '💥',
pending: '⏳',
const TIER_ICON: Record<string, IconId> = {
native: 'tier.native',
platinum: 'tier.platinum',
gold: 'tier.gold',
silver: 'tier.silver',
bronze: 'tier.bronze',
borked: 'tier.borked',
pending: 'tier.pending',
}
const tierGlyph = (tier: string) => TIER_GLYPH[tier] ?? '❔'
/** A tierLabel() string (`gold`, `gold / silver`, `—`) as icons; an unknown tier is the unknown mark. */
export function tierMarks(label: string): (HTMLSpanElement | string)[] {
if (!label || label === '—') return ['—']
return label
.split(' / ')
.flatMap((tier, i) => [...(i ? ['/'] : []), iconInline(TIER_ICON[tier] ?? 'state.unknown')])
}
/** A tierLabel() string (`gold`, `gold / silver`, `—`) as glyphs. */
export function tierGlyphs(label: string): string {
/** `tierMarks` as plain text (glyph, then word) for an `<option>`, which cannot hold markup. */
export function tierText(label: string): string {
if (!label || label === '—') return '—'
return label.split(' / ').map(tierGlyph).join('/')
return label
.split(' / ')
.map((tier) => iconText(TIER_ICON[tier] ?? 'state.unknown'))
.join('/')
}
export const KEEP_GLYPH: Record<string, string> = { kept: '📌', excluded: '🚫' }
const KEEP_ICON: Record<string, IconId> = { kept: 'keep.kept', excluded: 'keep.excluded' }
/** "Any value" in a filter select or segmented control. */
export const ANY_GLYPH = '✱'
/** The keep filter's value as plain option text. */
export const keepText = (value: string) => iconText(KEEP_ICON[value])

View File

@ -0,0 +1,104 @@
// The backlog page's icons are registry ids: the user's word shows right of
// the icon, a chosen alternative glyph replaces it, spoken names stay.
import { screen } from '@testing-library/dom'
import { afterEach, describe, expect, it } from 'vitest'
import { applyFilters } from '../../estimate'
import { timelineChart } from '../../lib/charts/timeline'
import { makeDataset, makeFilters, makeGame, makePaceVsHltb, makeState } from '../../test/factories'
import { useIcons } from '../../test/iconLedger'
import { GAMES, header, panel, show, table } from '../../test/plannerHelpers'
import { painted } from '../../test/painted'
import { keepText, styleGlyph, tierMarks, tierText } from './glyphs'
import { summaryCards } from './summary'
afterEach(() => {
history.replaceState(null, '', '/')
})
const wordAfter = (mark: Element | null) => mark?.nextElementSibling?.textContent
describe('backlog icons: filter panel', () => {
it('draws the basis word right of the icon and keeps the button name', async () => {
useIcons({ 'basis.rush': { word: 'sprint', glyph: '🚀' } })
await show()
const rush = panel().getByRole('button', { name: 'Rush' })
expect(rush.querySelector('[data-icon]')?.textContent).toBe('🚀')
expect(wordAfter(rush.querySelector('[data-icon]'))).toBe('Sprint')
expect(rush.querySelector('.icon-inline')).toHaveClass('has-word')
})
it('reset button, no-cap value and clear-date mark follow the ledger', async () => {
useIcons({ 'filter.reset': { glyph: '🧹' }, 'filter.no-cap': { word: 'endless' }, 'backlog.cli': { word: 'default' } })
await show()
const reset = panel().getByRole('button', { name: 'Reset to CLI defaults' })
expect(painted(reset)).toBe('🧹 ⌨️Default')
expect(document.querySelector('.panel .val .icon-word')?.textContent).toBe('Endless')
})
it('tier options and the keep check carry the tier icons and their words', async () => {
useIcons({ 'tier.gold': { word: 'great' }, 'filter.proton-missing': { word: 'unrated' } })
await show()
const gold = [...document.querySelectorAll('.panel select option')].find((o) => o.getAttribute('aria-label') === 'gold')
expect(gold?.textContent).toBe('🥇 Great')
expect(wordAfter(document.querySelector('.panel .check [data-icon="filter.proton-missing"]'))).toBe('Unrated')
})
})
describe('backlog icons: table', () => {
it('sort arrow and column icons use their ids', async () => {
useIcons({ 'backlog.sort-asc': { glyph: '🔼', word: 'up' }, 'basis.leisure': { word: 'slow' } })
await show()
const th = header('Leisure')
expect(th).toHaveAttribute('aria-label', 'Leisure')
expect(th.querySelector('[data-icon="backlog.sort-asc"]')?.textContent).toBe('🔼')
expect([...th.querySelectorAll('.icon-word')].map((w) => w.textContent)).toEqual(['Slow', 'Up'])
})
it('tier cells, options and the no-data badge follow the ledger', async () => {
useIcons({ 'tier.platinum': { glyph: '💠' }, 'keep.kept': { word: 'pinned' }, 'planner.no-data': { word: 'blank' } })
history.replaceState(null, '', '/backlog/#nodata=1')
await show([...GAMES, makeGame({ app_id: 9, name: 'No Data', rush_hours: -1, leisure_hours: -1, worst_hours: -1 })])
expect(table().querySelector('td.proton [data-icon="tier.platinum"]')?.textContent).toBe('💠')
const keep = screen.getByRole('combobox', { name: 'Filter Keep' })
expect([...keep.querySelectorAll('option')].map((o) => o.textContent)).toContain('📌 Pinned')
expect(wordAfter(table().querySelector('.badge [data-icon="planner.no-data"]'))).toBe('Blank')
})
it('number filter boxes keep their comparator placeholders', async () => {
await show()
expect(table().querySelector('input[aria-label$=" min"]')).toHaveAttribute('placeholder', '≥')
expect(table().querySelector('input[aria-label$=" max"]')).toHaveAttribute('placeholder', '≤')
})
})
describe('backlog icons: summary, glyph helpers and chart', () => {
it('the banner and parity row paint ledger words and alternatives, spoken text unchanged', () => {
useIcons({ 'filter.target-date': { word: 'deadline' }, 'summary.need': { glyph: '➡️' }, 'summary.match': { word: 'same' } })
const filters = makeFilters({ targetDate: '2026-01-11' })
const result = applyFilters(makeDataset([makeGame({ app_id: 1 })]), filters)
const el = summaryCards(
{ result, filters, state: makeState(), presets: [2], defaultQualifying: result.remainingGames, paceVsHltb: makePaceVsHltb() },
new Date('2026-01-01T00:00:00Z'),
)
document.body.append(el)
expect(painted(el.querySelector('.target-banner'))).toContain('🏁Deadline')
expect(painted(el.querySelector('.target-banner'))).toContain('➡️')
expect(wordAfter(el.querySelector('.parity [data-icon="summary.match"]'))).toBe('Same')
expect(el.querySelector('.target-banner')).toHaveTextContent('by')
})
it('style, tier and keep helpers draw ids, and the empty chart draws the empty id', () => {
useIcons({ 'style.fast': { word: 'speedy' }, 'state.empty': { glyph: '📪' }, 'tier.bronze': { word: 'rough' } })
const style = styleGlyph('faster_than_rush')
expect(style.querySelector('.icon-word')?.textContent).toBe('Speedy')
expect(style).toHaveTextContent('Faster than HLTB rush')
expect(tierMarks('bronze').map((m) => (typeof m === 'string' ? m : m.textContent)).join('')).toBe('🥉Rough')
expect(keepText('kept')).toBe('📌')
expect(tierText('bronze / gold')).toBe('🥉 Rough/🥇')
const filters = makeFilters()
const box = timelineChart(applyFilters(makeDataset([]), filters), filters, makeState())
expect(box.querySelector('.empty-icon')?.textContent).toBe('📪')
expect(box).toHaveTextContent('Not enough games in scope to draw a timeline.')
})
})

View File

@ -112,12 +112,12 @@ export class Planner {
private syncSub(): void {
const s = this.data.state
this.sub.replaceChildren(
...(s.current_game_name ? [glyph('▶️', 'Currently playing '), ' ', h('strong', {}, s.current_game_name), ' · '] : []),
glyph('🏆', 'games finished'),
...(s.current_game_name ? [glyph('planner.playing', 'Currently playing '), ' ', h('strong', {}, s.current_game_name), ' · '] : []),
glyph('dash.finished', 'games finished'),
` ${s.games_done_since_start} · `,
glyph('📅', 'since'),
glyph('planner.since', 'since'),
` ${s.enforcement_started_at.slice(0, 10) || '—'} · `,
glyph('🎮', 'candidates'),
glyph('planner.candidates', 'candidates'),
` ${this.data.games.length}`,
)
}

View File

@ -2,7 +2,6 @@ import { screen, within } from '@testing-library/dom'
import { afterEach, describe, expect, it } from 'vitest'
import { makeGame } from '../../test/factories'
import { GAMES, hash, header, names, show, table } from '../../test/plannerHelpers'
import { ANY_GLYPH } from './glyphs'
import { hltbUrl } from './plannerTable'
afterEach(() => {
@ -120,7 +119,7 @@ describe('<game-table> table', () => {
await show()
const options = [...screen.getByRole('combobox', { name: 'Filter Keep' }).querySelectorAll('option')]
expect(options.map((o) => [o.value, o.textContent, o.getAttribute('aria-label')])).toEqual([
['', ANY_GLYPH, 'All'],
['', '✱', 'All'],
['kept', '📌', 'kept'],
['excluded', '🚫', 'excluded'],
])

View File

@ -5,11 +5,14 @@
import type { GameRow } from '../../estimate'
import { fmtHoursPrecise, fmtPlaytime } from '../../format'
import type { IconId } from '../../icons/registry'
import { iconText } from '../../icons/iconText'
import { iconInline } from '../../icons/render'
import { h } from '../../lib/dom'
import { tierLabel } from '../../protondb'
import type { WebGame } from '../../types'
import { glyph } from '../../ui/build'
import { ANY_GLYPH, KEEP_GLYPH, tierGlyphs } from './glyphs'
import { BASIS_ICON, keepText, tierMarks, tierText } from './glyphs'
import { COLUMNS, optionsFor, type Column, type ColumnKey, type TableState } from './tableState'
export const DISPLAY_CAP = 300
@ -36,27 +39,28 @@ export function hltbUrl(game: WebGame): string {
return `https://howlongtobeat.com/?q=${encodeURIComponent(game.name)}`
}
// Textgate: select options paint glyphs; the value (kept/excluded, a
// Textgate: select options paint icons; the value (kept/excluded, a
// tierLabel string) is what the hash stores and what the option speaks.
// Only the keep and proton columns have a select filter; keep's options are
// always kept/excluded, so every one has a glyph.
const optionLabel = (c: Column, v: string) => (c.key === 'keep' ? KEEP_GLYPH[v] : tierGlyphs(v))
// always kept/excluded, so every one has an icon.
// An <option> holds text only, so these are glyph-then-word strings.
const optionLabel = (c: Column, v: string) => (c.key === 'keep' ? keepText(v) : tierText(v))
const option = (c: Column, v: string) =>
h('option', { value: v, 'aria-label': v || 'All' }, v ? optionLabel(c, v) : ANY_GLYPH)
h('option', { value: v, 'aria-label': v || 'All' }, v ? optionLabel(c, v) : iconText('backlog.any'))
// Textgate: column headers are pictograms; the column name is the button's
// aria-label (spoken only), the sort arrow stays visible.
const COLUMN_ICON: Record<ColumnKey, string> = {
name: '🎮',
completion: '%',
playtime: '⏱',
rush: '🐇',
leisure: '🐢',
worst: '🐌',
count_comp: '#',
proton: '🐧',
keep: '📌',
}
const COLUMN_ICON = {
name: 'planner.game',
completion: 'planner.completion',
playtime: 'planner.playtime',
rush: BASIS_ICON.rush,
leisure: BASIS_ICON.leisure,
worst: BASIS_ICON.worst,
count_comp: 'planner.completions',
proton: 'planner.proton',
keep: 'planner.keep',
} as const satisfies Record<ColumnKey, IconId>
export class PlannerTable {
readonly el: HTMLElement
@ -109,8 +113,12 @@ export class PlannerTable {
return el
}
if (c.filter === 'range') {
// The comparator in the box is a math operator, not an icon: a placeholder is text only.
const bound = (side: 'min' | 'max') =>
field(`${c.key}.${side}`, h('input', { type: 'number', inputmode: 'decimal', placeholder: side === 'min' ? '≥' : '≤', 'aria-label': `${c.label} ${side}` }))
field(
`${c.key}.${side}`,
h('input', { type: 'number', inputmode: 'decimal', placeholder: side === 'min' ? '≥' : '≤', 'aria-label': `${c.label} ${side}` }),
)
return h('td', { class: 'range-filter' }, h('div', {}, bound('min'), bound('max')))
}
if (c.filter === 'select') {
@ -121,7 +129,7 @@ export class PlannerTable {
return h('td', {}, field(c.key, h('input', { type: 'search', placeholder: '', 'aria-label': `Filter ${c.label}` })))
}
const headCell = (c: Column): HTMLTableCellElement => {
const button = h('button', { type: 'button', class: 'sort-btn', 'aria-label': c.label }, COLUMN_ICON[c.key])
const button = h('button', { type: 'button', class: 'sort-btn', 'aria-label': c.label }, iconInline(COLUMN_ICON[c.key]))
const th = h('th', { class: c.numeric ? 'num clickable' : 'clickable', scope: 'col', 'aria-label': c.label }, button)
th.addEventListener('click', () => {
this.opts.onSort(c.key)
@ -161,7 +169,7 @@ export class PlannerTable {
keep.addEventListener('change', () => { this.opts.onToggle(id) })
const link = h('a', { target: '_blank', rel: 'noreferrer' })
const name = h('td', { class: 'name' }, link)
row = { tr: h('tr', {}, name, cells, h('td', { class: 'num' }, keep)), name, link, badge: glyph('❓', 'no data', 'badge'), cells, keep }
row = { tr: h('tr', {}, name, cells, h('td', { class: 'num' }, keep)), name, link, badge: glyph('planner.no-data', 'no data', 'badge'), cells, keep }
this.rows.set(id, row)
}
const g = r.game
@ -179,9 +187,9 @@ export class PlannerTable {
fmtHoursPrecise(r.leisure),
fmtHoursPrecise(r.worst),
String(g.count_comp),
tierGlyphs(tier),
]
texts.forEach((text, i) => { row.cells[i].textContent = text })
row.cells[6].replaceChildren(...tierMarks(tier))
row.cells[6].setAttribute('aria-label', tier)
row.keep.checked = !r.excluded
row.keep.setAttribute('aria-label', r.excluded ? 'Re-include' : 'Exclude')
@ -203,8 +211,8 @@ export class PlannerTable {
private syncHeads(table: TableState): void {
for (const [c, th, button] of this.heads) {
const active = c.key === table.sort
const arrow = active ? (table.asc ? ' ▲' : ' ▼') : ''
button.textContent = `${COLUMN_ICON[c.key]}${arrow}`
const arrow = active ? [' ', iconInline(table.asc ? 'backlog.sort-asc' : 'backlog.sort-desc')] : []
button.replaceChildren(iconInline(COLUMN_ICON[c.key]), ...arrow)
if (active) th.setAttribute('aria-sort', table.asc ? 'ascending' : 'descending')
else th.removeAttribute('aria-sort')
}

View File

@ -1,16 +1,17 @@
// <backlog-stats>: the CLI's `stats` estimate for the default filters (was
// screens/Backlog.tsx StatsCard). Textgate: labels are glyphs, words spoken only.
// screens/Backlog.tsx StatsCard). Textgate: labels are icons, words spoken only.
import { q } from '../../api/queries'
import { fmtHours } from '../../format'
import type { IconId } from '../../icons/registry'
import { h } from '../../lib/dom'
import { LiveElement } from '../../lib/element'
import { card, errorNotice, facts, glyph, loading } from '../../ui/build'
import { BASIS_GLYPH, styleGlyph } from './glyphs'
import { BASIS_ICON, styleGlyph } from './glyphs'
const ICON = '📊'
const ICON: IconId = 'stats.card'
const ratio = (r: number) => (r < 0 ? '—' : `${r.toFixed(2)}×`)
const stat = (num: string | number, icon: string, label: string) =>
const stat = (num: string | number, icon: IconId, label: string) =>
h('div', { class: 'stat' }, h('span', { class: 'stat-num' }, num), glyph(icon, label, 'stat-label'))
export class BacklogStatsElement extends LiveElement {
@ -37,17 +38,17 @@ export class BacklogStatsElement extends LiveElement {
h(
'div',
{ class: 'stat-row' },
stat(s.qualifying, '🎮', 'qualifying games'),
stat(fmtHours(s.rush_total), BASIS_GLYPH.rush, 'rush'),
stat(fmtHours(s.leisure_total), BASIS_GLYPH.leisure, 'leisure'),
stat(fmtHours(s.worst_total), BASIS_GLYPH.worst, 'worst case'),
stat(s.qualifying, 'backlog.in-scope', 'qualifying games'),
stat(fmtHours(s.rush_total), BASIS_ICON.rush, 'rush'),
stat(fmtHours(s.leisure_total), BASIS_ICON.leisure, 'leisure'),
stat(fmtHours(s.worst_total), BASIS_ICON.worst, 'worst case'),
),
p
? facts([
[glyph(BASIS_GLYPH.pace, 'Your pace'), styleGlyph(p.player_style)],
[glyph(BASIS_GLYPH.rush, 'vs rush'), ratio(p.ratio_vs_rush)],
[glyph(BASIS_GLYPH.leisure, 'vs leisure'), ratio(p.ratio_vs_leisure)],
[glyph('🏆', 'Calibrated on'), [String(p.calibration_count), h('span', { class: 'sr-only' }, ' finished games')]],
[glyph(BASIS_ICON.pace, 'Your pace'), styleGlyph(p.player_style)],
[glyph(BASIS_ICON.rush, 'vs rush'), ratio(p.ratio_vs_rush)],
[glyph(BASIS_ICON.leisure, 'vs leisure'), ratio(p.ratio_vs_leisure)],
[glyph('dash.finished','Calibrated on'), [String(p.calibration_count), h('span', { class: 'sr-only' }, ' finished games')]],
])
: null,
],

View File

@ -1,13 +1,15 @@
// The planner's headline: games in scope, the target-date banner, one card per
// estimate basis and the player's pace vs HLTB (was SummaryCards.tsx).
// Textgate: labels are glyphs (glyphs.ts), the old wording is spoken only.
// Textgate: labels are icons (glyphs.ts), the old wording is spoken only.
import { basisTotal, etaDays, paceDays, playerEstimatedTotal, type EstimateResult } from '../../estimate'
import { fmtEta, fmtHours } from '../../format'
import type { IconId } from '../../icons/registry'
import { iconInline } from '../../icons/render'
import { h } from '../../lib/dom'
import type { EstimateBasis, Filters, PaceVsHLTB, WebStateInfo } from '../../types'
import { empty, glyph } from '../../ui/build'
import { BASIS_GLYPH, styleGlyph } from './glyphs'
import { BASIS_ICON, styleGlyph } from './glyphs'
export interface SummaryProps {
result: EstimateResult
@ -26,8 +28,8 @@ const CARDS: readonly { basis: EstimateBasis; title: string; blurb: string }[] =
]
const spoken = (text: string) => h('span', { class: 'sr-only' }, text)
/** Games per day: the 🎮 stands in for the word "games". */
const perDay = (n: number | string) => [`${n} 🎮/d`, spoken(' games per day')]
/** Games per day: the games icon stands in for the word "games". */
const perDay = (n: number | string) => [`${n} `, iconInline('summary.games-per-day'), '/d', spoken(' games per day')]
function targetBanner({ result, filters }: SummaryProps, now: Date): HTMLDivElement | null {
if (!filters.targetDate) return null
@ -39,16 +41,20 @@ function targetBanner({ result, filters }: SummaryProps, now: Date): HTMLDivElem
return h(
'div',
{ class: 'target-banner' },
glyph('🎮', 'To finish'),
glyph('summary.to-finish', 'To finish'),
' ',
h('strong', {}, result.remainingGames),
spoken(' games'),
' 🏁 ',
' ',
iconInline('filter.target-date'),
' ',
spoken('by '),
h('strong', {}, filters.targetDate),
` (${days} d) `,
glyph(BASIS_GLYPH[filters.basis], `on the ${filters.basis} model, you need`),
' → ',
glyph(BASIS_ICON[filters.basis], `on the ${filters.basis} model, you need`),
' ',
iconInline('summary.need'),
' ',
h('strong', {}, need),
)
}
@ -60,13 +66,13 @@ const presetRows = (presets: readonly number[], eta: (perDay: number) => number
presets.map((p) => h('div', { class: 'preset' }, h('span', {}, `${p} h/day`), h('span', {}, fmtEta(eta(p))))),
)
const pair = (icon: string, label: string, value: Node | string, attrs: Record<string, string> = {}) => [
const pair = (icon: IconId, label: string, value: Node | string, attrs: Record<string, string> = {}) => [
glyph(icon, label),
typeof value === 'string' ? h('span', attrs, value) : value,
]
function playerInsight({ result, paceVsHltb: pace, presets }: SummaryProps): HTMLDivElement {
const title = h('div', { class: 'player-insight-title' }, glyph(BASIS_GLYPH.pace, 'Your Play Style vs HLTB'))
const title = h('div', { class: 'player-insight-title' }, glyph(BASIS_ICON.pace, 'Your Play Style vs HLTB'))
if (!pace || pace.calibration_count === 0) {
return h(
'div',
@ -83,18 +89,18 @@ function playerInsight({ result, paceVsHltb: pace, presets }: SummaryProps): HTM
h(
'div',
{ class: 'player-insight-grid' },
pair('🏆', 'Calibration games', String(pace.calibration_count)),
pair('dash.finished','Calibration games', String(pace.calibration_count)),
pace.ratio_vs_rush !== -1
? pair(BASIS_GLYPH.rush, 'vs Rush speed', `${pace.ratio_vs_rush.toFixed(2)}×`, {
? pair(BASIS_ICON.rush, 'vs Rush speed', `${pace.ratio_vs_rush.toFixed(2)}×`, {
class: pace.ratio_vs_rush <= 1 ? 'player-insight-fast' : 'player-insight-slow',
})
: null,
pace.ratio_vs_leisure !== -1 ? pair(BASIS_GLYPH.leisure, 'vs Leisure speed', `${pace.ratio_vs_leisure.toFixed(2)}×`) : null,
pace.ratio_vs_leisure !== -1 ? pair(BASIS_ICON.leisure, 'vs Leisure speed', `${pace.ratio_vs_leisure.toFixed(2)}×`) : null,
// `t` is the formula's own symbol: 0 = rush speed, 1 = leisure speed.
pace.interpolation_t !== -1
? pair('t', 'Interpolation t, 0 = rush speed, 1 = leisure speed', pace.interpolation_t.toFixed(3))
? pair('summary.interpolation', 'Interpolation t, 0 = rush speed, 1 = leisure speed', pace.interpolation_t.toFixed(3))
: null,
pair('🎭', 'Play style', styleGlyph(pace.player_style)),
pair('summary.style', 'Play style', styleGlyph(pace.player_style)),
),
estimated !== null
? h(
@ -103,7 +109,7 @@ function playerInsight({ result, paceVsHltb: pace, presets }: SummaryProps): HTM
h(
'div',
{ class: 'player-insight-estimate-total' },
glyph('Σ', 'Estimated total at your pace: '),
glyph('summary.estimated-total', 'Estimated total at your pace: '),
' ',
h('strong', { class: 'player-insight-estimate-hours' }, fmtHours(estimated)),
),
@ -122,10 +128,10 @@ function basisCard(props: SummaryProps, c: (typeof CARDS)[number]): HTMLDivEleme
return h(
'div',
{ class: filters.basis === c.basis ? 'card active' : 'card', 'data-basis': c.basis },
h('div', { class: 'card-title' }, glyph(BASIS_GLYPH[c.basis], c.title)),
h('div', { class: 'card-title' }, glyph(BASIS_ICON[c.basis], c.title)),
spoken(c.blurb),
h('div', { class: 'card-total' }, isPace ? perDay(pace) : fmtHours(total)),
h('div', { class: 'card-eta' }, isPace && !pace ? glyph('∅', 'No start date set') : fmtEta(eta)),
h('div', { class: 'card-eta' }, isPace && !pace ? glyph('summary.no-start', 'No start date set') : fmtEta(eta)),
isPace ? null : presetRows(presets, (p) => etaDays(total, p)),
)
}
@ -143,15 +149,15 @@ export function summaryCards(props: SummaryProps, now: Date = new Date()): HTMLD
'div',
{},
h('span', { class: 'big' }, result.remainingGames.toLocaleString()),
glyph('🎮', 'games in scope', 'big-label'),
glyph('backlog.in-scope', 'games in scope', 'big-label'),
),
h(
'div',
{ class: 'parity', 'data-match': String(match) },
glyph('⌨️', 'CLI default qualifies '),
glyph('backlog.cli', 'CLI default qualifies '),
' ',
h('strong', {}, defaultQualifying),
match ? h('span', { class: 'ok' }, ' ✓', spoken(' match')) : null,
match ? h('span', { class: 'ok' }, ' ', iconInline('summary.match'), spoken(' match')) : null,
),
),
targetBanner(props, now),

View File

@ -7,7 +7,7 @@ import { makeGame, makePaceVsHltb, makeState } from '../../test/factories'
import { flush, mount, stubApi } from '../../test/harness'
import { GAMES, panel, show } from '../../test/plannerHelpers'
import { visibleWords } from '../../test/visibleWords'
import { ANY_GLYPH, KEEP_GLYPH, styleGlyph, tierGlyphs } from './glyphs'
import { keepText, styleGlyph, tierMarks, tierText } from './glyphs'
import { painted } from '../../test/painted'
afterEach(() => {
@ -50,11 +50,15 @@ describe('textgate guard: backlog', () => {
describe('backlog glyphs', () => {
it('paints ProtonDB tiers as medals, unknown tiers as ❔', () => {
expect(tierGlyphs('gold / silver')).toBe('🥇/🥈')
expect(tierGlyphs('—')).toBe('—')
expect(tierGlyphs('')).toBe('—')
expect(tierGlyphs('weird')).toBe('❔')
expect(KEEP_GLYPH.excluded).toBe('🚫')
const text = (label: string) => tierMarks(label).map((m) => (typeof m === 'string' ? m : m.textContent)).join('')
expect(text('gold / silver')).toBe('🥇/🥈')
expect(text('—')).toBe('—')
expect(text('')).toBe('—')
expect(text('weird')).toBe('❔')
expect(keepText('excluded')).toBe('🚫')
expect(tierText('gold / silver')).toBe('🥇/🥈')
expect(tierText('—')).toBe('—')
expect(tierText('weird')).toBe('❔')
})
it('speaks an unknown play style by its key', () => {
@ -67,7 +71,7 @@ describe('backlog glyphs', () => {
it('offers glyph options in the table filters, values unchanged', async () => {
await show()
const keep = screen.getByRole('combobox', { name: 'Filter Keep' })
expect([...keep.querySelectorAll('option')].map((o) => [o.value, o.textContent])).toContainEqual(['', ANY_GLYPH])
expect([...keep.querySelectorAll('option')].map((o) => [o.value, o.textContent])).toContainEqual(['', '✱'])
expect([...keep.querySelectorAll('option')].map((o) => [o.value, o.textContent])).toContainEqual(['kept', '📌'])
const tier = screen.getByRole('combobox', { name: 'Filter ProtonDB' })
expect([...tier.querySelectorAll('option')].map((o) => o.textContent)).toContain('🥇/💎')

View File

@ -60,7 +60,8 @@ describe('Dashboard', () => {
describe('assignment', () => {
it('summarises a healthy state', async () => {
show()
expect(await screen.findByText('Hollow Knight')).toHaveClass('hero-game')
// The billing line also names the game, behind its icon: pick the hero by class.
expect(await screen.findByText('Hollow Knight', { selector: '.hero-game' })).toHaveClass('hero-game')
expect(fact('Installed')).toHaveTextContent('Yes')
expect(fact('Games finished')).toHaveTextContent('3')
expect(fact('Store')).toHaveTextContent('Blocked')
@ -161,7 +162,7 @@ describe('Dashboard', () => {
it('stays out of the way when nothing is installing', async () => {
show({ 'GET /api/daemon': { ...daemon(), fast_installs: undefined } })
expect(await screen.findByText('Hollow Knight')).toBeInTheDocument()
expect(await screen.findByText('Hollow Knight', { selector: '.hero-game' })).toBeInTheDocument()
expect(screen.queryByText(/Fast-installing/)).not.toBeInTheDocument()
expect(screen.queryByRole('region', { name: 'Fast install' })).not.toBeInTheDocument()
})

View File

@ -8,6 +8,7 @@ import { commandIcon, commandLabel } from '../commands/catalog'
import '../commands/commandButton'
import { fmtDuration, fmtRemaining } from '../format'
import { progressBar, stateBadge, type BarTone } from '../jobs/progress'
import { iconInline } from '../icons/render'
import { define, h, hx } from '../lib/dom'
import { LiveElement } from '../lib/element'
import { jobHref } from '../lib/runner'
@ -15,11 +16,11 @@ import { card, empty, errorNotice, facts, glyph, link, loading } from '../ui/bui
import { ago } from '../ui/format'
import { said } from './spoken'
/** "5 min ago" painted as 🕓 5 min (the word "ago" spoken only). */
/** "5 min ago" painted as a clock icon and 5 min (the word "ago" spoken only). */
export function since(iso: string | null): HTMLSpanElement {
const spoken = ago(iso)
const short = spoken === 'just now' ? '<1 min' : spoken.replace(/ ago$/, '')
return said(spoken, '🕓 ', short)
return said(spoken, iconInline('dash.ago'), ' ', short)
}
/** Seconds left on the total block: from `until` when known, else the
@ -43,23 +44,26 @@ export class BlockCountdownElement extends LiveElement {
return
}
const left = fmtRemaining(blockSecondsLeft(block))
this.replaceChildren(h('span', { class: 'text-danger' }, said(`${left} left`, '⏳ ', left)))
this.replaceChildren(h('span', { class: 'text-danger' }, said(`${left} left`, iconInline('dash.block-left'), ' ', left)))
}
}
function statusFacts(s: StatusPayload): HTMLDListElement {
return facts([
[
glyph('💾', 'Installed'),
s.assigned_game_installed ? glyph('✅', 'Yes') : h('span', { class: 'text-warning' }, glyph('⚠️', 'No — install it from Library')),
glyph('dash.installed', 'Installed'),
s.assigned_game_installed ? glyph('state.yes', 'Yes') : h('span', { class: 'text-warning' }, glyph('state.warn', 'No — install it from Library')),
],
[glyph('🏆', 'Games finished'), s.finished_count],
[glyph('🛒', 'Store'), s.store_blocked ? glyph('🔒', 'Blocked') : h('span', { class: 'text-warning' }, glyph('🔓', 'Unblocked'))],
[glyph('🗂️', 'Installed games'), s.installed_count],
[glyph('⛔', 'Total block'), s.total_block.active ? hx('block-countdown') : glyph('➖', 'Off')],
[glyph('dash.finished', 'Games finished'), s.finished_count],
[
glyph('📌', 'Manual picks'),
s.manual_picks.length ? s.manual_picks.map((p) => `${p.name} (${p.age_days} d)`).join(', ') : glyph('➖', 'None'),
glyph('dash.store', 'Store'),
s.store_blocked ? glyph('dash.store-blocked', 'Blocked') : h('span', { class: 'text-warning' }, glyph('dash.store-open', 'Unblocked')),
],
[glyph('dash.games', 'Installed games'), s.installed_count],
[glyph('dash.total-block', 'Total block'), s.total_block.active ? hx('block-countdown') : glyph('state.off', 'Off')],
[
glyph('picks.manual', 'Manual picks'),
s.manual_picks.length ? s.manual_picks.map((p) => `${p.name} (${p.age_days} d)`).join(', ') : glyph('state.off', 'None'),
],
])
}
@ -71,13 +75,13 @@ export class DashboardStatusElement extends LiveElement {
protected update(): void {
const { data, error } = q.status.state
const icon = '🎯'
const icon = 'assigned.game'
if (error) {
this.replaceChildren(card('Assignment', errorNotice(error), { icon }))
} else if (!data) {
this.replaceChildren(card('Assignment', loading('status'), { icon }))
} else {
const game = data.current_game_name ?? glyph('📭', 'Nothing assigned')
const game = data.current_game_name ?? glyph('state.empty', 'Nothing assigned')
this.replaceChildren(
card('Assignment', [h('p', { class: 'hero-game' }, game), statusFacts(data)], {
icon,
@ -95,9 +99,9 @@ function budgetTone(blocked: boolean, used: number): BarTone {
}
function billingLine(blocked: boolean, label: string): HTMLParagraphElement {
if (blocked) return h('p', { class: 'field-help' }, glyph('⛔', 'Blocked for today.'))
if (!label) return h('p', { class: 'field-help' }, said('Now: nothing billing', '⏸️'))
return h('p', { class: 'field-help' }, said(`Now: ${label}`, '▶️ ', label))
if (blocked) return h('p', { class: 'field-help' }, glyph('dash.blocked-today', 'Blocked for today.'))
if (!label) return h('p', { class: 'field-help' }, said('Now: nothing billing', iconInline('dash.not-billing')))
return h('p', { class: 'field-help' }, said(`Now: ${label}`, iconInline('dash.billing'), ' ', label))
}
export class BudgetGlanceElement extends LiveElement {
@ -107,7 +111,7 @@ export class BudgetGlanceElement extends LiveElement {
protected update(): void {
const { data, error } = q.budget.state
const icon = '⏱️'
const icon = 'dash.budget'
if (error) {
this.replaceChildren(card('Gaming today', errorNotice(error), { icon }))
return
@ -128,8 +132,8 @@ export class BudgetGlanceElement extends LiveElement {
progressBar(t.fraction_used, 'Budget used', budgetTone(t.blocked, t.fraction_used)),
billingLine(t.blocked, data.session.billing_label),
]
: h('p', { class: 'text-danger' }, data.error ?? glyph('⚠️', 'Budget state unavailable.'))
this.replaceChildren(card('Gaming today', body, { icon, aside: link('/gaming/', glyph('➡️', 'Details')) }))
: h('p', { class: 'text-danger' }, data.error ?? glyph('state.warn', 'Budget state unavailable.'))
this.replaceChildren(card('Gaming today', body, { icon, aside: link('/gaming/', glyph('action.open', 'Details')) }))
}
}
@ -140,8 +144,8 @@ function fastInstallRow(r: FastInstallRun): HTMLDivElement {
return h(
'div',
{},
h('p', { class: 'text-danger' }, said(`Fast install of ${r.name} failed: ${r.error}`, '⛔ ', r.name, ': ', r.error)),
h('p', { class: 'field-help' }, glyph('↪️', "Steam's own download took over.")),
h('p', { class: 'text-danger' }, said(`Fast install of ${r.name} failed: ${r.error}`, iconInline('dash.fast-failed'), ' ', r.name, ': ', r.error)),
h('p', { class: 'field-help' }, glyph('dash.steam-took-over', "Steam's own download took over.")),
)
}
const pct = r.percent === null ? null : Math.floor(r.percent)
@ -149,9 +153,9 @@ function fastInstallRow(r: FastInstallRun): HTMLDivElement {
return h(
'div',
{},
h('p', {}, said(`Fast-installing ${r.name} — ${where}`, '⚡ ', r.name, pct === null ? '' : ` ${pct}%`)),
h('p', {}, said(`Fast-installing ${r.name} — ${where}`, iconInline('dash.fast-install'), ' ', r.name, pct === null ? '' : ` ${pct}%`)),
progressBar(pct === null ? null : pct / 100, `${r.name} download`),
h('p', { class: 'field-help' }, said(`${fmtDuration(r.elapsed_seconds)} elapsed`, '⏳ ', fmtDuration(r.elapsed_seconds))),
h('p', { class: 'field-help' }, said(`${fmtDuration(r.elapsed_seconds)} elapsed`, iconInline('dash.elapsed'), ' ', fmtDuration(r.elapsed_seconds))),
)
}
@ -163,7 +167,7 @@ export class FastInstallsElement extends LiveElement {
protected update(): void {
const runs = q.daemon.state.data?.fast_installs ?? []
this.replaceChildren(...(runs.length ? [card('Fast install', runs.map(fastInstallRow), { icon: '⚡' })] : []))
this.replaceChildren(...(runs.length ? [card('Fast install', runs.map(fastInstallRow), { icon: 'dash.fast-install' })] : []))
}
}
@ -201,7 +205,7 @@ export class RecentJobsElement extends LiveElement {
),
),
],
{ icon: '⚙️', aside: link('/jobs/', glyph('➡️', 'All jobs')) },
{ icon: 'dash.recent-jobs', aside: link('/jobs/', glyph('action.open', 'All jobs')) },
),
)
}

View File

@ -6,6 +6,8 @@
import { OTHER_KEY, UNATTRIBUTED_KEY, seriesClass } from '../../budgetSeries'
import { fmtAgo, fmtDuration } from '../../format'
import { budgetHistorySvg } from '../../lib/charts/budgetHistory'
import { iconInline } from '../../icons/render'
import type { IconId } from '../../icons/registry'
import { h } from '../../lib/dom'
import type { BudgetHistoryDay, BudgetLegendEntry, BudgetRules, BudgetSession, BudgetToday } from '../../types'
import { glyph } from '../../ui/build'
@ -25,17 +27,17 @@ function meterState(today: BudgetToday): string {
/** A series name: game names are content; the sentinels and the "(launcher)" tag are glyphs. */
export function seriesLabel(key: string, label: string): HTMLElement {
if (key === OTHER_KEY) return glyph('➕', label)
if (key === UNATTRIBUTED_KEY) return glyph('❔', label)
if (key.startsWith('launcher:')) return said(label, '🚀 ', label.replace(/\s*\(launcher\)$/, ''))
if (key === OTHER_KEY) return glyph('gaming.series.other', label)
if (key === UNATTRIBUTED_KEY) return glyph('gaming.series.unattributed', label)
if (key.startsWith('launcher:')) return said(label, iconInline('gaming.launcher'), ' ', label.replace(/\s*\(launcher\)$/, ''))
return h('span', {}, label)
}
/** "5m ago" painted as 🕓 5m. */
/** "5m ago" painted as the as-of icon and 5m. */
function asOf(iso: string): HTMLElement {
const ago = fmtAgo(iso)
const short = ago === 'unknown' ? '?' : ago === 'just now' ? '<10s' : ago.replace(/ ago$/, '')
return said(`as of ${ago}`, '🕓 ', short)
return said(`as of ${ago}`, iconInline('dash.ago'), ' ', short)
}
function warningLine(today: BudgetToday, maskedCount: number): HTMLElement {
@ -48,14 +50,14 @@ function warningLine(today: BudgetToday, maskedCount: number): HTMLElement {
'span',
{ class: 'budget-badge budget-badge--blocked' },
maskedCount > 0
? glyph('⛔🔒', 'Cutoff engaged — launchers are masked')
: glyph('⛔🔓', 'Cutoff engaged — launchers are not currently masked'),
? glyph('gaming.cutoff.masked', 'Cutoff engaged — launchers are masked')
: glyph('gaming.cutoff.unmasked', 'Cutoff engaged — launchers are not currently masked'),
)
}
const next = today.next_warning_seconds
return next === null
? glyph('🔕', 'No further warnings today.')
: said(`Next warning at ${fmtDuration(next)} remaining.`, '🔔 ', fmtDuration(next))
? glyph('gaming.warn.none', 'No further warnings today.')
: said(`Next warning at ${fmtDuration(next)} remaining.`, iconInline('gaming.warning'), ' ', fmtDuration(next))
}
function usageLine(t: BudgetToday): HTMLElement {
@ -63,7 +65,18 @@ function usageLine(t: BudgetToday): HTMLElement {
const spoken =
`${fmtDuration(t.seconds_used)} of ${fmtDuration(t.budget_seconds)} used · ` +
`${Math.round(t.fraction_used * 100)}% · gaming day ${t.gaming_day} (starts ${t.day_starts_at})`
return said(spoken, used, ' · 📅 ', t.gaming_day, ' · 🌅 ', t.day_starts_at.replace(/\s*local$/, ''))
return said(
spoken,
used,
' · ',
iconInline('gaming.day'),
' ',
t.gaming_day,
' · ',
iconInline('gaming.day_start'),
' ',
t.day_starts_at.replace(/\s*local$/, ''),
)
}
export function todayCard(today: BudgetToday, legend: readonly BudgetLegendEntry[], maskedCount: number): HTMLElement {
@ -76,14 +89,14 @@ export function todayCard(today: BudgetToday, legend: readonly BudgetLegendEntry
return h(
'section',
{ class: 'budget-today' },
h('h2', {}, glyph('📅', 'Today')),
h('h2', {}, glyph('gaming.today', 'Today')),
h('p', { class: 'budget-hero' }, h('strong', {}, fmtDuration(today.seconds_remaining)), h('span', { class: 'sr-only' }, ' left')),
h('div', { class: `budget-meter budget-meter--${meterState(today)}` }, fill),
h('p', { class: 'hint' }, usageLine(today)),
h('p', { class: 'hint' }, warningLine(today, maskedCount)),
today.games.length > 0
? [
h('h3', { class: 'budget-subhead' }, glyph('🎮', 'Today by game')),
h('h3', { class: 'budget-subhead' }, glyph('gaming.by_game', 'Today by game')),
h(
'ul',
{ class: 'budget-games' },
@ -108,23 +121,23 @@ export function todayUnavailable(error: string | null): HTMLElement {
return h(
'section',
{ class: 'budget-today' },
h('h2', {}, glyph('📅', 'Today')),
h('h2', {}, glyph('gaming.today', 'Today')),
// The server's own error is shown as is; the fallback is a glyph.
h('p', { class: 'error' }, error ?? glyph('⚠️', 'Budget state unavailable.')),
h('p', { class: 'error' }, error ?? glyph('state.warn', 'Budget state unavailable.')),
)
}
const VERDICT = new Map([
['engaged', ['▶️', 'Billing — you are playing']],
['not_applicable', ['⏸️', 'Not billing — no game running']],
const VERDICT = new Map<string, readonly [IconId, string]>([
['engaged', ['dash.billing', 'Billing — you are playing']],
['not_applicable', ['dash.not-billing', 'Not billing — no game running']],
])
export function liveCard(session: BudgetSession): HTMLElement {
const title = h('h2', {}, glyph('📡', 'Right now'))
const title = h('h2', {}, glyph('gaming.right_now', 'Right now'))
if (!session.available) {
return h('section', { class: 'budget-live' }, title, h('p', { class: 'hint' }, glyph('📭', 'No verdict has been logged yet.')))
return h('section', { class: 'budget-live' }, title, h('p', { class: 'hint' }, glyph('state.empty', 'No verdict has been logged yet.')))
}
const [icon, verdict] = VERDICT.get(session.state) ?? ['❔', session.state]
const [icon, verdict] = VERDICT.get(session.state) ?? (['state.unknown', session.state] as const)
return h(
'section',
{ class: 'budget-live' },
@ -134,8 +147,8 @@ export function liveCard(session: BudgetSession): HTMLElement {
? h(
'p',
{ class: 'hint' },
session.game_name ? [said('Assigned game ', '🎯 '), h('strong', {}, session.game_name), ' · '] : null,
said(`${session.qualifying_count} qualifying processes`, '⚙️ ', session.qualifying_count),
session.game_name ? [said('Assigned game ', iconInline('assigned.game'), ' '), h('strong', {}, session.game_name), ' · '] : null,
said(`${session.qualifying_count} qualifying processes`, iconInline('gaming.qualifying'), ' ', session.qualifying_count),
)
: null,
// The assignment above is what the enforcer told you to play; this is
@ -146,7 +159,9 @@ export function liveCard(session: BudgetSession): HTMLElement {
? h(
'p',
{ class: 'hint' },
session.state === 'engaged' ? said('Billing to ', '💸 ') : said('Last billed to ', '⏮️💸 '),
session.state === 'engaged'
? said('Billing to ', iconInline('gaming.billing_to'), ' ')
: said('Last billed to ', iconInline('gaming.billed_last'), ' '),
h('strong', {}, session.billing_label),
)
: null,
@ -157,13 +172,13 @@ export function liveCard(session: BudgetSession): HTMLElement {
}
export function historyCard(days: readonly BudgetHistoryDay[], legend: readonly BudgetLegendEntry[], budgetSeconds: number): HTMLElement {
const title = h('h2', {}, glyph('📊', 'Last 14 days'))
const title = h('h2', {}, glyph('gaming.history', 'Last 14 days'))
if (days.length === 0) {
return h(
'div',
{ class: 'chart' },
title,
h('p', { class: 'hint' }, glyph('📭', 'No budget history recorded yet — a bar appears for each gaming day from now on.')),
h('p', { class: 'hint' }, glyph('state.empty', 'No budget history recorded yet — a bar appears for each gaming day from now on.')),
)
}
// A <template> parses the markup as HTML, which puts <svg> in the SVG namespace.
@ -189,24 +204,24 @@ export function historyCard(days: readonly BudgetHistoryDay[], legend: readonly
)
}
const onOff = (value: boolean, on: string, off: string) => (value ? glyph('✅', on) : glyph('➖', off))
const onOff = (value: boolean, on: string, off: string) => (value ? glyph('state.yes', on) : glyph('state.off', off))
export function rulesCard(rules: BudgetRules): HTMLElement {
const row = (icon: string, term: string, value: Node | string) => [h('dt', {}, glyph(icon, term)), h('dd', {}, value)]
const row = (icon: IconId, term: string, value: Node | string) => [h('dt', {}, glyph(icon, term)), h('dd', {}, value)]
const warn = rules.warn_at.map((s) => fmtDuration(s)).join(', ')
return h(
'section',
{ class: 'budget-rules' },
h('h2', {}, glyph('📏', 'Rules in effect')),
h('h2', {}, glyph('gaming.rules', 'Rules in effect')),
h(
'dl',
{ class: 'budget-rules-list' },
row('⏱️', 'Daily budget', fmtDuration(rules.budget_seconds)),
row('🛡️', 'Enforcement', onOff(rules.enforcement, 'on', 'off')),
row('🚀', 'Counts launchers', onOff(rules.counts_launchers, 'yes', 'no')),
row('🔔', 'Warnings at', said(`${warn} remaining`, warn)),
rules.demo ? row('🧪', 'Mode', glyph('🧪', 'demo (short budget, separate state)')) : null,
rules.masked_launchers.length > 0 ? row('🔒', 'Masked now', rules.masked_launchers.join(', ')) : null,
row('gaming.budget', 'Daily budget', fmtDuration(rules.budget_seconds)),
row('gaming.enforcement', 'Enforcement', onOff(rules.enforcement, 'on', 'off')),
row('gaming.launcher', 'Counts launchers', onOff(rules.counts_launchers, 'yes', 'no')),
row('gaming.warning', 'Warnings at', said(`${warn} remaining`, warn)),
rules.demo ? row('gaming.mode', 'Mode', glyph('gaming.demo', 'demo (short budget, separate state)')) : null,
rules.masked_launchers.length > 0 ? row('gaming.masked', 'Masked now', rules.masked_launchers.join(', ')) : null,
),
)
}

View File

@ -0,0 +1,82 @@
// The gaming page paints every icon through the registry: the user's word
// shows right of the icon, a chosen alternative glyph replaces the default,
// and the spoken sentence stays as it was.
import { screen } from '@testing-library/dom'
import { afterEach, describe, expect, it } from 'vitest'
import { OTHER_KEY } from '../../budgetSeries'
import { makeBudgetRules, makeBudgetSession, makeBudgetToday } from '../../test/factories'
import { mount } from '../../test/harness'
import { useIcons } from '../../test/iconLedger'
import { liveCard, rulesCard, seriesLabel, todayCard, todayUnavailable } from './cards'
import './panel'
const show = (el: HTMLElement) => {
document.body.replaceChildren(el)
}
const words = () => [...document.querySelectorAll('.icon-word')].map((w) => w.textContent)
afterEach(() => {
history.replaceState(null, '', '/')
})
describe('gaming page icons', () => {
it('rules card: a word right of the row icon, an alternative glyph, spoken names kept', () => {
useIcons({ 'gaming.budget': { word: 'allowance' }, 'gaming.enforcement': { glyph: '⚔️' }, 'state.yes': { word: 'on' } })
show(rulesCard(makeBudgetRules()))
const term = document.querySelector('dt')
expect(term?.querySelector('[data-icon]')?.nextElementSibling).toHaveClass('icon-word')
expect(term?.querySelector('.icon-word')?.textContent).toBe('Allowance')
expect(term?.querySelector('.sr-only')?.textContent).toBe('Daily budget')
expect(document.querySelectorAll('dt').item(1).querySelector('[data-icon]')?.textContent).toBe('⚔️')
expect(words()).toEqual(['Allowance', 'On', 'On'])
})
it('today card: warning, gaming day and heading icons carry the words', () => {
useIcons({ 'gaming.warning': { word: 'bell' }, 'gaming.day': { word: 'date' }, 'gaming.today': { glyph: '🗓️' } })
show(todayCard(makeBudgetToday(), [], 0))
expect(words()).toEqual(['Date', 'Bell'])
expect(screen.getByText(/Next warning at 1h 0m remaining/)).toBeInTheDocument()
expect(document.querySelector('h2 [data-icon]')?.textContent).toBe('🗓️')
})
it('unavailable and empty marks reuse the shared state icons', () => {
useIcons({ 'state.warn': { word: 'attention' } })
show(todayUnavailable(null))
expect(words()).toEqual(['Attention'])
expect(screen.getByText('Budget state unavailable.')).toBeInTheDocument()
})
it('live card: the verdict icon swaps and the billing icon shows its word', () => {
useIcons({ 'dash.billing': { glyph: '⏺️' }, 'gaming.billing_to': { word: 'charging' }, 'assigned.game': { word: 'target' } })
show(liveCard(makeBudgetSession()))
expect(document.querySelector('.budget-verdict [data-icon]')?.textContent).toBe('⏺️')
expect(words()).toEqual(['Target', 'Charging'])
expect(screen.getByText('Billing to')).toBeInTheDocument()
expect(screen.getByText('Billing — you are playing')).toBeInTheDocument()
})
it('series labels: the other-games sentinel and a launcher carry their icons', () => {
useIcons({ 'gaming.series.other': { word: 'rest' }, 'gaming.launcher': { word: 'client' } })
show(wrap(seriesLabel(OTHER_KEY, 'Other games')))
expect(words()).toEqual(['Rest'])
show(wrap(seriesLabel('launcher:epic', 'Epic (launcher)')))
expect(words()).toEqual(['Client'])
expect(document.body.textContent).toContain('Epic')
})
it('mode link: the demo and production icons take the chosen glyph', () => {
useIcons({ 'gaming.demo': { glyph: '🔬' }, 'gaming.production': { glyph: '🏢' } })
mount('<budget-mode-link></budget-mode-link>')
expect(screen.getByRole('link', { name: 'Show demo budget' }).querySelector('[data-icon]')?.textContent).toBe('🔬')
history.replaceState(null, '', '/gaming/?demo=1')
mount('<budget-mode-link></budget-mode-link>')
expect(screen.getByRole('link', { name: 'Show production budget' }).querySelector('[data-icon]')?.textContent).toBe('🏢')
})
})
function wrap(child: HTMLElement): HTMLElement {
const el = document.createElement('div')
el.append(child)
return el
}

View File

@ -5,6 +5,7 @@
import { explain } from '../../api/errors'
import { q } from '../../api/queries'
import { iconInline } from '../../icons/render'
import { define, h } from '../../lib/dom'
import { LiveElement } from '../../lib/element'
import { commandLine, glyph, loading } from '../../ui/build'
@ -21,12 +22,12 @@ export function isDemo(search: string = location.search): boolean {
export class BudgetModeLinkElement extends LiveElement {
protected update(): void {
const demo = isDemo()
// 🧪 switches to the demo budget, 🏭 back to production; the words are spoken.
// The demo icon switches to the demo budget, the production icon back; the words are spoken.
this.replaceChildren(
h(
'a',
{ href: demo ? '/gaming/' : '/gaming/?demo=1', class: 'btn btn-ghost' },
demo ? glyph('🏭', 'Show production budget') : glyph('🧪', 'Show demo budget'),
demo ? glyph('gaming.production', 'Show production budget') : glyph('gaming.demo', 'Show demo budget'),
),
)
}
@ -50,7 +51,7 @@ export class BudgetPanelElement extends LiveElement {
{ class: 'status' },
// The server's own detail is painted; the framing is spoken. The
// command is the recovery path, so it stays with a copy button.
h('p', { class: 'error' }, said(`Could not read budget state: ${explain(error).detail}`, '⛔ ', explain(error).detail)),
h('p', { class: 'error' }, said(`Could not read budget state: ${explain(error).detail}`, iconInline('notice.danger'), ' ', explain(error).detail)),
h('p', { class: 'hint' }, h('span', { class: 'sr-only' }, 'Is the backend running? Start it with')),
commandLine('./run.sh serve'),
),

View File

@ -7,6 +7,7 @@ import { explain } from '../api/errors'
import type { Job } from '../api/jobContract'
import { q } from '../api/queries'
import { commandIcon, commandLabel } from '../commands/catalog'
import { iconInline } from '../icons/render'
import '../jobs/jobProgress'
import { stateBadge } from '../jobs/progress'
import { define, h, hx } from '../lib/dom'
@ -86,10 +87,10 @@ export class JobListElement extends LiveElement {
h(
'tr',
{},
h('th', { scope: 'col' }, glyph('⌨️', 'Command')),
h('th', { scope: 'col' }, glyph('🚦', 'State')),
h('th', { scope: 'col' }, glyph('🕐', 'Started')),
h('th', { scope: 'col', class: 'num' }, glyph('⏱️', 'Took')),
h('th', { scope: 'col' }, glyph('jobs.command', 'Command')),
h('th', { scope: 'col' }, glyph('jobs.state', 'State')),
h('th', { scope: 'col' }, glyph('jobs.started', 'Started')),
h('th', { scope: 'col', class: 'num' }, glyph('jobs.took', 'Took')),
),
),
this.body,
@ -125,12 +126,12 @@ export class JobListElement extends LiveElement {
}
function notFound(id: string, error: ApiFailure): HTMLDivElement {
// ❓ + the id painted; the explanation and the server's message are spoken.
// The not-found icon + the id painted; the explanation and the server's message are spoken.
const el = notice(
'warning',
null,
h('p', { class: 'm0' }, h('span', { 'aria-hidden': 'true' }, '❓ '), h('span', { class: 'mono' }, id)),
h('p', { class: 'm0' }, link(pageHref('/jobs'), glyph('📋', 'See all jobs'), '')),
h('p', { class: 'm0' }, h('span', { 'aria-hidden': 'true' }, iconInline('jobs.not-found'), ' '), h('span', { class: 'mono' }, id)),
h('p', { class: 'm0' }, link(pageHref('/jobs'), glyph('jobs.all', 'See all jobs'), '')),
)
el.dataset.code = 'not_found'
el.setAttribute('aria-label', `Job not found. There is no job ${id}. It may have been pruned: the history keeps the last 50.${error.message ? ` ${error.message}` : ''}`)
@ -155,7 +156,7 @@ export class JobDetailElement extends LiveElement {
this.sub = h('p', { class: 'sub' })
this.status = h('div', { class: 'contents' })
this.mounted = false
this.replaceChildren(pageHead(this.heading, this.sub, link(pageHref('/jobs'), glyph('📋', 'All jobs'), 'btn btn-ghost')), this.status)
this.replaceChildren(pageHead(this.heading, this.sub, link(pageHref('/jobs'), glyph('jobs.all', 'All jobs'), 'btn btn-ghost')), this.status)
// Subscribed by hand, not via watch(): an unknown id stops polling.
let live = true
const off = q.job(this.jobId).subscribe(() => {
@ -172,12 +173,12 @@ export class JobDetailElement extends LiveElement {
const id = this.jobId
const { data, error, loading: waiting } = q.job(id).state
const missing = !data && error instanceof ApiFailure && error.code === 'not_found' ? error : null
// Heading: the command's glyph (❓ when the id is unknown, ⚙️ while loading), name spoken.
this.heading.replaceChildren(data ? commandGlyph(data.command) : missing ? glyph('❓', 'Job not found') : glyph('⚙️', 'Job'))
// Heading: the command's glyph (the not-found icon when the id is unknown, the job icon while loading), name spoken.
this.heading.replaceChildren(data ? commandGlyph(data.command) : missing ? glyph('jobs.not-found', 'Job not found') : glyph('jobs.job', 'Job'))
this.sub.replaceChildren(
h('span', { class: 'sr-only' }, 'Job '),
h('span', { class: 'mono' }, id),
data ? h('span', {}, h('span', { 'aria-hidden': 'true' }, ' · 🕐 '), h('span', { class: 'sr-only' }, ' · created '), dateTime(data.created_at)) : '',
data ? h('span', {}, h('span', { 'aria-hidden': 'true' }, ' · ', iconInline('jobs.started'), ' '), h('span', { class: 'sr-only' }, ' · created '), dateTime(data.created_at)) : '',
)
this.status.replaceChildren(
...(missing ? [notFound(id, missing)] : error ? [errorNotice(error)] : waiting ? [loading('job')] : []),

View File

@ -4,6 +4,8 @@
// browser's search state, so a reload comes back to it.
import { q } from '../api/queries'
import type { IconId } from '../icons/registry'
import { iconInline } from '../icons/render'
import { define, h, hx } from '../lib/dom'
import { LiveElement } from '../lib/element'
import '../library/gameBrowser'
@ -13,10 +15,10 @@ import { bytes } from '../ui/format'
type View = 'all' | 'installed'
/** View key, spoken label, painted glyph. */
const VIEWS: [View, string, string][] = [
['all', 'All games', '🗂️'],
['installed', 'Installed', '💾'],
/** View key, spoken label, painted icon. */
const VIEWS: [View, string, IconId][] = [
['all', 'All games', 'libpage.all'],
['installed', 'Installed', 'dash.installed'],
]
const viewFromHash = (): View => (readHash().get('view') === 'installed' ? 'installed' : 'all')
@ -66,10 +68,10 @@ export class InstalledTableElement extends LiveElement {
h(
'tr',
{},
h('th', { scope: 'col' }, glyph('🎮', 'Game')),
h('th', { scope: 'col' }, glyph('#', 'App id')),
h('th', { scope: 'col', class: 'num' }, glyph('💽', 'Size')),
h('th', { scope: 'col' }, glyph('🏷️', 'Role')),
h('th', { scope: 'col' }, glyph('libpage.game', 'Game')),
h('th', { scope: 'col' }, glyph('libpage.app-id', 'App id')),
h('th', { scope: 'col', class: 'num' }, glyph('libpage.size', 'Size')),
h('th', { scope: 'col' }, glyph('libpage.role', 'Role')),
),
),
h(
@ -85,9 +87,9 @@ export class InstalledTableElement extends LiveElement {
h(
'td',
{},
g.assigned ? pill('accent', 'assigned', '🎯') : null,
g.protected ? pill('neutral', 'protected', '🛡️') : null,
!g.assigned && !g.protected ? glyph('🗑️', 'uninstall candidate', 'muted') : null,
g.assigned ? pill('accent', 'assigned', 'assigned.game') : null,
g.protected ? pill('neutral', 'protected', 'libpage.protected') : null,
!g.assigned && !g.protected ? glyph('libpage.candidate', 'uninstall candidate', 'muted') : null,
),
),
),
@ -97,12 +99,12 @@ export class InstalledTableElement extends LiveElement {
: null,
],
{
icon: '💾',
icon: 'dash.installed',
aside: data
? h(
'span',
{ class: 'muted' },
h('span', { 'aria-hidden': 'true' }, `🎮 ${games.length} · 💽 ${bytes(total)}`),
h('span', { 'aria-hidden': 'true' }, iconInline('libpage.game'), ` ${games.length} · `, iconInline('libpage.size'), ` ${bytes(total)}`),
h('span', { class: 'sr-only' }, `${games.length} games · ${bytes(total)}`),
)
: null,
@ -143,7 +145,7 @@ export class LibraryViewElement extends HTMLElement {
this.show(key)
},
},
h('span', { 'aria-hidden': 'true' }, icon),
h('span', { 'aria-hidden': 'true' }, iconInline(icon)),
)
this.buttons.set(key, btn)
return btn

View File

@ -19,8 +19,8 @@ export class BacklogOverviewElement extends LiveElement {
protected update(): void {
const { data, error } = q.dataset.state
const aside = link('/backlog/', glyph('➡️', 'Open the planner'))
const icon = '📚'
const aside = link('/backlog/', glyph('action.open', 'Open the planner'))
const icon = 'dash.outlook'
if (!data) {
this.replaceChildren(card('Backlog outlook', error ? errorNotice(error) : loading('backlog'), { aside, icon }))
return

View File

@ -0,0 +1,104 @@
// Pass 2 wiring for the dashboard, picks, store, setup and library pages:
// a ledger word shows right of its icon, a chosen alternative glyph replaces
// the default, and the spoken text is unchanged.
import { screen, waitFor } from '@testing-library/dom'
import { describe, expect, it } from 'vitest'
import { makeInstalled, makeLibGame, makeStatus } from '../test/fixtures'
import { mount, stubApi } from '../test/harness'
import { useIcons } from '../test/iconLedger'
import './dashboard'
import './library'
import './picks'
import './setup'
import './store'
const word = (el: Element | null | undefined) => el?.nextElementSibling?.textContent
const markOf = (root: ParentNode, id: string) => root.querySelector(`[data-icon="${id}"], [data-icon-word="${id}"]`)
describe('dashboard icons', () => {
it('a fact row paints its icon word and chosen glyph, the label stays spoken', async () => {
useIcons({ 'dash.finished': { word: 'trophies', glyph: '🥇' }, 'state.yes': { word: 'yes' } })
stubApi({ 'GET /api/status': makeStatus(), 'GET /api/commands': [] })
mount('<dashboard-status></dashboard-status>')
const label = await screen.findByText('Games finished', { selector: 'dt .sr-only' })
const icon = label.closest('dt')?.querySelector('[data-icon="dash.finished"]')
expect(icon?.textContent).toBe('🥇')
expect(word(icon)).toBe('Trophies')
expect(label).toHaveClass('sr-only')
const installed = screen.getByText('Installed', { selector: 'dt .sr-only' }).closest('dt')?.nextElementSibling
expect(word(installed?.querySelector('[data-icon="state.yes"]'))).toBe('Yes')
})
it('the store row and the block countdown use their own icons', async () => {
useIcons({ 'dash.store-blocked': { word: 'shut' }, 'dash.block-left': { word: 'left' } })
stubApi({
'GET /api/status': makeStatus({ total_block: { active: true, days_remaining: 2, until: null } }),
'GET /api/commands': [],
})
const el = mount('<dashboard-status></dashboard-status>')
await screen.findAllByText('Store', { selector: 'dt .sr-only' })
expect(word(markOf(el, 'dash.store-blocked'))).toBe('Shut')
expect(word(markOf(el, 'dash.block-left'))).toBe('Left')
})
})
describe('store notice icon', () => {
it('paints the store-lock icon, its word and glyph, the sentence stays spoken', async () => {
useIcons({ 'store.blocked': { word: 'sealed', glyph: '🛑' } })
stubApi({ 'GET /api/status': makeStatus({ store_blocked: true }) })
mount('<store-notice></store-notice>')
const notice = await screen.findByRole('status')
const icon = markOf(notice, 'store.blocked')
expect(icon?.textContent).toBe('🛑')
expect(word(icon)).toBe('Sealed')
expect(screen.getByText(/Store blocked\./)).toHaveClass('sr-only')
})
})
describe('picks icons', () => {
it('a pick row paints the age icon and the kept pin with their words', async () => {
const pick = (app_id: number, name: string) => ({ app_id, name, age_days: 3 })
useIcons({ 'picks.age': { word: 'picked' }, 'picks.kept': { word: 'kept', glyph: '💚' } })
stubApi({
'GET /api/status': makeStatus({ manual_picks: [pick(1, 'Celeste')], kept_picks: [pick(2, 'Hades')] }),
'GET /api/commands': [],
})
const el = mount('<manual-picks></manual-picks>')
await screen.findByText('Celeste')
expect(word(markOf(el, 'picks.age'))).toBe('Picked')
const kept = markOf(el, 'picks.kept')
expect(kept?.textContent).toBe('💚')
expect(word(kept)).toBe('Kept')
expect(screen.getByText('· picked 3 d ago · 1')).toHaveClass('sr-only')
})
})
describe('setup icons', () => {
it('the field icons and the stored-key placeholder follow the ledger', async () => {
useIcons({ 'setup.api-key': { word: 'key' }, 'setup.key-stored': { word: 'stored', glyph: '🔐' } })
stubApi({ 'GET /api/setup': { configured: true, has_api_key: true, steam_id: '76561198000000000' } })
const el = mount('<setup-form></setup-form>')
expect(word(markOf(el, 'setup.api-key'))).toBe('Key')
expect(screen.getByLabelText<HTMLInputElement>('Steam Web API key')).toBeInTheDocument()
await waitFor(() => {
expect(screen.getByLabelText<HTMLInputElement>('Steam Web API key').placeholder).toBe(`🔐 Stored ${'•'.repeat(32)}`)
})
})
})
describe('library page icons', () => {
it('the installed table headers and the view switch paint their words', async () => {
useIcons({ 'libpage.size': { word: 'space', glyph: '📏' }, 'libpage.all': { word: 'covers' } })
stubApi({
'GET /api/library': { games: [makeLibGame({ app_id: 1, name: 'Hollow Knight' })] },
'GET /api/installed': { games: [makeInstalled({ app_id: 5, name: 'Portal' })] },
'GET /api/commands': [],
})
mount('<library-view></library-view>')
const th = (await screen.findByText('Size', { selector: 'th .sr-only' })).closest('th')
expect(th?.querySelector('[data-icon="libpage.size"]')?.textContent).toBe('📏')
expect(word(th?.querySelector('[data-icon="libpage.size"]'))).toBe('Space')
expect(screen.getByRole('button', { name: 'All games' })).toHaveTextContent('Covers')
})
})

View File

@ -3,12 +3,13 @@
import { q } from '../api/queries'
import { commandButton } from '../commands/commandButton'
import { define, h } from '../lib/dom'
import { iconInline } from '../icons/render'
import { define, h, type Child } from '../lib/dom'
import { LiveElement } from '../lib/element'
import { card, empty, errorNotice, loading } from '../ui/build'
/** Glyphs and numbers painted, the sentence spoken. */
function glyphText(painted: string, spoken: string): HTMLSpanElement {
function glyphText(painted: readonly Child[], spoken: string): HTMLSpanElement {
return h('span', { class: 'muted' }, h('span', { 'aria-hidden': 'true' }, painted), h('span', { class: 'sr-only' }, spoken))
}
@ -51,7 +52,7 @@ export class ManualPicksElement extends LiveElement {
{ class: 'grow' },
h('strong', {}, p.name),
' ',
glyphText(`· 🕐 ${p.age_days} d · ${p.app_id}`, `· picked ${p.age_days} d ago · ${p.app_id}`),
glyphText(['· ', iconInline('picks.age'), ` ${p.age_days} d · ${p.app_id}`], `· picked ${p.age_days} d ago · ${p.app_id}`),
),
abandon(p.app_id),
),
@ -61,7 +62,7 @@ export class ManualPicksElement extends LiveElement {
h(
'li',
{ class: 'row' },
h('span', { class: 'grow' }, h('strong', {}, p.name), ' ', glyphText(`· 📌 🔓 · ${p.app_id}`, `· kept · no lock · ${p.app_id}`)),
h('span', { class: 'grow' }, h('strong', {}, p.name), ' ', glyphText(['· ', iconInline('picks.kept'), ' ', iconInline('state.unlocked'), ` · ${p.app_id}`], `· kept · no lock · ${p.app_id}`)),
abandon(p.app_id),
),
),
@ -69,7 +70,7 @@ export class ManualPicksElement extends LiveElement {
none
? h('div', { class: 'actions' }, commandButton({ name: 'abandon-pick', label: 'Abandon a pick by app id…' }))
: null,
], { icon: '📌' }),
], { icon: 'picks.manual' }),
)
}
}

View File

@ -7,6 +7,8 @@
import { api } from '../api/client'
import { q } from '../api/queries'
import { Action } from '../lib/action'
import type { IconId } from '../icons/registry'
import { iconFor, iconInline } from '../icons/render'
import { append, define, h, type Child } from '../lib/dom'
import { LiveElement } from '../lib/element'
import { invalidateAll } from '../lib/query'
@ -27,9 +29,9 @@ export function idError(id: string): string | null {
return ID_RE.test(id.trim()) ? null : 'A SteamID64 is 17 digits and starts with 7656.'
}
// Textgate: help is a 🔗 to where the value comes from; its sentence is spoken only.
// Textgate: help is a link icon to where the value comes from; its sentence is spoken only.
const helpLink = (href: string, spoken: string, sentence: string): Child[] => [
h('a', { href, target: '_blank', rel: 'noreferrer', class: 'setup-link', 'aria-label': spoken }, '🔗'),
h('a', { href, target: '_blank', rel: 'noreferrer', class: 'setup-link', 'aria-label': spoken }, iconInline('setup.help')),
h('span', { class: 'sr-only' }, sentence),
]
const KEY_HELP = (): Child[] =>
@ -38,19 +40,24 @@ const ID_HELP = (): Child[] => helpLink('https://steamid.io', 'steamid.io', 'You
/** Placeholders paint the expected shape: one dot per character, the fixed 7656 prefix. */
const KEY_SHAPE = '·'.repeat(32)
const KEY_STORED = `🔒 ${'•'.repeat(32)}`
const ID_SHAPE = `7656${'·'.repeat(13)}`
/** A placeholder is plain text: the stored-key icon (and its word, if any) then filled dots. */
function keyStored(): string {
const { glyph: mark, word } = iconFor('setup.key-stored')
return `${mark}${word ? ` ${word}` : ''} ${'•'.repeat(32)}`
}
interface Field {
input: HTMLInputElement
help: HTMLParagraphElement
hint: () => Child[]
baseClass: string
/** Characters a valid value has; a bad value paints `⚠️ typed/want`. */
/** Characters a valid value has; a bad value paints the warning icon and `typed/want`. */
want: number
}
function field(id: string, label: string, icon: string, input: HTMLInputElement, hint: () => Child[], want: number): { el: HTMLDivElement; f: Field } {
function field(id: string, label: string, icon: IconId, input: HTMLInputElement, hint: () => Child[], want: number): { el: HTMLDivElement; f: Field } {
const help = h('p', { id: `${id}-help`, class: 'field-help' }, hint())
input.id = id
input.setAttribute('aria-describedby', `${id}-help`)
@ -59,7 +66,7 @@ function field(id: string, label: string, icon: string, input: HTMLInputElement,
'div',
{ class: 'form-field' },
// The glyph is painted beside a spoken-only <label>, so the label's text stays exactly `label`.
h('span', { class: 'field-label', 'aria-hidden': 'true' }, icon),
h('span', { class: 'field-label', 'aria-hidden': 'true' }, iconInline(icon)),
h('label', { for: id, class: 'sr-only' }, label),
input,
help,
@ -92,7 +99,7 @@ export class SetupFormElement extends LiveElement {
const key = field(
'setup-key',
'Steam Web API key',
'🔑',
'setup.api-key',
h('input', { class: 'input mono', type: 'password', autocomplete: 'off', spellcheck: 'false', autofocus: true }),
KEY_HELP,
32,
@ -100,7 +107,7 @@ export class SetupFormElement extends LiveElement {
const id = field(
'setup-id',
'SteamID64',
'🆔',
'setup.steam-id',
h('input', { class: 'input mono input-num', inputmode: 'numeric', placeholder: ID_SHAPE }),
ID_HELP,
17,
@ -149,8 +156,8 @@ export class SetupFormElement extends LiveElement {
? [notice('warning', null, spoken('Not configured yet', 'Every other screen needs these two values first.'))]
: []),
)
// 🔒 + filled dots: a key is stored (typing replaces it); hollow dots: none yet.
this.keyField.input.placeholder = data?.has_api_key ? KEY_STORED : KEY_SHAPE
// Lock icon + filled dots: a key is stored (typing replaces it); hollow dots: none yet.
this.keyField.input.placeholder = data?.has_api_key ? keyStored() : KEY_SHAPE
this.keyField.input.dataset.stored = String(data?.has_api_key ?? false)
if (!this.idEdited) this.idField.input.value = data?.steam_id ?? ''
this.render()
@ -167,30 +174,30 @@ export class SetupFormElement extends LiveElement {
'success',
null,
spoken('Saved', 'Steam accepted the key.'),
h('a', { href: '/', class: 'btn btn-ghost btn-small', 'aria-label': 'Go to the dashboard' }, '🏠'),
h('a', { href: '/', class: 'btn btn-ghost btn-small', 'aria-label': 'Go to the dashboard' }, iconInline('nav.dashboard')),
),
]
: []),
)
this.failure.replaceChildren(...(this.save.error ? [errorNotice(this.save.error)] : []))
this.submit.disabled = this.save.pending
// ⏳ while Steam checks, ✔️ to save; the words are spoken only.
this.submit.replaceChildren(this.save.pending ? glyph('⏳', 'Checking with Steam…') : glyph('✔️', 'Save and verify'))
// The busy icon while Steam checks, the confirm icon to save; the words are spoken only.
this.submit.replaceChildren(this.save.pending ? glyph('state.wait', 'Checking with Steam…') : glyph('action.confirm', 'Save and verify'))
}
private mark(f: Field, problem: string | null): void {
const bad = this.touched && problem !== null
f.input.className = bad ? `${f.baseClass} input-bad` : f.baseClass
f.input.setAttribute('aria-invalid', String(bad))
// A bad value paints ⚠️ and how many characters it has of the `want` it needs.
const count = `⚠️ ${f.input.value.trim().length}/${f.want}`
// A bad value paints the warning icon and how many characters it has of the `want` it needs.
const count = `${f.input.value.trim().length}/${f.want}`
const state = bad ? `${problem}|${count}` : 'ok'
if (f.help.dataset.state === state) return
f.help.dataset.state = state
f.help.dataset.bad = String(bad)
f.help.className = bad ? 'field-help text-danger' : 'field-help'
f.help.replaceChildren()
append(f.help, bad ? [h('span', { 'aria-hidden': 'true', class: 'mono' }, count), h('span', { class: 'sr-only' }, problem)] : f.hint())
append(f.help, bad ? [h('span', { 'aria-hidden': 'true', class: 'mono' }, iconInline('state.warn'), ` ${count}`), h('span', { class: 'sr-only' }, problem)] : f.hint())
}
private async store(): Promise<void> {

View File

@ -2,6 +2,7 @@
// right now. Nothing shows until the status is known.
import { q } from '../api/queries'
import { iconInline } from '../icons/render'
import { define, h } from '../lib/dom'
import { LiveElement } from '../lib/element'
import { notice } from '../ui/build'
@ -17,11 +18,11 @@ export class StoreNoticeElement extends LiveElement {
this.replaceChildren()
return
}
// Textgate: 🛒 + lock state painted (tone is the 2nd channel), the sentence spoken.
// Textgate: the store + lock state icon painted (tone is the 2nd channel), the sentence spoken.
const [tone, icon, spoken] = data.store_blocked
? (['info', '🛒🔒', 'Store blocked. Unblocking takes a typed phrase and is capped at 30 minutes.'] as const)
: (['warning', '🛒🔓', 'Store unblocked. The store is open right now; it re-blocks automatically.'] as const)
const el = notice(tone, null, h('span', { 'aria-hidden': 'true' }, icon), h('span', { class: 'sr-only' }, spoken))
? (['info', 'store.blocked', 'Store blocked. Unblocking takes a typed phrase and is capped at 30 minutes.'] as const)
: (['warning', 'store.open', 'Store unblocked. The store is open right now; it re-blocks automatically.'] as const)
const el = notice(tone, null, h('span', { 'aria-hidden': 'true' }, iconInline(icon)), h('span', { class: 'sr-only' }, spoken))
el.dataset.blocked = String(data.store_blocked)
this.replaceChildren(el)
}

View File

@ -8,6 +8,8 @@ import { explain } from '../../api/errors'
import type { StateBackup } from '../../api/contract'
import type { Job } from '../../api/jobContract'
import { q } from '../../api/queries'
import type { IconId } from '../../icons/registry'
import { iconInline } from '../../icons/render'
import { phraseMatches } from '../../commands/catalog'
import '../../commands/commandButton'
import { PhraseField } from '../../commands/phraseField'
@ -24,8 +26,9 @@ import { bytes, dateTime } from '../../ui/format'
export const restorePhrase = (id: string): string => `restore backup ${id}`
/** Why a backup was taken, as a glyph (reason words spoken only). */
const REASON_ICON: Record<string, string> = { 'before reset': '♻️', nightly: '🌙' }
const reasonGlyph = (reason: string): HTMLSpanElement => glyph(REASON_ICON[reason] ?? '🗄️', reason)
const REASON_ICON: Readonly<Partial<Record<string, IconId>>> = { 'before reset': 'backup.reason.reset', nightly: 'backup.reason.nightly' }
const reasonIcon = (reason: string): IconId => REASON_ICON[reason] ?? 'backup.reason.other'
const reasonGlyph = (reason: string): HTMLSpanElement => glyph(reasonIcon(reason), reason)
/** One restore: phrase form, then the job it started. */
export class RestoreDialog {
@ -66,8 +69,8 @@ export class RestoreDialog {
'p',
{ class: 'm0 row' },
h('span', { class: 'sr-only' }, `Replaces the current state with the backup from ${dateTime(backup.created_at)} (${backup.reason}).`),
h('span', { 'aria-hidden': 'true', class: 'mono' }, `🗄️ ${backup.id} · ${dateTime(backup.created_at)}`),
h('span', { 'aria-hidden': 'true' }, REASON_ICON[backup.reason] ?? '🗄️'),
h('span', { 'aria-hidden': 'true', class: 'mono' }, iconInline('backup.item'), ` ${backup.id} · ${dateTime(backup.created_at)}`),
h('span', { 'aria-hidden': 'true' }, iconInline(reasonIcon(backup.reason))),
),
this.field.el,
this.failure,
@ -75,7 +78,7 @@ export class RestoreDialog {
'div',
{ class: 'actions' },
this.submit,
h('button', { type: 'button', class: 'btn btn-ghost', onclick: onClose }, glyph('✖️', 'Cancel')),
h('button', { type: 'button', class: 'btn btn-ghost', onclick: onClose }, glyph('action.cancel', 'Cancel')),
),
)
this.modal.render(form)
@ -88,7 +91,7 @@ export class RestoreDialog {
private sync(): void {
this.submit.disabled = !this.matches() || this.restore.pending
this.submit.replaceChildren(this.restore.pending ? glyph('⏳', 'Restoring…') : glyph('⏮️', 'Restore'))
this.submit.replaceChildren(this.restore.pending ? glyph('state.wait', 'Restoring…') : glyph('backup.restore', 'Restore'))
this.failure.replaceChildren(...(this.restore.error ? [errorNotice(this.restore.error)] : []))
}
@ -101,7 +104,7 @@ export class RestoreDialog {
'div',
{ class: 'stack' },
hx('job-progress', { 'job-id': out.value.id }),
h('div', { class: 'actions' }, h('button', { type: 'button', class: 'btn btn-ghost', onclick: onClose }, glyph('✖️', 'Close'))),
h('div', { class: 'actions' }, h('button', { type: 'button', class: 'btn btn-ghost', onclick: onClose }, glyph('action.cancel', 'Close'))),
),
)
this.modal.focusFirst()
@ -114,7 +117,7 @@ export class BackupsCardElement extends LiveElement {
private readonly root = card(
'State backups',
[h('p', { class: 'sr-only' }, 'Reset takes a timestamped backup first, so it can be undone here.'), this.status, this.list],
{ aside: hx('command-button', { name: 'reset', label: 'Reset all state…' }), icon: '🗄️' },
{ aside: hx('command-button', { name: 'reset', label: 'Reset all state…' }), icon: 'backup.item' },
)
private dialog: RestoreDialog | null = null
private shownKey = ''
@ -161,7 +164,7 @@ export class BackupsCardElement extends LiveElement {
this.open(b)
},
},
glyph('⏮️', 'Restore…'),
glyph('backup.restore', 'Restore…'),
),
),
),

View File

@ -5,6 +5,8 @@
// focus from a button or yanks the journal while it is being read.
import { q } from '../../api/queries'
import type { IconId } from '../../icons/registry'
import { iconInline } from '../../icons/render'
import { define, h } from '../../lib/dom'
import { LiveElement } from '../../lib/element'
import { runner } from '../../lib/runner'
@ -25,7 +27,11 @@ export function restartWaitMs(availableAt: string | null, now: number = Date.now
}
/** Daemon state: glyph painted, the state word spoken. */
const STATE_ICON: Record<DaemonState, string> = { running: '🟢', restarting: '🔄', unreachable: '🔴' }
const STATE_ICON = {
running: 'daemon.running',
restarting: 'daemon.restarting',
unreachable: 'daemon.unreachable',
} as const satisfies Record<DaemonState, IconId>
function unreachableNotice(): HTMLDivElement {
// Textgate: ⛔ + the command to run are painted; the explanation is spoken only.
@ -66,16 +72,16 @@ export class DaemonCardElement extends LiveElement {
runner.run('enforce', { demo: 1 })
},
},
glyph('🧪', 'Demo run (enforce --demo)…'),
glyph('daemon.demo_run', 'Demo run (enforce --demo)…'),
)
private readonly parts = [
this.alert,
this.factsSlot,
h('div', { class: 'actions' }, this.restart, this.demo),
h('h3', { class: 'h3' }, glyph('📜', 'Journal')),
h('h3', { class: 'h3' }, glyph('daemon.journal', 'Journal')),
this.journal,
]
private readonly root = card('Enforcer daemon', [this.status, this.body], { icon: '🛡️' })
private readonly root = card('Enforcer daemon', [this.status, this.body], { icon: 'daemon.heading' })
private shown = false
private canRestart = false
private unreachable = false
@ -104,19 +110,19 @@ export class DaemonCardElement extends LiveElement {
}
this.factsSlot.replaceChildren(
facts([
[glyph('📡', 'State'), h('span', { 'data-state': data.state }, glyph(STATE_ICON[data.state], data.state))],
[glyph('#️⃣', 'PID'), data.pid ?? '—'],
[glyph('⏱️', 'Up since'), data.started_at ? since(data.started_at) : '—'],
[glyph('daemon.state', 'State'), h('span', { 'data-state': data.state }, glyph(STATE_ICON[data.state], data.state))],
[glyph('daemon.pid', 'PID'), data.pid ?? '—'],
[glyph('daemon.up_since', 'Up since'), data.started_at ? since(data.started_at) : '—'],
]),
)
this.canRestart = waitMs === 0 && data.state === 'running'
this.restart.setAttribute('aria-disabled', String(!this.canRestart))
// Rate limited: ⏳ + the clock counting down; free: 🔄. Words spoken only.
// Rate limited: the busy icon + the clock counting down; free: the restart icon. Words spoken only.
const wait = clock(waitMs / 1000)
this.restart.replaceChildren(
waitMs > 0
? h('span', { 'aria-label': `Restart available in ${wait}` }, h('span', { 'aria-hidden': 'true' }, `⏳ ${wait}`))
: glyph('🔄', 'Restart daemon…'),
? h('span', { 'aria-label': `Restart available in ${wait}` }, h('span', { 'aria-hidden': 'true' }, iconInline('state.wait'), ` ${wait}`))
: glyph('daemon.restart', 'Restart daemon…'),
)
this.fillJournal(data.journal_tail)
}

View File

@ -0,0 +1,83 @@
// The system page paints every icon through the registry: the user's word
// shows right of the icon, a chosen alternative glyph replaces the default,
// and the spoken names stay as they were.
import { screen, waitFor } from '@testing-library/dom'
import { beforeEach, describe, expect, it } from 'vitest'
import type { DaemonStatus } from '../../api/contract'
import { makeSpec } from '../../test/fixtures'
import { installEventSource, mount, stubApi } from '../../test/harness'
import { useIcons } from '../../test/iconLedger'
import './backupsCard'
import './daemonCard'
import './serverCard'
import './setupCard'
const daemon = (over: Partial<DaemonStatus> = {}): DaemonStatus => ({
state: 'running',
started_at: '2026-10-10T10:00:00Z',
pid: 4242,
journal_tail: [],
restart_available_at: null,
...over,
})
const words = (root: Element) => [...root.querySelectorAll('.icon-word')].map((w) => w.textContent)
const marks = (root: Element) => [...root.querySelectorAll('[data-icon]')].map((m) => m.textContent)
beforeEach(installEventSource)
describe('system page icons', () => {
it('daemon card: state, pid and restart icons carry words and glyphs, names spoken', async () => {
useIcons({ 'daemon.running': { word: 'alive', glyph: '💚' }, 'daemon.pid': { word: 'process' }, 'daemon.restart': { word: 'restart' } })
stubApi({ 'GET /api/daemon': daemon() })
const el = mount('<daemon-card></daemon-card>')
await screen.findByText('4242')
expect(words(el)).toEqual(expect.arrayContaining(['Alive', 'Process', 'Restart']))
expect(marks(el)).toContain('💚')
expect(screen.getByText('PID')).toHaveClass('sr-only')
expect(screen.getByRole('button', { name: /Restart daemon/ })).toBeInTheDocument()
})
it('daemon card: the rate-limit countdown keeps the busy icon and its word', async () => {
useIcons({ 'state.wait': { word: 'busy' } })
const later = new Date(Date.now() + 90_000).toISOString()
stubApi({ 'GET /api/daemon': daemon({ restart_available_at: later }) })
const el = mount('<daemon-card></daemon-card>')
await waitFor(() => {
expect(words(el)).toEqual(['Busy'])
})
expect(screen.getByLabelText(/Restart available in/)).toBeInTheDocument()
})
it('server card: version, code state and restart carry the chosen icons', async () => {
useIcons({ 'server.version': { word: 'build' }, 'state.yes': { word: 'fresh' }, 'server.restart': { glyph: '🚀' } })
stubApi({ 'GET /api/server': { stale: false, started_at: '2026-10-10T10:00:00Z', version: '9.9.9' } })
const el = mount('<server-card></server-card>')
await screen.findByText('9.9.9')
expect(words(el)).toEqual(['Build', 'Fresh'])
expect(screen.getByRole('button', { name: 'Restart server' }).querySelector('[data-icon]')?.textContent).toBe('🚀')
expect(screen.getByText('current')).toHaveClass('sr-only')
})
it('backups card: reason, restore and cancel icons go through the registry', async () => {
useIcons({ 'backup.reason.reset': { word: 'wipe' }, 'backup.restore': { glyph: '⏪' }, 'action.cancel': { word: 'cancel' } })
stubApi({
'GET /api/backups': [{ id: '20261010-100000', created_at: '2026-10-10T10:00:00Z', reason: 'before reset', size_bytes: 2048 }],
'GET /api/commands': [makeSpec('reset')],
'GET /api/jobs': [],
})
const el = mount('<backups-card></backups-card>')
await screen.findByText('20261010-100000')
expect(words(el)).toEqual(['Wipe'])
expect(screen.getByRole('button', { name: 'Restore…' }).querySelector('[data-icon]')?.textContent).toBe('⏪')
})
it('setup card: key, stored and edit icons carry the words, sentences stay spoken', async () => {
useIcons({ 'setup.api-key': { word: 'key' }, 'setup.key-stored': { word: 'safe' },'syssetup.edit': { glyph: '📝' } })
stubApi({ 'GET /api/setup': { configured: true, has_api_key: true, steam_id: '7656119800000000' } })
const el = mount('<setup-card></setup-card>')
await screen.findByText('Stored (never shown)')
expect(words(el)).toEqual(['Key', 'Safe'])
expect(screen.getByRole('link', { name: 'Open setup' }).querySelector('[data-icon]')?.textContent).toBe('📝')
})
})

View File

@ -19,7 +19,7 @@ export class ServerCardElement extends LiveElement {
void this.restart.action.run()
},
})
private readonly root = card('Web server', [this.info, this.failure, h('div', { class: 'actions' }, this.button)], { icon: '🌐' })
private readonly root = card('Web server', [this.info, this.failure, h('div', { class: 'actions' }, this.button)], { icon: 'server.heading' })
private readonly restart = new ServerRestart(() => {
this.update()
})
@ -41,9 +41,9 @@ export class ServerCardElement extends LiveElement {
...(data
? [
facts([
[glyph('🏷️', 'Version'), h('span', { class: 'mono' }, data.version)],
[glyph('🕒', 'Started'), h('span', { 'aria-label': `${dateTime(data.started_at)} (${ago(data.started_at)})` }, dateTime(data.started_at))],
[glyph('💾', 'Code'), data.stale ? glyph('⚠️', 'stale') : glyph('✅', 'current')],
[glyph('server.version', 'Version'), h('span', { class: 'mono' }, data.version)],
[glyph('server.started', 'Started'), h('span', { 'aria-label': `${dateTime(data.started_at)} (${ago(data.started_at)})` }, dateTime(data.started_at))],
[glyph('server.code', 'Code'), data.stale ? glyph('state.warn', 'stale') : glyph('state.yes', 'current')],
]),
]
: []),
@ -52,7 +52,7 @@ export class ServerCardElement extends LiveElement {
this.failure.replaceChildren(...(action.error ? [errorNotice(action.error)] : []))
this.button.disabled = restarting || action.pending
this.button.dataset.restarting = String(restarting)
this.button.replaceChildren(restarting ? glyph('⏳', 'Restarting… the page reloads when it is back') : glyph('🔄', 'Restart server'))
this.button.replaceChildren(restarting ? glyph('state.wait', 'Restarting… the page reloads when it is back') : glyph('server.restart', 'Restart server'))
}
}

View File

@ -18,11 +18,11 @@ export class SetupCardElement extends LiveElement {
card(
'Setup',
facts([
[glyph('⚙️', 'Configured'), data ? (data.configured ? glyph('✅', 'Yes') : glyph('❌', 'No')) : '…'],
[glyph('🔑', 'Steam API key'), data ? (data.has_api_key ? glyph('🔒', 'Stored (never shown)') : glyph('❌', 'Missing')) : '…'],
[glyph('🆔', 'Steam ID'), h('span', { class: 'mono' }, data?.steam_id ?? '—')],
[glyph('syssetup.configured', 'Configured'), data ? (data.configured ? glyph('state.yes', 'Yes') : glyph('state.no', 'No')) : '…'],
[glyph('setup.api-key', 'Steam API key'), data ? (data.has_api_key ? glyph('setup.key-stored','Stored (never shown)') : glyph('state.no', 'Missing')) : '…'],
[glyph('setup.steam-id', 'Steam ID'), h('span', { class: 'mono' }, data?.steam_id ?? '—')],
]),
{ aside: link(pageHref('/setup'), glyph('✏️', 'Open setup')), icon: '🔧' },
{ aside: link(pageHref('/setup'), glyph('syssetup.edit', 'Open setup')), icon: 'cmd.setup' },
),
)
}

View File

@ -0,0 +1,53 @@
// Pass-2 icon wiring for the health badges and the stale banner: subject and
// state are separate ids, the user's words show right of them, the spoken
// text (pill text, aria-label) stays.
import { describe, expect, it, vi } from 'vitest'
import { button } from '../test/events'
import { mount, stubApi } from '../test/harness'
import { useIcons } from '../test/iconLedger'
import { painted } from '../test/painted'
import { visibleWords } from '../test/visibleWords'
import './health'
const server = (over = {}) => ({ stale: false, started_at: '2026-10-10T10:00:00Z', version: '1.2.3', ...over })
const daemon = (state: string) => ({ state, started_at: null, pid: null, journal_tail: [], restart_available_at: null })
describe('health badges by id', () => {
it('draws the subject and the state with their words and glyphs', async () => {
useIcons({
'server.heading': { word: 'web' },
'health.ok': { word: 'fine', glyph: '🟢' },
'daemon.heading': { word: 'guard' },
'health.warn': { word: 'shaky' },
})
stubApi({ 'GET /api/server': server(), 'GET /api/daemon': daemon('restarting') })
const el = mount('<health-badges></health-badges>')
await vi.waitFor(() => { expect(el.querySelector('[data-state="Daemon restarting"]')).not.toBeNull() })
const pills = [...el.querySelectorAll<HTMLElement>('.pill')]
expect(painted(pills[0])).toBe('🌐Web🟢Fine')
expect(painted(pills[1])).toBe('🛡️Guard⚠️Shaky')
expect(pills[0]?.querySelector('.sr-only')?.textContent).toContain('Server ok')
expect(pills[1]).toHaveAttribute('data-state', 'Daemon restarting')
expect(visibleWords(el)).toEqual([])
})
it('keeps the plain glyphs without words, the unknown state as the ellipsis', () => {
stubApi({ 'GET /api/server': () => new Promise(() => undefined), 'GET /api/daemon': () => new Promise(() => undefined) })
const el = mount('<health-badges></health-badges>')
expect(painted(el.querySelector('[data-state="Daemon …"]'))).toBe('🛡️…')
})
})
describe('stale banner by id', () => {
it('draws the stale mark and the restart icon from the ledger', async () => {
useIcons({ 'health.stale': { word: 'old' }, 'server.restart': { word: 'reload', glyph: '♻️' } })
stubApi({ 'GET /api/server': server({ stale: true }) })
const el = mount('<stale-banner></stale-banner>')
await vi.waitFor(() => { expect(el).toHaveTextContent('The web server is running stale code.') })
const banner = el.firstElementChild
expect(banner?.querySelector('.glyph [data-icon="health.stale"]')?.textContent).toBe('⚠️🌐')
expect(banner?.querySelector('.glyph .icon-word')?.textContent).toBe('Old')
expect(button(el, 'Restart server').textContent).toBe('♻️Reload')
})
})

View File

@ -2,20 +2,22 @@
// every page while the running server is older than the code on disk).
import { q } from '../api/queries'
import type { IconId } from '../icons/registry'
import { iconInline } from '../icons/render'
import { define, h } from '../lib/dom'
import { LiveElement } from '../lib/element'
import { errorNotice, glyph } from '../ui/build'
import { ServerRestart } from './serverRestart'
const DAEMON_TONE = { running: 'success', restarting: 'warning', unreachable: 'danger' } as const
const STATE_GLYPH: Record<string, string> = { success: '✅', warning: '⚠️', danger: '⛔', neutral: '…' }
const STATE_ICON = { success: 'health.ok', warning: 'health.warn', danger: 'health.bad', neutral: 'health.unknown' } as const satisfies Record<string, IconId>
/** A health pill: glyphs painted, `text` (+ `extra`) spoken. `data-state` holds the words for tests. */
function badge(tone: string, icons: string, text: string, extra = ''): HTMLSpanElement {
/** A health pill: the subject and state icons painted, `text` (+ `extra`) spoken. `data-state` holds the words for tests. */
function badge(tone: keyof typeof STATE_ICON, subject: IconId, text: string, extra = ''): HTMLSpanElement {
return h(
'span',
{ class: `pill pill-${tone}`, 'data-state': text },
h('span', { 'aria-hidden': 'true' }, icons),
h('span', { class: 'has-word', 'aria-hidden': 'true' }, iconInline(subject), iconInline(STATE_ICON[tone])),
h('span', { class: 'sr-only' }, text + extra),
)
}
@ -31,15 +33,15 @@ export class HealthBadgesElement extends LiveElement {
const d = q.daemon.state.data?.state
const serverTone = server.error ? 'danger' : server.data?.stale ? 'warning' : 'success'
const serverText = server.error ? 'Server down' : server.data?.stale ? 'Server stale' : 'Server ok'
// Textgate: 🌐 server / 🛡️ daemon + a state glyph, on the tone colour; the
// words (and the version, formerly a tooltip) are spoken only.
// Textgate: the server / daemon icon + a state icon, on the tone colour;
// the words (and the version, formerly a tooltip) are spoken only.
const version = server.data ? ` v${server.data.version}` : ''
this.replaceChildren(
h(
'div',
{ class: 'health', 'aria-label': 'Health' },
badge(serverTone, `🌐${STATE_GLYPH[serverTone]}`, serverText, version),
badge(d ? DAEMON_TONE[d] : 'neutral', `🛡️${STATE_GLYPH[d ? DAEMON_TONE[d] : 'neutral']}`, `Daemon ${d ?? '…'}`),
badge(serverTone, 'server.heading', serverText, version),
badge(d ? DAEMON_TONE[d] : 'neutral', 'daemon.heading',`Daemon ${d ?? '…'}`),
),
)
}
@ -67,7 +69,7 @@ export class StaleBannerElement extends LiveElement {
h(
'div',
{ class: 'banner banner-warning', role: 'status' },
glyph('⚠️🌐', 'The web server is running stale code. Restart it to pick up the new version.'),
glyph('health.stale', 'The web server is running stale code. Restart it to pick up the new version.'),
h(
'button',
{
@ -77,7 +79,7 @@ export class StaleBannerElement extends LiveElement {
onclick: () => void action.run(),
'aria-label': this.restart.restarting ? 'Restarting…' : 'Restart server',
},
h('span', { 'aria-hidden': 'true' }, this.restart.restarting ? '⏳' : '🔄'),
iconInline(this.restart.restarting ? 'state.wait' : 'server.restart'),
),
action.error ? errorNotice(action.error) : null,
),

View File

@ -30,7 +30,7 @@ export function jobChip(job: Job): HTMLAnchorElement {
'span',
{ class: 'jobchip-label' },
glyph(commandIcon(job.command), label),
h('span', { class: 'jobchip-sub' }, waiting ? glyph('✋', 'needs input') : p?.total ? `${p.step}/${p.total}` : '…'),
h('span', { class: 'jobchip-sub' }, waiting ? glyph('jobchip.needs-input', 'needs input') : p?.total ? `${p.step}/${p.total}` : '…'),
),
progressBar(fraction, label, waiting ? 'warning' : 'accent', true),
)

View File

@ -27,10 +27,9 @@ export interface PalettePage {
to: string
label: string
blurb: string
/** A raw glyph: these pages are not in the icon registry yet. */
icon: string
icon: IconId
}
export const PALETTE_PAGES: PalettePage[] = [
{ to: '/words', label: 'Icon words', blurb: 'Pick the word shown next to each icon', icon: '🏷️' },
{ to: '/words', label: 'Icon words', blurb: 'Pick the word shown next to each icon', icon: 'words.page' },
]

View File

@ -75,22 +75,13 @@ describe('small builders', () => {
expect(el.querySelector('.empty-icon')?.textContent).toBe('📭')
})
it('pill has an icon for known tones', () => {
const el = pill('danger', 'x')
it('pill paints the registered icon it is given and speaks its text', () => {
const el = pill('danger', 'odd one', 'notice.danger')
expect(el.className).toBe('pill pill-danger')
expect(el.querySelector('.pill-icon')).not.toBeNull()
})
it('pill paints a bullet for an unknown tone and speaks its text', () => {
const el = pill('mystery', 'odd one')
expect(el.querySelector('.pill-icon')?.textContent).toBe('•')
expect(el.querySelector('.pill-icon')?.textContent).toBe('⛔')
expect(el.querySelector('.sr-only')?.textContent).toBe('odd one')
})
it('pill paints the icon it is given over the tone glyph', () => {
expect(pill('danger', 'x', '🔥').querySelector('.pill-icon')?.textContent).toBe('🔥')
})
it('link is an anchor', () => {
const a = link('/library/', 'Open')
expect(a.getAttribute('href')).toBe('/library/')

View File

@ -3,8 +3,8 @@
// for content a custom element renders from live data.
import { explain } from '../api/errors'
import { isIconId, type IconId } from '../icons/registry'
import { iconFor, iconMark, iconWord } from '../icons/render'
import type { IconId } from '../icons/registry'
import { iconFor, iconInline, iconMark, iconWord } from '../icons/render'
import { h, type Child } from '../lib/dom'
export type Tone = 'info' | 'success' | 'warning' | 'danger'
@ -47,14 +47,14 @@ export function errorNotice(error: unknown, ...children: Child[]): HTMLDivElemen
}
export function copyButton(text: string): HTMLButtonElement {
const btn = h('button', { type: 'button', class: 'btn btn-ghost btn-small', 'aria-label': 'Copy command' }, '📋')
const btn = h('button', { type: 'button', class: 'btn btn-ghost btn-small', 'aria-label': 'Copy command' }, iconInline('copy.command'))
btn.addEventListener('click', () => {
if (!('clipboard' in navigator)) return
void navigator.clipboard.writeText(text).then(() => {
btn.textContent = '✅'
btn.replaceChildren(iconInline('copy.done'))
btn.setAttribute('aria-label', 'Copied')
setTimeout(() => {
btn.textContent = '📋'
btn.replaceChildren(iconInline('copy.command'))
btn.setAttribute('aria-label', 'Copy command')
}, 2000)
})
@ -71,12 +71,12 @@ export function loading(what: string): HTMLParagraphElement {
return h('p', { class: 'loading', role: 'status' }, h('span', { class: 'spinner', 'aria-hidden': 'true' }), h('span', { class: 'sr-only' }, `Loading ${what}`))
}
/** Empty-state marker: 📭 painted, the caller's sentence spoken only. */
/** Empty-state marker: the empty icon painted, the caller's sentence spoken only. */
export function empty(label: string): HTMLParagraphElement {
return h(
'p',
{ class: 'empty', 'aria-label': label },
h('span', { class: 'empty-icon', 'aria-hidden': 'true' }, '📭'),
iconInline('state.empty', 'empty-icon'),
h('span', { class: 'sr-only' }, label),
)
}
@ -84,27 +84,21 @@ export function empty(label: string): HTMLParagraphElement {
export interface CardOptions {
aside?: Child
className?: string
icon?: string
icon?: IconId
}
/**
* A painted glyph whose meaning is spoken (.sr-only). With a registered id the
* glyph comes from the registry (the user's alternative applied) and his word,
* if any, is drawn right of it; `spoken` then defaults to the registry name.
* A raw glyph (`glyph('🧭', 'navigate')`) paints just that, as before.
* A painted glyph whose meaning is spoken (.sr-only). The glyph comes from the
* registry (the user's alternative applied) and his word, if any, is drawn
* right of it; `spoken` defaults to the registry name.
*/
export function glyph(id: IconId, spoken?: string, className?: string): HTMLSpanElement
export function glyph(icon: string, spoken: string, className?: string): HTMLSpanElement
export function glyph(icon: string, spoken?: string, className = 'glyph'): HTMLSpanElement {
if (!isIconId(icon)) {
return h('span', { class: className }, h('span', { 'aria-hidden': 'true' }, icon), h('span', { class: 'sr-only' }, spoken))
}
const { glyph: painted, spoken: name } = iconFor(icon)
const word = iconWord(icon)
export function glyph(id: IconId, spoken?: string, className = 'glyph'): HTMLSpanElement {
const { glyph: painted, spoken: name } = iconFor(id)
const word = iconWord(id)
return h(
'span',
{ class: word ? `${className} has-word` : className },
h('span', { 'aria-hidden': 'true', 'data-icon': icon }, painted),
h('span', { 'aria-hidden': 'true', 'data-icon': id }, painted),
word,
h('span', { class: 'sr-only' }, spoken ?? name),
)
@ -126,23 +120,13 @@ export function facts(rows: readonly (readonly [Child, Child])[]): HTMLDListElem
)
}
const TONE_PILL_ICON: Record<string, string> = {
info: 'ℹ️',
success: '✅',
warning: '⚠️',
danger: '⛔',
kept: '📌',
excluded: '🚫',
idle: '⏸️',
running: '▶️',
}
/** A tone badge: `icon` (else the tone's glyph) painted, `text` spoken only. */
export function pill(tone: string, text: string, icon = TONE_PILL_ICON[tone] ?? '•'): HTMLSpanElement {
/** A tone badge: the registered `icon` (and its word) painted, `text` spoken only. */
export function pill(tone: string, text: string, icon: IconId): HTMLSpanElement {
return h(
'span',
{ class: `pill pill-${tone}` },
h('span', { class: 'pill-icon', 'aria-hidden': 'true' }, icon),
iconMark(icon, 'pill-icon'),
iconWord(icon),
h('span', { class: 'sr-only' }, text),
)
}

View File

@ -0,0 +1,24 @@
// The dialog's close button is a registered icon: his word beside it, his
// glyph in place of the default, the aria-label stays "Close".
import { describe, expect, it, vi } from 'vitest'
import { useIcons } from '../test/iconLedger'
import { Modal } from './dialog'
describe('Modal close button by id', () => {
it('paints the default cross, spoken name Close', () => {
const modal = new Modal({ title: 'Hello', onClose: vi.fn() })
const close = modal.el.querySelector('.dialog-close')
expect(close?.textContent).toBe('×')
expect(close).toHaveAttribute('aria-label', 'Close')
})
it('paints the user word right of his chosen glyph', () => {
useIcons({ 'dialog.close': { word: 'exit', glyph: '❌' } })
const modal = new Modal({ title: 'Hello', onClose: vi.fn() })
const close = modal.el.querySelector('.dialog-close')
expect(close?.textContent).toBe('❌Exit')
expect(close?.querySelector('.icon-word')).toHaveAttribute('data-icon-word', 'dialog.close')
expect(close).toHaveAttribute('aria-label', 'Close')
})
})

View File

@ -2,6 +2,7 @@
// inert background and Escape (routed through `onClose` so the owner decides
// what closing means). Focus returns to the opener when it closes.
import { iconInline } from '../icons/render'
import { append, h, type Child } from '../lib/dom'
export interface ModalOptions {
@ -23,7 +24,7 @@ export class Modal {
const close = h(
'button',
{ type: 'button', class: 'btn btn-ghost btn-icon dialog-close', 'aria-label': 'Close', onclick: onClose },
h('span', { 'aria-hidden': 'true' }, '×'),
iconInline('dialog.close'),
)
this.head = h('header', { class: 'dialog-head' }, this.heading, close)
this.body = h('div', { class: 'dialog-body' }, this.head)

View File

@ -1,5 +1,81 @@
{
"icons": {
"action.cancel": {
"glyph": null,
"word": "cancel"
},
"action.confirm": {
"glyph": null,
"word": "confirm"
},
"action.open": {
"glyph": "🔗",
"word": "open"
},
"assigned.game": {
"glyph": null,
"word": "assigned"
},
"backlog.any": {
"glyph": null,
"word": "any"
},
"backlog.cli": {
"glyph": null,
"word": "cli"
},
"backlog.filters": {
"glyph": null,
"word": "filters"
},
"backlog.in-scope": {
"glyph": null,
"word": "scope"
},
"backlog.sort-asc": {
"glyph": null,
"word": "ascending"
},
"backlog.sort-desc": {
"glyph": null,
"word": "descending"
},
"backup.item": {
"glyph": null,
"word": "backup"
},
"backup.reason.nightly": {
"glyph": null,
"word": "nightly"
},
"backup.reason.other": {
"glyph": null,
"word": "other"
},
"backup.reason.reset": {
"glyph": null,
"word": "reset"
},
"backup.restore": {
"glyph": null,
"word": "restore"
},
"basis.leisure": {
"glyph": null,
"word": "leisure"
},
"basis.pace": {
"glyph": null,
"word": "pace"
},
"basis.rush": {
"glyph": null,
"word": "rush"
},
"basis.worst": {
"glyph": null,
"word": "worst"
},
"cmd.abandon-pick": {
"glyph": null,
"word": "abandon"
@ -104,6 +180,342 @@
"glyph": null,
"word": "remove"
},
"cmdflag.cancellable": {
"glyph": null,
"word": "stoppable"
},
"cmdflag.countdown": {
"glyph": null,
"word": "countdown"
},
"cmdflag.mutating": {
"glyph": null,
"word": "changes"
},
"cmdflag.readonly": {
"glyph": null,
"word": "readonly"
},
"cmdflag.root": {
"glyph": null,
"word": "root"
},
"cmdpal.go": {
"glyph": null,
"word": "navigate"
},
"cmdpal.open": {
"glyph": null,
"word": "page"
},
"cmdpal.run-phrase": {
"glyph": null,
"word": "confirm"
},
"cmdpal.search": {
"glyph": null,
"word": "search"
},
"copy.command": {
"glyph": null,
"word": "copy"
},
"copy.done": {
"glyph": null,
"word": "done"
},
"daemon.demo_run": {
"glyph": null,
"word": "demo"
},
"daemon.heading": {
"glyph": null,
"word": "daemon"
},
"daemon.journal": {
"glyph": null,
"word": "journal"
},
"daemon.pid": {
"glyph": null,
"word": "process"
},
"daemon.restart": {
"glyph": null,
"word": "restart"
},
"daemon.restarting": {
"glyph": null,
"word": "restarting"
},
"daemon.running": {
"glyph": null,
"word": "running"
},
"daemon.state": {
"glyph": null,
"word": "state"
},
"daemon.unreachable": {
"glyph": null,
"word": "unreachable"
},
"daemon.up_since": {
"glyph": null,
"word": "uptime"
},
"dash.ago": {
"glyph": null,
"word": "ago"
},
"dash.billing": {
"glyph": null,
"word": "playing"
},
"dash.block-left": {
"glyph": null,
"word": "left"
},
"dash.blocked-today": {
"glyph": null,
"word": "blocked"
},
"dash.budget": {
"glyph": null,
"word": "budget"
},
"dash.elapsed": {
"glyph": null,
"word": "elapsed"
},
"dash.fast-failed": {
"glyph": null,
"word": "failed"
},
"dash.fast-install": {
"glyph": null,
"word": "fast"
},
"dash.finished": {
"glyph": null,
"word": "finished"
},
"dash.games": {
"glyph": null,
"word": "games"
},
"dash.installed": {
"glyph": null,
"word": "installed"
},
"dash.not-billing": {
"glyph": null,
"word": "idle"
},
"dash.outlook": {
"glyph": null,
"word": "backlog"
},
"dash.recent-jobs": {
"glyph": null,
"word": "jobs"
},
"dash.steam-took-over": {
"glyph": null,
"word": "fallback"
},
"dash.store": {
"glyph": null,
"word": "store"
},
"dash.store-blocked": {
"glyph": null,
"word": "blocked"
},
"dash.store-open": {
"glyph": null,
"word": "open"
},
"dash.total-block": {
"glyph": null,
"word": "block"
},
"dialog.close": {
"glyph": null,
"word": "close"
},
"filter.advanced": {
"glyph": null,
"word": "advanced"
},
"filter.basis": {
"glyph": null,
"word": "basis"
},
"filter.clear-date": {
"glyph": null,
"word": "clear"
},
"filter.daily": {
"glyph": null,
"word": "daily"
},
"filter.fallback": {
"glyph": null,
"word": "guess"
},
"filter.max-time": {
"glyph": null,
"word": "cap"
},
"filter.min-confidence": {
"glyph": null,
"word": "confidence"
},
"filter.min-polled": {
"glyph": null,
"word": "polled"
},
"filter.min-tier": {
"glyph": null,
"word": "minimum"
},
"filter.no-cap": {
"glyph": null,
"word": "unlimited"
},
"filter.proton-missing": {
"glyph": null,
"word": "unrated"
},
"filter.reset": {
"glyph": null,
"word": "reset"
},
"filter.started": {
"glyph": null,
"word": "started"
},
"filter.target-date": {
"glyph": null,
"word": "deadline"
},
"filter.untouched": {
"glyph": null,
"word": "untouched"
},
"gaming.billed_last": {
"glyph": null,
"word": "previous"
},
"gaming.billing_to": {
"glyph": null,
"word": "charging"
},
"gaming.budget": {
"glyph": null,
"word": "budget"
},
"gaming.by_game": {
"glyph": null,
"word": "games"
},
"gaming.cutoff.masked": {
"glyph": null,
"word": "cutoff"
},
"gaming.cutoff.unmasked": {
"glyph": null,
"word": "unmasked"
},
"gaming.day": {
"glyph": null,
"word": "date"
},
"gaming.day_start": {
"glyph": null,
"word": "sunrise"
},
"gaming.demo": {
"glyph": null,
"word": "demo"
},
"gaming.enforcement": {
"glyph": null,
"word": "enforcement"
},
"gaming.history": {
"glyph": null,
"word": "history"
},
"gaming.launcher": {
"glyph": null,
"word": "launcher"
},
"gaming.masked": {
"glyph": null,
"word": "masked"
},
"gaming.mode": {
"glyph": null,
"word": "mode"
},
"gaming.production": {
"glyph": null,
"word": "production"
},
"gaming.qualifying": {
"glyph": null,
"word": "processes"
},
"gaming.right_now": {
"glyph": null,
"word": "live"
},
"gaming.rules": {
"glyph": null,
"word": "rules"
},
"gaming.series.other": {
"glyph": null,
"word": "other"
},
"gaming.series.unattributed": {
"glyph": null,
"word": "unattributed"
},
"gaming.today": {
"glyph": null,
"word": "today"
},
"gaming.warn.none": {
"glyph": null,
"word": "silent"
},
"gaming.warning": {
"glyph": null,
"word": "warning"
},
"health.bad": {
"glyph": null,
"word": "down"
},
"health.ok": {
"glyph": null,
"word": "healthy"
},
"health.stale": {
"glyph": null,
"word": "stale"
},
"health.unknown": {
"glyph": null,
"word": "unknown"
},
"health.warn": {
"glyph": null,
"word": "degraded"
},
"job.state.cancelled": {
"glyph": null,
"word": "stopped"
@ -128,6 +540,146 @@
"glyph": null,
"word": "question"
},
"jobchip.needs-input": {
"glyph": null,
"word": "answer"
},
"jobs.all": {
"glyph": null,
"word": "all"
},
"jobs.cancel": {
"glyph": null,
"word": "stop"
},
"jobs.command": {
"glyph": null,
"word": "command"
},
"jobs.job": {
"glyph": null,
"word": "job"
},
"jobs.log": {
"glyph": null,
"word": "log"
},
"jobs.not-found": {
"glyph": null,
"word": "missing"
},
"jobs.started": {
"glyph": null,
"word": "started"
},
"jobs.state": {
"glyph": null,
"word": "state"
},
"jobs.took": {
"glyph": null,
"word": "took"
},
"jobs.waiting": {
"glyph": null,
"word": "waiting"
},
"keep.excluded": {
"glyph": null,
"word": "excluded"
},
"keep.kept": {
"glyph": null,
"word": "kept"
},
"lib.completion": {
"glyph": null,
"word": "completion"
},
"lib.count": {
"glyph": null,
"word": "games"
},
"lib.hide-completed": {
"glyph": null,
"word": "hide"
},
"lib.hltb": {
"glyph": null,
"word": "hltb"
},
"lib.name": {
"glyph": null,
"word": "name"
},
"lib.pickable": {
"glyph": null,
"word": "pickable"
},
"lib.played": {
"glyph": null,
"word": "played"
},
"lib.recent": {
"glyph": null,
"word": "recent"
},
"lib.relevance": {
"glyph": null,
"word": "relevance"
},
"lib.search": {
"glyph": null,
"word": "search"
},
"lib.sort": {
"glyph": null,
"word": "sort"
},
"lib.why.blocked": {
"glyph": null,
"word": "blocked"
},
"lib.why.complete": {
"glyph": null,
"word": "complete"
},
"lib.why.noach": {
"glyph": null,
"word": "none"
},
"lib.why.skipped": {
"glyph": null,
"word": "skipped"
},
"libpage.all": {
"glyph": null,
"word": "all"
},
"libpage.app-id": {
"glyph": null,
"word": "number"
},
"libpage.candidate": {
"glyph": null,
"word": "removable"
},
"libpage.game": {
"glyph": null,
"word": "game"
},
"libpage.protected": {
"glyph": null,
"word": "protected"
},
"libpage.role": {
"glyph": null,
"word": "role"
},
"libpage.size": {
"glyph": null,
"word": "size"
},
"nav.backlog": {
"glyph": null,
"word": "backlog"
@ -179,6 +731,326 @@
"palette.open": {
"glyph": null,
"word": "search"
},
"params.app_id": {
"glyph": null,
"word": "game"
},
"params.backup_id": {
"glyph": null,
"word": "backup"
},
"params.days": {
"glyph": null,
"word": "days"
},
"params.demo": {
"glyph": null,
"word": "demo"
},
"params.minutes": {
"glyph": null,
"word": "minutes"
},
"params.other": {
"glyph": null,
"word": "field"
},
"params.reason": {
"glyph": null,
"word": "reason"
},
"params.replace": {
"glyph": null,
"word": "replace"
},
"pending.beat": {
"glyph": null,
"word": "heartbeat"
},
"pending.beat-lost": {
"glyph": null,
"word": "failing"
},
"pending.leave": {
"glyph": null,
"word": "leaving"
},
"pending.rearm": {
"glyph": null,
"word": "rearm"
},
"phrase.field": {
"glyph": null,
"word": "type"
},
"picks.age": {
"glyph": null,
"word": "picked"
},
"picks.kept": {
"glyph": null,
"word": "kept"
},
"picks.manual": {
"glyph": null,
"word": "manual"
},
"planner.candidates": {
"glyph": null,
"word": "candidates"
},
"planner.completion": {
"glyph": null,
"word": "completion"
},
"planner.completions": {
"glyph": null,
"word": "completions"
},
"planner.game": {
"glyph": null,
"word": "game"
},
"planner.keep": {
"glyph": null,
"word": "keep"
},
"planner.no-data": {
"glyph": null,
"word": "blank"
},
"planner.playing": {
"glyph": null,
"word": "playing"
},
"planner.playtime": {
"glyph": null,
"word": "playtime"
},
"planner.proton": {
"glyph": null,
"word": "proton"
},
"planner.since": {
"glyph": null,
"word": "since"
},
"prompt.answer": {
"glyph": null,
"word": "send"
},
"prompt.back": {
"glyph": null,
"word": "back"
},
"prompt.games": {
"glyph": null,
"word": "choices"
},
"prompt.no": {
"glyph": null,
"word": "no"
},
"prompt.own-game": {
"glyph": null,
"word": "own"
},
"prompt.pick": {
"glyph": null,
"word": "pick"
},
"prompt.question": {
"glyph": null,
"word": "question"
},
"prompt.yes": {
"glyph": null,
"word": "yes"
},
"runner.arm": {
"glyph": null,
"word": "arm"
},
"runner.fill": {
"glyph": null,
"word": "fill"
},
"runner.run": {
"glyph": null,
"word": "run"
},
"runner.terminal": {
"glyph": null,
"word": "terminal"
},
"server.code": {
"glyph": null,
"word": "code"
},
"server.heading": {
"glyph": null,
"word": "server"
},
"server.restart": {
"glyph": null,
"word": "restart"
},
"server.started": {
"glyph": null,
"word": "started"
},
"server.version": {
"glyph": null,
"word": "version"
},
"setup.api-key": {
"glyph": null,
"word": "key"
},
"setup.help": {
"glyph": null,
"word": "link"
},
"setup.key-stored": {
"glyph": null,
"word": "stored"
},
"setup.steam-id": {
"glyph": null,
"word": "id"
},
"state.empty": {
"glyph": null,
"word": "empty"
},
"state.locked": {
"glyph": null,
"word": "locked"
},
"state.no": {
"glyph": null,
"word": "no"
},
"state.off": {
"glyph": null,
"word": "off"
},
"state.unknown": {
"glyph": null,
"word": "unknown"
},
"state.unlocked": {
"glyph": null,
"word": "unlocked"
},
"state.wait": {
"glyph": null,
"word": "busy"
},
"state.warn": {
"glyph": null,
"word": "attention"
},
"state.yes": {
"glyph": null,
"word": "yes"
},
"stats.card": {
"glyph": null,
"word": "estimates"
},
"store.blocked": {
"glyph": null,
"word": "blocked"
},
"store.open": {
"glyph": null,
"word": "open"
},
"style.between": {
"glyph": null,
"word": "between"
},
"style.fast": {
"glyph": null,
"word": "fast"
},
"style.slow": {
"glyph": null,
"word": "slow"
},
"summary.estimated-total": {
"glyph": null,
"word": "total"
},
"summary.games-per-day": {
"glyph": null,
"word": "rate"
},
"summary.interpolation": {
"glyph": null,
"word": "blend"
},
"summary.match": {
"glyph": null,
"word": "match"
},
"summary.need": {
"glyph": null,
"word": "needs"
},
"summary.no-start": {
"glyph": null,
"word": "unset"
},
"summary.style": {
"glyph": null,
"word": "style"
},
"summary.to-finish": {
"glyph": null,
"word": "remaining"
},
"syssetup.configured": {
"glyph": null,
"word": "configured"
},
"syssetup.edit": {
"glyph": null,
"word": "edit"
},
"tier.borked": {
"glyph": null,
"word": "borked"
},
"tier.bronze": {
"glyph": null,
"word": "bronze"
},
"tier.gold": {
"glyph": null,
"word": "gold"
},
"tier.native": {
"glyph": null,
"word": "native"
},
"tier.pending": {
"glyph": null,
"word": "pending"
},
"tier.platinum": {
"glyph": null,
"word": "platinum"
},
"tier.silver": {
"glyph": null,
"word": "silver"
},
"words.page": {
"glyph": null,
"word": "words"
}
},
"version": 1