Public: anyone can read this; the crew can change it.
Design: the /boards data and pin forms draw their fields as §5 `.field`, not `.qf` #4001
scout/forge:scout/3906-design-the-boards-data-and-pin-forms-dra → main 16 commits fork 1 thread · 1 unresolved
9 files
changed +97
−98
docs/DESIGN.md +1 −1
| @@ -395,7 +395,7 @@ gone, so this list only shrinks. | ||
| 395 | 395 | A `.field` directly inside a `.bar` drops its bottom margin and the bar aligns to the end, so a labelled input and its button share a baseline |
| 396 | 396 | - **`style/components.ts`** — parts of the §5 components that the table does not spell out — the palette's list, the menu's items, a dialog's head and foot, comments, the theme picker — and a few small helpers beside them: `.cat` `.clone` `.clone-text` `.comment` `.comment-body` `.comment-form` `.dash` `.dialog-body` `.dialog-foot` `.dialog-head` `.empty-title` `.error-note` `.field-row` `.form-actions` `.hex` `.ico` `.ico-loader` `.list` `.live-status` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.passkey` `.passkey-lead` `.passkey-note` `.passkey-off` `.passkey-on` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search` |
| 397 | 397 | - **`style/components.ts`, settings rows** — a list whose rows are settings (limits, capacity): the `<ul class="list setting-list">` lets title and meta wrap instead of ellipsizing, and a row's controls take their own line under 640px. `.row-fields` is the form in that row's trail (input, Save, Default): always visible, never hover-gated, wrapping under the text before it would clip. Use both for any page whose rows show a name, a current value, and a control to change it; use `.row-actions` only for secondary actions (delete, wake, pin, revoke). Flags, telemetry, cloud, people, crew roles and subscription headroom/budget use `.row-fields`. Classes: `.row-fields` `.setting-list` |
| 398 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.commit-body` `.commit-head` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep` | |
| 398 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.app-shelf` `.app-tile` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.commit-body` `.commit-head` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep` | |
| 399 | 399 | - **`style/content.ts`, code view** — the source view and the syntax-highlight token classes `highlight-html.ts` builds as `tok-${kind}`: `.blob-view` `.ln` `.tok-attribute` `.tok-comment` `.tok-constant` `.tok-decorator` `.tok-deleted` `.tok-emphasis` `.tok-function` `.tok-heading` `.tok-inserted` `.tok-keyword` `.tok-link` `.tok-meta` `.tok-number` `.tok-operator` `.tok-plain` `.tok-property` `.tok-punctuation` `.tok-regex` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable` |
| 400 | 400 | - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r` |
| 401 | 401 | - **`style/content.ts`, diff viewer** — the diff table: its gutters, line kinds, file head and inline review comments: `.add` `.del` `.dh` `.diff` `.diff-body` `.diff-head` `.diff-note` `.diff-path` `.diff-stat` `.diff-stub` `.diff-summary` `.diff-table` `.dl` `.dl-review` `.dn` `.dn-comment` `.nonl` `.rc-hidden` `.rc-resolve` `.rc-resolved` `.wd` |
src/web/pages/boards-view.ts +11 −17
| @@ -18,7 +18,7 @@ import { liveRegionsJs } from "../client.ts"; | ||
| 18 | 18 | import { notFoundPage } from "../chrome.ts"; |
| 19 | 19 | import { html, raw, when, type Html } from "../html.ts"; |
| 20 | 20 | import { fragment, page } from "../layout.ts"; |
| 21 | import { btn, card, chartBox, empty } from "../ui.ts"; | |
| 21 | import { btn, card, chartBox, empty, field, selectField } from "../ui.ts"; | |
| 22 | 22 | import { flowPanel } from "./flow-panel.ts"; |
| 23 | 23 | import { isPinned, listPins } from "../../boards/pins.ts"; |
| 24 | 24 | import { panelData, runFor } from "../../boards/panel_data.ts"; |
| @@ -27,9 +27,6 @@ import { cellsOf, paramsOf, queryFields, readParams } from "./boards.ts"; | ||
| 27 | 27 | /** The events the panels' queries read (runs, pulls, checks, issues, usage): any of them may change a chart. */ |
| 28 | 28 | const READS = "run.queued,run.started,run.finished,pull.*,check.*,issue.*,usage.*"; |
| 29 | 29 | |
| 30 | const option = (value: string, selected: boolean) => | |
| 31 | html`<option value="${value}" ${selected ? raw("selected") : null}>${value}</option>`; | |
| 32 | ||
| 33 | 30 | /** Where a panel lives: its board's slug and its place on it, which name its data door. */ |
| 34 | 31 | export type PanelAt = { slug: string; index: number }; |
| 35 | 32 | |
| @@ -84,7 +81,7 @@ export async function boardsList(ctx: Ctx): Promise<Response> { | ||
| 84 | 81 | const listed = await timePhaseAsync(ctx.request, "boards", () => listAllBoards(ctx.app, ctx.auth.user)); |
| 85 | 82 | if (!listed.ok) return notFoundPage(ctx); |
| 86 | 83 | const make = html`<form method="post" action="/boards/new" class="bform"> |
| 87 | <label class="qf"><span>New board</span><input class="input" name="title" required maxlength="${String(MAX_TITLE)}" placeholder="Title" /></label> | |
| 84 | ${field({ id: "new-title", label: "New board", name: "title", required: true, maxlength: MAX_TITLE, placeholder: "Title" })} | |
| 88 | 85 | ${btn("Make board", { variant: "primary" })} |
| 89 | 86 | </form>`; |
| 90 | 87 | const body = |
| @@ -115,15 +112,12 @@ export async function boardsList(ctx: Ctx): Promise<Response> { | ||
| 115 | 112 | } |
| 116 | 113 | |
| 117 | 114 | function panelForm(slug: string, op: string, p: Panel | undefined, index: number, fields: Html): Html { |
| 115 | const at = op === "edit" ? `e${String(index)}` : "m"; | |
| 118 | 116 | return html`<form method="post" action="/boards/${slug}/${op}" class="bform"> |
| 119 | 117 | ${op === "edit" ? html`<input type="hidden" name="index" value="${String(index)}" />` : null} |
| 120 | <label class="qf"><span>Panel title</span><input class="input" name="title" required maxlength="${String(MAX_TITLE)}" value="${p?.title ?? ""}" placeholder="Panel title" /></label> | |
| 121 | <label class="qf"><span>Width</span><select class="input" name="w"> | |
| 122 | ${[1, 2, 3].slice(0, MAX_W).map((n) => html`<option value="${String(n)}" ${n === (p?.w ?? 1) ? raw("selected") : null}>${String(n)} wide</option>`)} | |
| 123 | </select></label> | |
| 124 | <label class="qf"><span>Height</span><select class="input" name="h"> | |
| 125 | ${[1, 2, 3].slice(0, MAX_H).map((n) => html`<option value="${String(n)}" ${n === (p?.h ?? 1) ? raw("selected") : null}>${String(n)} high</option>`)} | |
| 126 | </select></label> | |
| 118 | ${field({ id: `${at}-title`, label: "Panel title", name: "title", required: true, maxlength: MAX_TITLE, value: p?.title ?? "", placeholder: "Panel title" })} | |
| 119 | ${selectField({ id: `${at}-w`, label: "Width", name: "w", options: [1, 2, 3].slice(0, MAX_W).map((n) => ({ value: String(n), label: `${String(n)} wide`, selected: n === (p?.w ?? 1) })) })} | |
| 120 | ${selectField({ id: `${at}-h`, label: "Height", name: "h", options: [1, 2, 3].slice(0, MAX_H).map((n) => ({ value: String(n), label: `${String(n)} high`, selected: n === (p?.h ?? 1) })) })} | |
| 127 | 121 | ${fields} |
| 128 | 122 | ${btn(op === "edit" ? "Save panel" : "Add panel", { variant: "primary" })} |
| 129 | 123 | </form>`; |
| @@ -143,7 +137,7 @@ function manage(slug: string, board: Board, adding: Html, pins: ReturnType<typeo | ||
| 143 | 137 | const one = (p: Panel, i: number) => html`<li class="row"> |
| 144 | 138 | <details class="row-main"> |
| 145 | 139 | <summary><strong class="break">${p.title}</strong> <span class="muted small">${CHART_NAMES[p.chart]} · ${String(p.w)}×${String(p.h)}</span></summary> |
| 146 | ${panelForm(slug, "edit", p, i, queryFields(paramsOf(p.query, p.chart)))} | |
| 140 | ${panelForm(slug, "edit", p, i, queryFields(paramsOf(p.query, p.chart), `e${String(i)}`))} | |
| 147 | 141 | </details> |
| 148 | 142 | <div class="row-trail bar"> |
| 149 | 143 | ${pinForm(slug, p.title, isPinned(pins, slug, p.title))} |
| @@ -168,12 +162,12 @@ function manage(slug: string, board: Board, adding: Html, pins: ReturnType<typeo | ||
| 168 | 162 | )} |
| 169 | 163 | ${card( |
| 170 | 164 | html`<form method="post" action="/boards/${slug}/rename" class="bform"> |
| 171 | <label class="qf"><span>Board title</span><input class="input" name="title" required maxlength="${String(MAX_TITLE)}" value="${board.title}" /></label> | |
| 165 | ${field({ id: "board-title", label: "Board title", name: "title", required: true, maxlength: MAX_TITLE, value: board.title })} | |
| 172 | 166 | ${btn("Rename")} |
| 173 | 167 | </form> |
| 174 | 168 | <form method="post" action="/boards/${slug}/settings" class="bform"> |
| 175 | <label class="qf"><span>Range</span><select class="input" name="range">${RANGES.map((r) => option(r, r === board.range))}</select></label> | |
| 176 | <label class="qf"><span>Live</span><select class="input" name="refresh"><option value="off" ${board.refresh === "off" ? raw("selected") : null}>off</option><option value="10s" ${board.refresh === "off" ? null : raw("selected")}>on: redraw when events arrive</option></select></label> | |
| 169 | ${selectField({ id: "board-range", label: "Range", name: "range", options: RANGES.map((r) => ({ value: r, label: r, selected: r === board.range })) })} | |
| 170 | ${selectField({ id: "board-refresh", label: "Live", name: "refresh", options: [{ value: "off", label: "off", selected: board.refresh === "off" }, { value: "10s", label: "on: redraw when events arrive", selected: board.refresh !== "off" }] })} | |
| 177 | 171 | ${btn("Save settings")} |
| 178 | 172 | </form> |
| 179 | 173 | <form method="post" action="/boards/${slug}/duplicate" class="bform">${btn("Duplicate")}</form> |
| @@ -197,7 +191,7 @@ export async function boardShow(ctx: Ctx): Promise<Response> { | ||
| 197 | 191 | body: html`<div class="page-head"><h1>${board.title}</h1> |
| 198 | 192 | ${btn("All boards", { href: "/boards", variant: "ghost" })}</div> |
| 199 | 193 | ${panels} |
| 200 | ${manage(slug, board, queryFields(readParams(ctx.url.searchParams)), listPins(ctx.app.db, ctx.auth.user?.id ?? ""))}`, | |
| 194 | ${manage(slug, board, queryFields(readParams(ctx.url.searchParams), "m"), listPins(ctx.app.db, ctx.auth.user?.id ?? ""))}`, | |
| 201 | 195 | scriptJs: liveRegionsJs, |
| 202 | 196 | }); |
| 203 | 197 | notePhase(ctx.request, "render", performance.now() - rendering); |
src/web/pages/boards.ts +30 −63
| @@ -18,7 +18,7 @@ import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../cor | ||
| 18 | 18 | import { notFoundPage } from "../chrome.ts"; |
| 19 | 19 | import { html, raw, when } from "../html.ts"; |
| 20 | 20 | import { page } from "../layout.ts"; |
| 21 | import { btn, card, chartBox, empty } from "../ui.ts"; | |
| 21 | import { btn, card, chartBox, empty, field, selectField } from "../ui.ts"; | |
| 22 | 22 | |
| 23 | 23 | const BUCKET_MS = { minute: 60_000, hour: 3_600_000, day: 86_400_000 } as const; |
| 24 | 24 | const AGGREGATES = ["count", "sum", "avg", "max"] as const; |
| @@ -133,67 +133,36 @@ export function machineLinks(now: number): { label: string; href: string }[] { | ||
| 133 | 133 | ]; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | const option = (value: string, label: string, selected: boolean) => | |
| 137 | html`<option value="${value}" ${selected ? raw("selected") : null}>${label}</option>`; | |
| 138 | ||
| 139 | 136 | /** The inputs that say a query, filled from `p`; the page's form and a panel's share them. */ |
| 140 | export function queryFields(p: Params) { | |
| 137 | export function queryFields(p: Params, idp: string) { | |
| 141 | 138 | const src = Object.hasOwn(SOURCES, p.source) ? SOURCES[p.source]! : undefined; |
| 142 | 139 | const cols = src ? Object.keys(src.columns) : []; |
| 140 | const opt = (value: string, label: string, current: string) => ({ value, label, selected: value === current }); | |
| 141 | const pick = (name: string, label: string, options: { value: string; label: string; selected: boolean }[]) => | |
| 142 | selectField({ label, name, id: `${idp}-${name}`, options }); | |
| 143 | const text = (name: string, label: string, value: string, placeholder: string) => | |
| 144 | field({ label, name, id: `${idp}-${name}`, value, placeholder, mono: true, maxlength: MAX_PARAM }); | |
| 143 | 145 | return html` |
| 144 | <label class="qf"><span>Chart</span> | |
| 145 | <select class="input" name="chart"> | |
| 146 | ${CHARTS.map((c) => option(c, CHART_NAMES[c], c === p.chart))} | |
| 147 | </select> | |
| 148 | </label> | |
| 149 | <label class="qf"><span>Source</span> | |
| 150 | <select class="input" name="source"> | |
| 151 | ${Object.keys(SOURCES).map((n) => option(n, n, n === p.source))} | |
| 152 | </select> | |
| 153 | </label> | |
| 154 | <label class="qf"><span>Aggregate</span> | |
| 155 | <select class="input" name="aggregate"> | |
| 156 | ${AGGREGATES.map((a) => option(a, a, a === p.aggregate))} | |
| 157 | </select> | |
| 158 | </label> | |
| 159 | <label class="qf" title="Column to aggregate"><span>Column</span> | |
| 160 | <select class="input" name="column"> | |
| 161 | ${option("", "(rows)", p.column === "")} | |
| 162 | ${cols.filter((c) => src!.columns[c] === "number").map((c) => option(c, c, c === p.column))} | |
| 163 | </select> | |
| 164 | </label> | |
| 165 | <label class="qf" title="Group by"><span>Group by</span> | |
| 166 | <select class="input" name="by"> | |
| 167 | ${(Object.keys(BUCKET_MS) as Bucket[]).map((b) => option(b, `per ${b}`, b === p.by))} | |
| 168 | ${cols.map((c) => option(c, `by ${c}`, c === p.by))} | |
| 169 | </select> | |
| 170 | </label> | |
| 171 | <label class="qf" title="Series (stacked area, heat strip, table)"><span>Series</span> | |
| 172 | <select class="input" name="series"> | |
| 173 | ${option("", "(one series)", p.series === "")} | |
| 174 | ${cols.map((c) => option(c, `split by ${c}`, c === p.series))} | |
| 175 | </select> | |
| 176 | </label> | |
| 177 | <label class="qf"><span>From</span> | |
| 178 | <input class="input mono" name="from" value="${p.from}" placeholder="from 2026-10-01" maxlength="${MAX_PARAM}" /> | |
| 179 | </label> | |
| 180 | <label class="qf"><span>To</span> | |
| 181 | <input class="input mono" name="to" value="${p.to}" placeholder="to 2026-10-08" maxlength="${MAX_PARAM}" /> | |
| 182 | </label> | |
| 183 | <label class="qf"><span>Filter column</span> | |
| 184 | <select class="input" name="fcolumn"> | |
| 185 | ${option("", "(no filter)", p.fcolumn === "")} | |
| 186 | ${cols.map((c) => option(c, c, c === p.fcolumn))} | |
| 187 | </select> | |
| 188 | </label> | |
| 189 | <label class="qf"><span>Filter operator</span> | |
| 190 | <select class="input" name="fop"> | |
| 191 | ${OPS.map((o) => option(o, o, o === p.fop))} | |
| 192 | </select> | |
| 193 | </label> | |
| 194 | <label class="qf"><span>Filter value</span> | |
| 195 | <input class="input mono" name="fvalue" value="${p.fvalue}" placeholder="value" maxlength="${MAX_PARAM}" /> | |
| 196 | </label> | |
| 146 | ${pick("chart", "Chart", CHARTS.map((c) => opt(c, CHART_NAMES[c], p.chart)))} | |
| 147 | ${pick("source", "Source", Object.keys(SOURCES).map((n) => opt(n, n, p.source)))} | |
| 148 | ${pick("aggregate", "Aggregate", AGGREGATES.map((a) => opt(a, a, p.aggregate)))} | |
| 149 | ${pick("column", "Column", [ | |
| 150 | opt("", "(rows)", p.column), | |
| 151 | ...cols.filter((c) => src!.columns[c] === "number").map((c) => opt(c, c, p.column)), | |
| 152 | ])} | |
| 153 | ${pick("by", "Group by", [ | |
| 154 | ...(Object.keys(BUCKET_MS) as Bucket[]).map((b) => opt(b, `per ${b}`, p.by)), | |
| 155 | ...cols.map((c) => opt(c, `by ${c}`, p.by)), | |
| 156 | ])} | |
| 157 | ${pick("series", "Series", [ | |
| 158 | opt("", "(one series)", p.series), | |
| 159 | ...cols.map((c) => opt(c, `split by ${c}`, p.series)), | |
| 160 | ])} | |
| 161 | ${text("from", "From", p.from, "from 2026-10-01")} | |
| 162 | ${text("to", "To", p.to, "to 2026-10-08")} | |
| 163 | ${pick("fcolumn", "Filter column", [opt("", "(no filter)", p.fcolumn), ...cols.map((c) => opt(c, c, p.fcolumn))])} | |
| 164 | ${pick("fop", "Filter operator", OPS.map((o) => opt(o, o, p.fop)))} | |
| 165 | ${text("fvalue", "Filter value", p.fvalue, "value")} | |
| 197 | 166 | `; |
| 198 | 167 | } |
| 199 | 168 | |
| @@ -248,7 +217,7 @@ export async function boardsPage(ctx: Ctx): Promise<Response> { | ||
| 248 | 217 | |
| 249 | 218 | const form = card( |
| 250 | 219 | html`<form method="get" action="/boards/data" class="bform"> |
| 251 | ${queryFields(p)} | |
| 220 | ${queryFields(p, "q")} | |
| 252 | 221 | ${btn("Draw", { variant: "primary" })} |
| 253 | 222 | </form>`, |
| 254 | 223 | { head: html`<h2>Query</h2>` }, |
| @@ -295,10 +264,8 @@ export async function boardsPage(ctx: Ctx): Promise<Response> { | ||
| 295 | 264 | (k) => html`<input type="hidden" name="${k}" value="${p[k as keyof Params]}" />`, |
| 296 | 265 | )} |
| 297 | 266 | <input type="hidden" name="w" value="1" /><input type="hidden" name="h" value="1" /> |
| 298 | <label class="qf"><span>Board</span><select class="input" name="slug"> | |
| 299 | ${boards.map((b) => html`<option value="${b.slug}">${b.board.title}</option>`)} | |
| 300 | </select></label> | |
| 301 | <label class="qf"><span>Panel title</span><input class="input" name="title" required maxlength="80" value="${`${p.aggregate} of ${p.source}`}" /></label> | |
| 267 | ${selectField({ label: "Board", name: "slug", id: "pin-slug", options: boards.map((b) => ({ value: b.slug, label: b.board.title })) })} | |
| 268 | ${field({ label: "Panel title", name: "title", id: "pin-title", value: `${p.aggregate} of ${p.source}`, required: true, maxlength: 80 })} | |
| 302 | 269 | ${btn("Pin to board")} |
| 303 | 270 | </form>`, |
| 304 | 271 | { head: html`<h2>Pin this query</h2>` }, |
src/web/style/content.ts +1 −2
| @@ -295,8 +295,7 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); } | ||
| 295 | 295 | .bp-h2 .chart-box.is-table { height: 400px; } |
| 296 | 296 | .bp-h3 .chart-box.is-table { height: 540px; } |
| 297 | 297 | .bform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; margin-bottom: 8px; } |
| 298 | .bform .qf { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; min-width: 0; } | |
| 299 | .bform .qf > span { font-size: 12.5px; font-weight: 600; color: var(--fg); } | |
| 298 | .bform .field { flex: 1 1 140px; min-width: 0; margin: 0; } | |
| 300 | 299 | .bform .btn { flex: none; } |
| 301 | 300 | .boards-result .table { margin-top: 12px; } |
| 302 | 301 | .bt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 2px 16px; font-family: var(--mono); font-size: 12.5px; margin-top: 8px; } |
src/web/ui.ts +3 −8
| @@ -1173,18 +1173,13 @@ export function selectField( | ||
| 1173 | 1173 | const id = o.id ?? `f-${o.name}`; |
| 1174 | 1174 | return html`<div class="field"> |
| 1175 | 1175 | <label for="${id}">${o.label}</label> |
| 1176 | <select class="input" id="${id}" name="${o.name}"> | |
| 1176 | <select class="input" id="${id}" name="${o.name}"${o.hint ? html` aria-describedby="${id}-hint"` : null}> | |
| 1177 | 1177 | ${o.options.map( |
| 1178 | 1178 | (opt) => |
| 1179 | html`<option | |
| 1180 | value="${opt.value}" | |
| 1181 | ${opt.selected ? raw("selected") : null} | |
| 1182 | > | |
| 1183 | ${opt.label} | |
| 1184 | </option>`, | |
| 1179 | html`<option value="${opt.value}"${opt.selected ? raw(" selected") : null}>${opt.label}</option>`, | |
| 1185 | 1180 | )} |
| 1186 | 1181 | </select> |
| 1187 | ${o.hint ? html`<span class="hint">${o.hint}</span>` : null} | |
| 1182 | ${o.hint ? html`<span class="hint" id="${id}-hint">${o.hint}</span>` : null} | |
| 1188 | 1183 | </div>`; |
| 1189 | 1184 | } |
| 1190 | 1185 |
test/boards-page.test.ts +3 −3
| @@ -224,9 +224,9 @@ describe("every chart type from one seeded query", () => { | ||
| 224 | 224 | }); |
| 225 | 225 | test("the chart is chosen beside the query", async () => { |
| 226 | 226 | const body = await drawn("heat"); |
| 227 | expect(body).toMatch(/<select class="input" name="chart"[^>]*>/); | |
| 228 | expect(body).toContain('<option value="heat" selected>heat strip</option>'); | |
| 229 | expect(body).toContain('<option value="kind" selected>split by kind</option>'); | |
| 227 | expect(body).toMatch(/<select\s+class="input"\s+id="q-chart"\s+name="chart"[^>]*>/); | |
| 228 | expect(body).toMatch(/<option\s+value="heat"\s+selected\s*>\s*heat strip\s*<\/option>/); | |
| 229 | expect(body).toMatch(/<option\s+value="kind"\s+selected\s*>\s*split by kind\s*<\/option>/); | |
| 230 | 230 | }); |
| 231 | 231 | }); |
| 232 | 232 |
test/boards-selectors.test.ts +35 −2
| @@ -58,10 +58,13 @@ test("every query selector has a visible label and sits outside .row-actions", a | ||
| 58 | 58 | expect(form![0]).not.toContain("row-actions"); |
| 59 | 59 | expect(form![0]).toContain('class="bform"'); |
| 60 | 60 | for (const name of ["chart", "source", "aggregate", "column", "by", "series", "from", "to", "fcolumn", "fop", "fvalue"]) { |
| 61 | const m = form![1]!.match(new RegExp(`<label class="qf"[^>]*><span>([^<]+)</span>\\s*<(?:select|input)[^>]* name="${name}"`)); | |
| 61 | const m = form![1]!.match(new RegExp(`<div class="field"[^>]*>\\s*<label for="([^"]+)">([^<]+)</label>\\s*<(?:select|input)[^>]*\\sid="\\1"\\s+name="${name}"`)); | |
| 62 | 62 | expect(m, name).not.toBeNull(); |
| 63 | expect(m![1]!.trim().length, name).toBeGreaterThan(0); | |
| 63 | expect(m![2]!.trim().length, name).toBeGreaterThan(0); | |
| 64 | 64 | } |
| 65 | expect(html).not.toContain('class="qf"'); | |
| 66 | expect(html).not.toMatch(/<div class="field"[^>]*\stitle=/); | |
| 67 | expect(form![0]).not.toContain('class="hint"'); // a hint under one select makes a wrapped .bform row ragged | |
| 65 | 68 | }); |
| 66 | 69 | |
| 67 | 70 | test("the selector styles never hide or collapse a control", () => { |
| @@ -82,3 +85,33 @@ test("in every theme the label, field text and border read against their ground" | ||
| 82 | 85 | expect(t.card.toLowerCase(), `${name} field ground`).not.toBe(t.fg.toLowerCase()); |
| 83 | 86 | } |
| 84 | 87 | }); |
| 88 | ||
| 89 | test("selectField ties its hint to the select with aria-describedby", async () => { | |
| 90 | const { selectField } = await import("../src/web/ui.ts"); | |
| 91 | const out = String(selectField({ id: "x", label: "L", name: "n", hint: "H", options: [{ value: "a", label: "A" }] })); | |
| 92 | expect(out).toMatch(/<select[^>]*aria-describedby="x-hint"/); | |
| 93 | expect(out).toContain('id="x-hint"'); | |
| 94 | expect(String(selectField({ id: "y", label: "L", name: "n", options: [] }))).not.toContain("aria-describedby"); | |
| 95 | }); | |
| 96 | ||
| 97 | test("the boards list and a board draw every form field as .field with unique ids", async () => { | |
| 98 | const h = { authorization: `Bearer ${token}`, origin: servers.url, "content-type": "application/x-www-form-urlencoded" }; | |
| 99 | const made = await fetch(`${servers.url}/boards/new`, { method: "POST", headers: h, body: "title=Forms", redirect: "manual" }); | |
| 100 | const slug = (made.headers.get("location") ?? "").split("/").pop()!; | |
| 101 | const list = await (await fetch(`${servers.url}/boards`, { headers: h })).text(); | |
| 102 | expect(list).not.toContain('class="qf"'); | |
| 103 | expect(list).toMatch(/<label for="new-title">New board<\/label>/); | |
| 104 | const page = await (await fetch(`${servers.url}/boards/${slug}`, { headers: h })).text(); | |
| 105 | expect(page).not.toContain('class="qf"'); | |
| 106 | for (const id of ["board-title", "board-range", "board-refresh", "m-title", "m-w", "m-h"]) { | |
| 107 | expect(page, id).toContain(`<label for="${id}">`); | |
| 108 | } | |
| 109 | const ids = [...page.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]); | |
| 110 | expect(new Set(ids).size).toBe(ids.length); | |
| 111 | }); | |
| 112 | ||
| 113 | test(".bform drops the .field bottom margin so buttons align with the inputs", () => { | |
| 114 | const rule = (content + components).match(/\.bform \.field \{([^}]*)\}/); | |
| 115 | expect(rule).not.toBeNull(); | |
| 116 | expect(rule![1]).toMatch(/margin:\s*0\b/); | |
| 117 | }); |
test/boards-store.test.ts +12 −1
| @@ -231,6 +231,17 @@ describe("/boards", () => { | ||
| 231 | 231 | expect((await asAdmin("/boards/scratch-b")).status).toBe(404); |
| 232 | 232 | }); |
| 233 | 233 | |
| 234 | test("no id repeats on a board page with several panels", async () => { | |
| 235 | await post("/boards/new", { title: "Ids" }); | |
| 236 | const q = { source: "runs", aggregate: "count", column: "", by: "day", from: "", to: "", fcolumn: "", fop: "eq", fvalue: "" }; | |
| 237 | for (const title of ["one", "two", "three"]) await post("/boards/ids/add", { ...q, title, w: "1", h: "1" }); | |
| 238 | const page = await (await asAdmin("/boards/ids")).text(); | |
| 239 | const ids = [...page.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]!); | |
| 240 | expect(ids).toContain("e2-chart"); | |
| 241 | expect(ids).toContain("m-chart"); | |
| 242 | expect(ids.filter((id, i) => ids.indexOf(id) !== i)).toEqual([]); | |
| 243 | }); | |
| 244 | ||
| 234 | 245 | test("a pinned query lands on the board", async () => { |
| 235 | 246 | const data = await (await asAdmin("/boards/data?source=runs&by=kind")).text(); |
| 236 | 247 | expect(data).toContain('action="/boards/pin"'); |
| @@ -250,7 +261,7 @@ describe("/boards", () => { | ||
| 250 | 261 | // runs in range: three days × three kinds for the heat strip; three days of bars, the series set aside |
| 251 | 262 | expect(page.match(/<rect class="cell"/g)?.length).toBe(9); |
| 252 | 263 | expect(page.match(/<rect class="bar"/g)?.length).toBe(3); |
| 253 | expect(page).toContain('<option value="heat" selected>heat strip</option>'); | |
| 264 | expect(page).toMatch(/<option\s+value="heat"\s+selected\s*>\s*heat strip\s*<\/option>/); | |
| 254 | 265 | expect(parseBoard({ ...board, panels: [{ ...board.panels[0], chart: "pie" }] }).ok).toBe(false); |
| 255 | 266 | await deleteBoard(app, alice, "charts"); |
| 256 | 267 | }); |
test/ssh-site.test.ts +1 −1
| @@ -103,7 +103,7 @@ describe("the terminal on the website", () => { | ||
| 103 | 103 | const page = await fetch(`${base}/settings/crew`, { |
| 104 | 104 | headers: { cookie }, |
| 105 | 105 | }).then((r) => r.text()); |
| 106 | expect(page).toContain('<select class="input" id="f-model" name="model">'); | |
| 106 | expect(page).toContain('<select class="input" id="f-model" name="model" aria-describedby="f-model-hint">'); | |
| 107 | 107 | expect(page).toContain('value="opus"'); |
| 108 | 108 | expect(page).toContain('value="sonnet"'); |
| 109 | 109 | expect(page).toContain('value="haiku"'); |
new above
offline