Public: anyone can read this; the crew can change it.
The flags page's forms use §5's .field and buttons, and .flag-form leaves the stylesheet #4801
scout/forge:scout/4614-the-flags-page-s-forms-use-5-s-field-and → main 9 commits fork 2 threads · 2 unresolved
5 files
changed +32
−27
docs/DESIGN.md +1 −1
| @@ -396,7 +396,7 @@ gone, so this list only shrinks. | ||
| 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` `.comment` `.comment-body` `.comment-form` `.dialog-body` `.dialog-foot` `.dialog-head` `.empty-title` `.error-note` `.field-row` `.form-actions` `.hex` `.ico` `.ico-loader` `.list` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search` |
| 397 | 397 | `.split` is the one two-column page: main, then an `<aside>` rail of 260px that sticks from 960px. `data-rail="wide"` on it (the studio's home and an app's page) widens the rail to 320px from 900px, drops the top margin, and lets the rail scroll with the page, since a column of cards runs taller than a screen |
| 398 | 398 | - **`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` |
| 399 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.bform` `.bgrid` `.bmanage` `.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` `.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` `.headroom` `.issue-head` `.issue-meta` `.number` `.owner` `.page-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.sub` `.table-wrap` `.tok` `.where-sep` | |
| 399 | - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.bform` `.bgrid` `.bmanage` `.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` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.headroom` `.issue-head` `.issue-meta` `.number` `.owner` `.page-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.sub` `.table-wrap` `.tok` `.where-sep` | |
| 400 | 400 | - **`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` |
| 401 | 401 | - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r` |
| 402 | 402 | - **`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` `.dn` `.dn-comment` `.nonl` `.wd` |
src/web/pages/flags.ts +23 −18
| @@ -11,10 +11,10 @@ import { makeWinnerDefault } from "../../actions/flag_winner.ts"; | ||
| 11 | 11 | import type { Ctx } from "../../http/context.ts"; |
| 12 | 12 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; |
| 13 | 13 | import { settingsLayout, signInFirst } from "../chrome.ts"; |
| 14 | import { field, readForm } from "../form.ts"; | |
| 14 | import { field as formField, readForm } from "../form.ts"; | |
| 15 | 15 | import { html } from "../html.ts"; |
| 16 | 16 | import { flashTo, page } from "../layout.ts"; |
| 17 | import { btn, card, empty, icon, row } from "../ui.ts"; | |
| 17 | import { btn, card, empty, field, icon, row, selectField } from "../ui.ts"; | |
| 18 | 18 | import { accountSections } from "./origins.ts"; |
| 19 | 19 | |
| 20 | 20 | export { useFlagRegistry }; |
| @@ -88,16 +88,21 @@ export function flagsPage(ctx: Ctx): Response { | ||
| 88 | 88 | <span class="mono">${decl.default ? "on" : "off"}</span> · owner |
| 89 | 89 | ${issueLink(repo, decl.issue)} · |
| 90 | 90 | live: ${summary(v)}<br /><span class="mono">${usesLine(week, month)}</span>`, |
| 91 | trail: html`<form class="row-fields flag-form" method="post" action="/settings/flags"> | |
| 91 | trail: html`<form class="row-fields" method="post" action="/settings/flags"> | |
| 92 | 92 | <input type="hidden" name="name" value="${name}" /> |
| 93 | <select class="input" name="forge" aria-label="${name} for the forge"> | |
| 94 | <option value="" ${v?.forge === undefined ? "selected" : ""}>forge: default</option> | |
| 95 | <option value="on" ${v?.forge === true ? "selected" : ""}>forge: on</option> | |
| 96 | <option value="off" ${v?.forge === false ? "selected" : ""}>forge: off</option> | |
| 97 | </select> | |
| 98 | <input class="input mono" name="users" placeholder="user ids" value="${(v?.users ?? []).join(", ")}" aria-label="${name} users" /> | |
| 99 | <input class="input mono" name="roles" placeholder="roles" value="${(v?.roles ?? []).join(", ")}" aria-label="${name} roles" /> | |
| 100 | <input class="input mono" name="percent" placeholder="%" size="3" value="${v?.percent === undefined ? "" : String(v.percent)}" aria-label="${name} percent" /> | |
| 93 | ${selectField({ | |
| 94 | label: "Forge", | |
| 95 | name: "forge", | |
| 96 | id: `f-${name}-forge`, | |
| 97 | options: [ | |
| 98 | { value: "", label: "forge: default", selected: v?.forge === undefined }, | |
| 99 | { value: "on", label: "forge: on", selected: v?.forge === true }, | |
| 100 | { value: "off", label: "forge: off", selected: v?.forge === false }, | |
| 101 | ], | |
| 102 | })} | |
| 103 | ${field({ label: "Users", name: "users", id: `f-${name}-users`, value: (v?.users ?? []).join(", "), placeholder: "user ids", mono: true, spellcheck: false })} | |
| 104 | ${field({ label: "Roles", name: "roles", id: `f-${name}-roles`, value: (v?.roles ?? []).join(", "), placeholder: "roles", mono: true, spellcheck: false })} | |
| 105 | ${field({ label: "Percent", name: "percent", id: `f-${name}-percent`, value: v?.percent === undefined ? "" : String(v.percent), placeholder: "%", mono: true, spellcheck: false })} | |
| 101 | 106 | ${btn("Save", { size: "sm", variant: "primary", label: `Save ${name}` })} |
| 102 | 107 | ${btn("Clear", { size: "sm", name: "clear", value: "1", label: `Clear ${name}` })} |
| 103 | 108 | ${lead === undefined |
| @@ -140,8 +145,8 @@ export async function flagsSet(ctx: Ctx): Promise<Response> { | ||
| 140 | 145 | const registry = flagRegistry(); |
| 141 | 146 | const form = await readForm(ctx, "admin"); |
| 142 | 147 | if (form instanceof Response) return form; |
| 143 | const name = field(form, "name"); | |
| 144 | const winner = field(form, "winner"); | |
| 148 | const name = formField(form, "name"); | |
| 149 | const winner = formField(form, "winner"); | |
| 145 | 150 | if (winner === "on" || winner === "off") { |
| 146 | 151 | const made = makeWinnerDefault(ctx.app, ctx.auth.user!, name, winner); |
| 147 | 152 | return flashTo( |
| @@ -153,13 +158,13 @@ export async function flagsSet(ctx: Ctx): Promise<Response> { | ||
| 153 | 158 | ); |
| 154 | 159 | } |
| 155 | 160 | const checked = |
| 156 | field(form, "clear") === "1" | |
| 161 | formField(form, "clear") === "1" | |
| 157 | 162 | ? ({ ok: true, value: undefined } as const) |
| 158 | 163 | : checkInput({ |
| 159 | forge: field(form, "forge"), | |
| 160 | users: field(form, "users"), | |
| 161 | roles: field(form, "roles"), | |
| 162 | percent: field(form, "percent"), | |
| 164 | forge: formField(form, "forge"), | |
| 165 | users: formField(form, "users"), | |
| 166 | roles: formField(form, "roles"), | |
| 167 | percent: formField(form, "percent"), | |
| 163 | 168 | }); |
| 164 | 169 | const stored = |
| 165 | 170 | checked.ok && registry.set(ctx.app.db, name, checked.value, ctx.auth.user!.id); |
src/web/style/components.ts +3
| @@ -439,6 +439,9 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 439 | 439 | /* A number beside its label in a settings row stays a few digits wide. */ |
| 440 | 440 | .row-fields .input[type="number"] { width: 5em; } |
| 441 | 441 | .row-fields .check { align-items: center; } |
| 442 | /* A labelled field beside a bare button: the button sits on the input's baseline. */ | |
| 443 | .row-fields:has(.field) { align-items: flex-end; } | |
| 444 | .row-fields .field { margin: 0; min-width: 0; flex: 1 1 8rem; max-width: 14rem; } | |
A percent field only needs a few digits. Add Fields are max 14rem and flex from 8rem; confirm at 360px that the four fields plus buttons wrap without a horizontal scroll. |
||
| 442 | 445 | .setting-list .row { flex-wrap: wrap; align-items: flex-start; } |
| 443 | 446 | .setting-list .row-main { flex: 1 1 18rem; } |
| 444 | 447 | .setting-list .row-title, .setting-list .row-meta { white-space: normal; overflow: visible; overflow-wrap: anywhere; } |
src/web/style/content.ts −8
| @@ -208,14 +208,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); } | ||
| 208 | 208 | .row:has(.headroom) { flex-wrap: wrap; } |
| 209 | 209 | .row:has(.headroom) .row-trail { flex-basis: 100%; flex-wrap: wrap; } |
| 210 | 210 | } |
| 211 | /* Settings → Flags: a flag's controls wrap under its text on a phone, never sideways. */ | |
| 212 | .flag-form { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; } | |
| 213 | @media (max-width: 640px) { | |
| 214 | .row:has(.flag-form) { flex-wrap: wrap; } | |
| 215 | .row:has(.flag-form) .row-trail { flex-basis: 100%; min-width: 0; } | |
| 216 | .flag-form { justify-content: flex-start; } | |
| 217 | .flag-form .input { min-width: 0; flex: 1 1 8rem; } | |
| 218 | } | |
| 219 | 211 | .chart-box { color: var(--accent); aspect-ratio: 720 / 260; max-width: 720px; } |
| 220 | 212 | .chart-box .chart { display: block; width: 100%; height: auto; } |
| 221 | 213 | .chart-box text { fill: var(--muted-fg); font-family: var(--mono); } |
test/flags-settings.test.ts +5
| @@ -76,11 +76,16 @@ describe("settings → flags", () => { | ||
| 76 | 76 | expect(text).toContain("alpha"); |
| 77 | 77 | expect(text).toContain("shows the new board"); |
| 78 | 78 | expect(text).toContain('href="/acme/forge/issues/1970"'); |
| 79 | expect(text).not.toContain("flag-form"); | |
| 80 | expect(text).toContain('<div class="field"'); | |
| 81 | expect(text).toContain('for="f-alpha-users"'); | |
| 79 | 82 | |
| 80 | 83 | const set = await post(cookie, { name: "alpha", forge: "on", users: "u1, u2", roles: "admin", percent: "30" }); |
| 81 | 84 | expect(set.status).toBe(303); |
| 82 | 85 | expect(reg.value("alpha")).toEqual({ forge: true, users: ["u1", "u2"], roles: ["admin"], percent: 30 }); |
| 83 | 86 | expect(reg.flag("alpha")).toBe(true); |
| 87 | const again = await (await fetch(`${servers.url}/settings/flags`, { headers: { cookie } })).text(); | |
| 88 | expect(again).toMatch(/<input[^>]*name="percent"[^>]*value="30"|<input[^>]*value="30"[^>]*name="percent"/); | |
| 84 | 89 | const log = app.db.query("SELECT actor_id FROM forge_setting_change WHERE key = 'flag.alpha'").all(); |
| 85 | 90 | expect(log).toEqual([{ actor_id: aliceId }]); |
| 86 | 91 |
new above
offline
Label is just "Users" on every row; the flag name was in the old aria-label. Keep it for screen readers, for example with a visually hidden suffix or aria-describedby.