Public: anyone can read this; the crew can change it.

Design: the origins page's handoff and connect path use the design system, and handoff/connect-* leave §5d #3865

Parked opened this
Closed without merging

scout/forge:scout/3839-design-the-origins-page-s-handoff-and-co → main 7 commits fork 3 threads · 3 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
6 files changed +111 −75
docs/DESIGN.md +5 −1
@@ -55,7 +55,7 @@ variables, so a theme is data. Six ship today. What each role _means_:
5555 | `--add-*` / `--del-*` / `--wd-*` | the diff. Tints stay ≤14% so syntax color survives on top. |
5656 | `--tok-*` | syntax, in two layers: eleven colour classes every consumer knows, plus finer kinds the web paints over them (§6c). |
5757 | `--shadow-1` / `--shadow-2` | a hint and an overlay. Near-transparent in dark palettes, so one rule serves every theme. |
58 | `--series-0…7` / `--qr-ground` | the same in every theme (`FIXED_TOKENS`): chart series (Okabe–Ito, colour-vision safe) and a QR code's white ground. |
58 | `--series-0…7` | the same in every theme (`FIXED_TOKENS`): chart series (Okabe–Ito, colour-vision safe). |
outdated

The row ends with an extra empty cell (| |) that the other rows do not have. Drop it so the table stays four columns wide and the pipes line up.

outdated

The row ends with | |, an extra empty cell that breaks the table width and the formatter. Remove it and pad to the column width.

5959
6060 **Status surfaces are tinted, never saturated**: `color-mix(in srgb, var(--x)
6161 12%, transparent)` for the fill, the pure token for the text, a 34% mix for the
@@ -393,7 +393,11 @@ gone, so this list only shrinks.
393393 - **`style/base.ts`** — the page shell (topbar, main, footer) and the layout and text utilities every page leans on: `.bar` `.bare` `.foot` `.grow` `.hide-lg` `.hide-sm` `.js-only` `.live-pill` `.mark` `.mb` `.mt` `.muted` `.narrow` `.narrow-wide` `.num` `.reduced` `.shell` `.shell-wide` `.skip` `.small` `.spacer` `.sr-only` `.stack` `.stack-tight` `.topbar` `.topbar-tools` `.truncate` `.wordmark`
394394 - **`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`
395395 - **`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`
396 <<<<<<< HEAD
397 - **`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, following, lineage: `.about` `.act` `.app-shelf` `.app-tile-body` `.app-tile-desc` `.app-tile-look` `.app-tile-name` `.app-tile` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.big` `.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` `.chart-box` `.chart` `.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` `.following-actions` `.following-eyebrow` `.following-foot` `.following-head` `.following-sentence` `.following` `.fork-bar` `.front-admin` `.front-controls` `.front-crew` `.front-featured-body` `.front-featured-look` `.front-featured` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen-form` `.frozen-sentence` `.frozen` `.headroom` `.hero-terminal` `.hero` `.issue-head` `.issue-meta` `.kv` `.lineage-children` `.lineage-here` `.lineage` `.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` `.quiet-details` `.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 =======
396399 - **`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, following, lineage: `.about` `.act` `.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` `.big` `.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` `.chart` `.chart-box` `.commit-body` `.commit-head` `.connect-more` `.connect-path` `.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` `.following` `.following-actions` `.following-eyebrow` `.following-foot` `.following-head` `.following-sentence` `.fork-bar` `.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` `.handoff` `.handoff-links` `.headroom` `.hero` `.hero-terminal` `.issue-head` `.issue-meta` `.kv` `.lineage` `.lineage-children` `.lineage-here` `.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`
400 >>>>>>> origin/main
397401 - **`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`
398402 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
399403 - **`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/design/themes.ts −1
@@ -399,7 +399,6 @@ export const FIXED_TOKENS = {
399399 "series-5": "#d55e00",
400400 "series-6": "#c9b800",
401401 "series-7": "#8a8a8a",
402 "qr-ground": "#ffffff",
403402 } as const;
404403
405404 function vars(theme: Theme): string {
src/web/pages/origins.ts +82 −57
@@ -404,9 +404,10 @@ function githubSection(configured: boolean, callback: string): Html {
404404 if (!configured) {
405405 const back =
406406 callback === "" ? "<your forge>/settings/origins/callback" : callback;
407 return html`<div class="connect-path">
408 <h3>${icon("github")}GitHub, one click</h3>
409 <p class="muted small">
407 return pathCard(
408 "github",
409 "GitHub, one click",
410 html`<p class="muted small">
410411 Needs a one-time OAuth app setup: no GitHub application is registered
411412 for this forge yet, so the device flow has no client id to use. Three
412413 steps, once, for every user of this forge:
@@ -434,20 +435,35 @@ function githubSection(configured: boolean, callback: string): Html {
434435 <p class="muted small">
435436 Until then, a personal access token below works and needs no
436437 registration anywhere.
437 </p>
438 </div>`;
438 </p>`,
439 );
439440 }
440 return html`<div class="connect-path">
441 <h3>${icon("github")}GitHub, one click</h3>
442 <p class="muted small">
441 return pathCard(
442 "github",
443 "GitHub, one click",
444 html`<p class="muted small">
443445 A short code and a URL you type it into — from this machine or from your
444446 phone. Nothing is typed into this terminal or this page.
445447 </p>
446448 <form method="post" action="/settings/origins/oauth">
447449 <input type="hidden" name="kind" value="github" />
448450 ${btn("Connect GitHub", { variant: "primary", icon: "github" })}
449 </form>
450 </div>`;
451 </form>`,
452 );
453 }
454
455 /** One way to connect: its own card, titled with the provider's mark. */
456 function pathCard(
457 mark: "github" | "forgejo" | "key",
458 title: string,
459 body: Html,
460 tag?: Html,
461 ): Html {
462 return card(body, {
463 head: html`${icon(mark)}
464 <h3>${title}</h3>
465 ${tag ?? null}`,
466 });
451467 }
452468
453469 function forgejoSection(
@@ -457,16 +473,17 @@ function forgejoSection(
457473 ): Html {
458474 const back = callbackUri(ctx);
459475 if (back === "") {
460 return html`<div class="connect-path">
461 <h3>${icon("forgejo")}Forgejo / Gitea, one click</h3>
462 <p class="error-note">
476 return pathCard(
477 "forgejo",
478 "Forgejo / Gitea, one click",
479 html`<p class="error-note">
463480 This forge does not know its own public URL, so it cannot register a
464481 callback for the code flow. Set
465482 <span class="mono">FORGE_URL</span> to the base URL people reach it at
466483 (or <span class="mono">FORGE_HOST</span> to the hostname it is served
467484 on) and this path lights up. A pasted token works either way.
468 </p>
469 </div>`;
485 </p>`,
486 );
470487 }
471488 // Two verbs, two endpoints, and HTML forbids nesting one form in another —
472489 // so the "forget" form sits beside the authorize form and its button joins
@@ -572,9 +589,10 @@ function forgejoSection(
572589 </div>`
573590 : null;
574591
575 return html`<div class="connect-path">
576 <h3>${icon("forgejo")}Forgejo / Gitea, one click</h3>
577 <p class="muted small">
592 return pathCard(
593 "forgejo",
594 "Forgejo / Gitea, one click",
595 html`<p class="muted small">
578596 Needs an app registration on the instance. Name it and this forge works
579597 out which it is, then sends you there to authorize.
580598 </p>
@@ -592,8 +610,8 @@ function forgejoSection(
592610 ${btn("Continue", { variant: registered ? "secondary" : "primary" })}
593611 </div>
594612 </form>
595 ${authorize} ${registerForm}
596 </div>`;
613 ${authorize} ${registerForm}`,
614 );
597615 }
598616
599617 /**
@@ -603,12 +621,10 @@ function forgejoSection(
603621 * environment variable is a page that teaches people the product is fiddly.
604622 */
605623 function tokenSection(values: ConnectValues): Html {
606 return html`<div class="connect-path">
607 <h3>
608 ${icon("key")}Personal access token
609 ${badge("recommended", { tone: "success" })}
610 </h3>
611 <p class="muted small">
624 return pathCard(
625 "key",
626 "Personal access token",
627 html`<p class="muted small">
612628 Nothing to register, anywhere. The token is validated against the forge
613629 before it is stored, encrypted at rest, and never shown again.
614630 </p>
@@ -632,8 +648,9 @@ function tokenSection(values: ConnectValues): Html {
632648 hint: "Needs repository and issue access. It is never displayed after this.",
633649 })}
634650 <div class="form-actions">${btn("Connect", { variant: "primary" })}</div>
635 </form>
636 </div>`;
651 </form>`,
652 badge("recommended", { tone: "success" }),
653 );
637654 }
638655
639656 /** The admin's list of hosts an origin may reach inside the network. */
@@ -715,31 +732,39 @@ function originsView(
715732 )
716733 : null}
717734 ${card(
718 html`${tokenSection(values)}
719 <details
720 class="connect-more"
721 ${values.mode !== "none" ? raw("open") : null}
722 >
723 <summary>One-click sign-in</summary>
724 <p class="muted small">
725 Both of these are OAuth, and both need somebody to register an
726 application once — for GitHub, per forge; for Forgejo and Gitea, per
727 instance. Worth it if several people use this forge; a token is
728 faster if it is just you.
729 </p>
730 ${githubSection(githubConfigured, callbackUri(ctx))}
731 ${forgejoSection(
732 ctx,
733 values,
734 matched === undefined
735 ? undefined
736 : {
737 webUrl: matched.webUrl,
738 clientId: matched.clientId,
739 id: matched.id,
740 },
741 )}
742 </details>`,
735 html`<div class="stack">
736 ${tokenSection(values)}

Cards nested in a card inside a fold make three borders at 360px. Try rendering the OAuth paths as plain sections in the fold body, with the h3 and icon but no card chrome, and see whether it reads calmer.

737 ${listCard([
738 row({
739 title: "One-click sign-in",
740 lead: icon("chevronRight"),
741 fold: {
742 id: "connect-oauth",
743 open: values.mode !== "none",
744 body: html`<div class="card-body stack">
745 <p class="muted small">
746 Both of these are OAuth, and both need somebody to register an
747 application once — for GitHub, per forge; for Forgejo and
748 Gitea, per instance. Worth it if several people use this
749 forge; a token is faster if it is just you.
750 </p>
751 ${githubSection(githubConfigured, callbackUri(ctx))}
752 ${forgejoSection(
753 ctx,
754 values,
755 matched === undefined
756 ? undefined
757 : {
758 webUrl: matched.webUrl,
759 clientId: matched.clientId,
760 id: matched.id,
761 },
762 )}
763 </div>`,
764 },
765 }),
766 ])}
767 </div>`,
743768 {
744769 id: "connect",
745770 head: html`${icon("plus")}
@@ -1204,11 +1229,11 @@ function copyBtn(target: string, label: string): Html {
12041229 function handoff(url: string, shortLink: string, openLabel?: string): Html {
12051230 const payload = shortLink === "" ? url : shortLink;
12061231 const code = qrEncode(payload);
1207 return html`<div class="handoff">
1232 return html`<div class="bar mt">
12081233 ${code.ok
1209 ? raw(qrSvg(code.value, { title: "Scan to open the link" }))
1234 ? raw(qrSvg(code.value, { title: "Scan to open the link", scale: 5 }))
12101235 : null}
1211 <div class="handoff-links">
1236 <div class="stack stack-tight">
12121237 ${shortLink === ""
12131238 ? null
12141239 : html`<p class="muted small">Or open this on a phone:</p>
@@ -1216,7 +1241,7 @@ function handoff(url: string, shortLink: string, openLabel?: string): Html {
12161241 <span class="mono" id="flow-short">${shortLink}</span>
12171242 ${copyBtn("flow-short", "Copy the short link")}
12181243 </div>`}
1219 <p class="muted small mt">The full link:</p>
1244 <p class="muted small mt">The full link (select it, or use Copy):</p>
12201245 <div class="bar">
12211246 <span class="mono small break" id="flow-url">${url}</span>
12221247 ${copyBtn("flow-url", "Copy the link")}
src/web/style/content.ts +16 −14
@@ -151,6 +151,21 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
151151 .origin-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
152152 .origin-row .origin-mark .ico { color: var(--muted-fg); }
153153 .origin-name { display: block; font-weight: 560; }
154 <<<<<<< HEAD
155 /* A page's quiet Details: what a person sometimes changes, closed until
156 asked for, the same disclosure as the one above. */
157 .quiet-details > summary {
158 cursor: pointer; font-weight: 560; list-style: none; color: var(--muted-fg);
159 display: flex; align-items: center; gap: 6px; padding: 6px 0; min-height: 44px;
160 }
161 .quiet-details > summary::-webkit-details-marker { display: none; }
162 .quiet-details > summary::before {
163 content: "›"; display: inline-block; color: var(--faint);
164 transition: transform 120ms var(--ease);
165 }
166 .quiet-details[open] > summary::before { transform: rotate(90deg); }
167 .quiet-details > summary:hover { color: var(--accent); }
168 =======
154169 .connect-path + .connect-path { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
155170 /* The two OAuth paths, folded away. Both need somebody to register an
156171 application once, and a page whose first control cannot be used until an
@@ -169,6 +184,7 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
169184 .connect-more[open] > summary::before { transform: rotate(90deg); }
170185 .connect-more > summary:hover { color: var(--accent); }
171186 .connect-more > p { margin: 6px 0 4px; }
187 >>>>>>> origin/main
172188 /* Why an issue closes, beside the button that closes it. */
173189 .form-actions select[name="reason"] { width: auto; }
174190 .form-actions input[name="into"] { display: none; width: 7em; }
@@ -187,9 +203,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
187203 row needs for "Close issue", and the buttons keep their full height. */
188204 .comment-form .form-actions .btn .ico { display: none; }
189205 }
190 .connect-more .connect-path { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
191 .connect-path h3 { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
192 .connect-path h3 .ico { color: var(--muted-fg); }
193206 .steps { margin: 8px 0 12px 18px; padding: 0; color: var(--muted-fg); }
194207 .steps li + li { margin-top: 6px; }
195208 .mirror-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@@ -205,17 +218,6 @@ a.origin-chip:hover { border-color: var(--border-strong); color: var(--fg); }
205218 font-variant-numeric: tabular-nums; letter-spacing: 0.14em;
206219 text-align: center; user-select: all; word-break: break-all;
207220 }
208 /* Handing a connect to another device: a code to scan, a short link to type,
209 the long one to copy. The QR keeps its own white ground in every theme —
210 a scanner reads dark modules on light and refuses the inverse, so this is
211 the one thing on the page the theme does not get a vote on. */
212 .handoff { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin-top: 12px; }
213 .handoff > svg {
214 flex: none; width: 168px; height: 168px;
215 background: var(--qr-ground); border: 1px solid var(--border); border-radius: var(--radius-sm);
216 }
217 .handoff-links { flex: 1 1 16rem; min-width: 0; }
218 .handoff-links .mono { user-select: all; overflow-wrap: anywhere; }
219221 .break { overflow-wrap: anywhere; }
220222 [data-apps] { overflow-wrap: anywhere; }
221223
test/themes.test.ts +2 −2
@@ -30,9 +30,9 @@ describe("bootCss: the ground before the stylesheet arrives (#1240)", () => {
3030 });
3131
3232 describe("fixed tokens: colours every theme shares (#2697)", () => {
33 test("the stylesheet defines each one, and every var(--series-N|qr-ground) it reads is defined", () => {
33 test("the stylesheet defines each one, and every var(--series-N) it reads is defined", () => {
3434 for (const [key, value] of Object.entries(FIXED_TOKENS)) expect(css).toContain(`--${key}: ${value};`);
35 for (const m of css.matchAll(/var\(--((?:series-\d+)|qr-ground)\)/g)) {
35 for (const m of css.matchAll(/var\(--(series-\d+)\)/g)) {
3636 expect(Object.keys(FIXED_TOKENS)).toContain(m[1]!);
3737 }
3838 expect(css).toContain(".fg-s0 { fill: var(--series-0); color: var(--series-0); }");
test/web-origins.test.ts +6
@@ -202,6 +202,9 @@ describe("origins on the web", () => {
202202 html.indexOf("One-click sign-in"),
203203 );
204204 expect(html).toContain("recommended");
205 // Drawn from the design system's components, not page-local classes.
206 for (const gone of ["class=\"connect-path", "class=\"connect-more", "class=\"handoff"])
207 expect(html).not.toContain(gone);
205208 // No GitHub client id is configured yet, so the button is replaced by a
206209 // hint rather than left there to fail.
207210 expect(html).toContain("FORGE_GITHUB_CLIENT_ID");
@@ -476,6 +479,9 @@ describe("origins on the web", () => {
476479 const page = await (await asUser(carol, where)).text();
477480 expect(page).toContain("WXYZ-1234");
478481 expect(page).toContain(ghOauth.verificationUri);
482 expect(page).toContain("Copy the short link");
outdated

"Copy the short link".slice(0, 9) is "Copy the ", which proves almost nothing. Assert the actual copy button label or the short link text, so the test fails if the handoff body is lost.

483 for (const gone of ["class=\"handoff", "class=\"handoff-links"])
484 expect(page).not.toContain(gone);
479485 // The no-JavaScript half is on the page, and says so.
480486 expect(page).toContain("Check again");
481487 expect(page).toContain("Refresh this page to check again");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs