Public: anyone can read this; the crew can change it.
/new-forge fits 360 px with the keyboard up: the name field and the button stay in view #13019
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13005-new-forge-fits-360-px-with-the-keyboard → main 10 commits fork 2 threads · 2 unresolved
6 files
changed +122
−29
docs/design/areas/forms.md +1
| @@ -4,6 +4,7 @@ A form's fields and its buttons sit in two rows, one for what you fill in and on | ||
| 4 | 4 | |
| 5 | 5 | - `.field-row` — a row of `.field`s side by side that wraps on a narrow screen, each at least 160px wide and aligned to the bottom so a labelled input and the button beside it share a baseline. Styled in `style/components.ts`; written by `createForm` in `pages/branches.ts` (the new-branch form), the graph filter in `pages/fleet-graph.ts` and the freeze form in `pages/frozen.ts`. The new-pull form stacks Base and Compare as plain `.field`s, one column at any width. |
| 6 | 6 | - `.form-actions` — the row of a form's buttons under its fields: 16px above, 8px apart, wrapping. Styled in `style/components.ts`, and in `style/content.ts` for a thread's close reason and "close into" input and for `.comment-form` on a narrow screen; written by nearly every form in `src/web/pages/` (`account.ts`, `settings.ts`, `crew.ts`, `edit.ts`, `issues.ts`, `pulls.ts`, `oauth.ts`, `teams.ts`, `chain.ts`, `everyday.ts`) and by the review comment form in `diff-view.ts`; `client.ts` finds its `.muted` note to report a save. |
| 7 | - `.form-actions[data-stick]` — on a screen up to 640px the row sticks to the bottom edge (opaque `--bg`, 8px padding) so a long form's submit stays in view with the keyboard up; `/forges/new` sets it (#13005). | |
| 7 | 8 | |
| 8 | 9 | - The gate break-glass (#7790) on the pull's Files step is a plain `field()` with a hint and a `.form-actions` row holding one `btn` in the `danger` variant; no new class. It sits under the disabled primary Merge button, so the page keeps one accent. |
| 9 | 10 |
docs/design/size-budget.json +11 −11
| @@ -1,31 +1,31 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "/": { |
| 3 | 3 | "js": 21504, |
| 4 | "css": 43520 | |
| 4 | "css": 44544 | |
| 5 | 5 | }, |
| 6 | 6 | "/explore": { |
| 7 | 7 | "js": 21248, |
| 8 | "css": 43520 | |
| 8 | "css": 44544 | |
| 9 | 9 | }, |
| 10 | 10 | "/map": { |
| 11 | 11 | "js": 28160, |
| 12 | "css": 45056 | |
| 12 | "css": 46080 | |
| 13 | 13 | }, |
| 14 | 14 | "/:owner/:name": { |
| 15 | 15 | "js": 35072, |
| 16 | "css": 43520 | |
| 16 | "css": 44544 | |
| 17 | 17 | }, |
| 18 | 18 | "/changelog": { |
| 19 | 19 | "js": 26112, |
| 20 | "css": 43520 | |
| 20 | "css": 44544 | |
| 21 | 21 | }, |
| 22 | 22 | "/:owner/:name/next": { |
| 23 | 23 | "js": 23040, |
| 24 | "css": 44032 | |
| 24 | "css": 44800 | |
| 25 | 25 | }, |
| 26 | 26 | "/:owner/:name/space": { |
| 27 | "js": 28928, | |
| 28 | "css": 44800 | |
| 27 | "js": 29440, | |
| 28 | "css": 45568 | |
| 29 | 29 | }, |
| 30 | 30 | "/:owner/:name/space.json": { |
| 31 | 31 | "js": 0, |
| @@ -33,14 +33,14 @@ | ||
| 33 | 33 | }, |
| 34 | 34 | "/pricing": { |
| 35 | 35 | "js": 21248, |
| 36 | "css": 43520 | |
| 36 | "css": 44544 | |
| 37 | 37 | }, |
| 38 | 38 | "/forges/new": { |
| 39 | 39 | "js": 21248, |
| 40 | "css": 43520 | |
| 40 | "css": 44544 | |
| 41 | 41 | }, |
| 42 | 42 | "/claim": { |
| 43 | 43 | "js": 23808, |
| 44 | "css": 43520 | |
| 44 | "css": 44544 | |
| 45 | 45 | } |
| 46 | 46 | } |
src/web/layout.ts +23 −7
| @@ -101,6 +101,8 @@ export interface PageOptions { | ||
| 101 | 101 | */ |
| 102 | 102 | flash?: Flash; |
| 103 | 103 | title: string; |
| 104 | /** A form with a sticky submit row: the layout shrinks with the on-screen keyboard (#13005). */ | |
| 105 | keyboardResizes?: boolean; | |
| 104 | 106 | /** |
| 105 | 107 | * One sentence for the places that show a page before it is opened: a |
| 106 | 108 | * search result, a link unfurled in a chat. A repository's description, |
| @@ -222,7 +224,10 @@ export interface PageOptions { | ||
| 222 | 224 | |
| 223 | 225 | // ---- topbar pieces ---- |
| 224 | 226 | |
| 225 | /** The theme a mode button sends: the viewer's own named theme while it is of that mode, else the default of the pair. */ | |
| 227 | /** | |
| 228 | * The theme a mode button sends: the viewer's own named theme while it is of that mode, else the | |
| 229 | * default of the pair. | |
| 230 | */ | |
| 226 | 231 | const modeTheme = (mode: "light" | "dark", active: ThemeName | undefined): ThemeName => |
| 227 | 232 | active !== undefined && THEMES[active].appearance === mode ? active : mode; |
| 228 | 233 | |
| @@ -413,10 +418,15 @@ const STATIC_PALETTE: PaletteItem[] = [ | ||
| 413 | 418 | { t: "Your shells", h: "/settings/shells", c: "Settings" }, |
| 414 | 419 | ]; |
| 415 | 420 | |
| 416 | /** What a signed-out visitor can reach: places to go, not Create and Settings rows that end at a sign-in wall. */ | |
| 421 | /** | |
| 422 | * What a signed-out visitor can reach: places to go, not Create and Settings rows that end at a | |
| 423 | * sign-in wall. | |
| 424 | */ | |
| 417 | 425 | const VISITOR_PALETTE = new Set(goPaletteRows().filter((r) => r.visitor).map((r) => r.t)); |
| 418 | 426 | |
| 419 | /** First path segments that are the forge's own pages, never an owner: no repository read for them. */ | |
| 427 | /** | |
| 428 | * First path segments that are the forge's own pages, never an owner: no repository read for them. | |
| 429 | */ | |
| 420 | 430 | const NOT_AN_OWNER = new Set([ |
| 421 | 431 | ...STATIC_PALETTE.map((p) => p.h.split("/")[1] ?? ""), |
| 422 | 432 | "api", "releases", "audit", "admin", "tell", "login", "logout", "signup", "feed", "boards", "organizations", "static", "assets", |
| @@ -529,7 +539,8 @@ function paletteIndex(ctx: Ctx, extra: PaletteItem[]): Html { | ||
| 529 | 539 | }), |
| 530 | 540 | }; |
| 531 | 541 | }), |
| 532 | // A "Go to" row is the viewer's own: an admin's page is not listed to anyone else (it would end at a 403 or a 404). | |
| 542 | // A "Go to" row is the viewer's own: an admin's page is not listed to anyone else (it would end | |
| 543 | // at a 403 or a 404). | |
| 533 | 544 | ...(ctx.auth.user |
| 534 | 545 | ? STATIC_PALETTE.filter((p) => { |
| 535 | 546 | const row = GO_ROWS.find((r) => r.t === p.t && r.h === p.h); |
| @@ -631,7 +642,9 @@ function flashToast(flash: Flash): Html { | ||
| 631 | 642 | |
| 632 | 643 | // ---- the chrome ---- |
| 633 | 644 | |
| 634 | /** Where a signed-out visitor's way in leads: the topbar button and the palette's Sign in share it. */ | |
| 645 | /** | |
| 646 | * Where a signed-out visitor's way in leads: the topbar button and the palette's Sign in share it. | |
| 647 | */ | |
| 635 | 648 | export function signInHref(ctx: Ctx): string { |
| 636 | 649 | const token = activeEdgeToken(ctx.app); |
| 637 | 650 | if (edgeStrangerLogin(ctx.request, token, ctx.auth.user) !== undefined) return "/signup"; |
| @@ -653,7 +666,10 @@ export function signUpHref(ctx: Ctx): string | undefined { | ||
| 653 | 666 | return mode === "open" || mode === "request" ? withReturn("/signup", returnTo(ctx)) : "/"; |
| 654 | 667 | } |
| 655 | 668 | |
| 656 | /** The Talk button; the count of confirms waiting on the viewer's yes is asked only here, where the button renders. */ | |
| 669 | /** | |
| 670 | * The Talk button; the count of confirms waiting on the viewer's yes is asked only here, where the | |
| 671 | * button renders. | |
| 672 | */ | |
| 657 | 673 | function talkButton(ctx: Ctx, user: User, about?: string): Html { |
| 658 | 674 | const waiting = waitingCount(ctx, user); |
| 659 | 675 | const label = waiting > 0 ? `Talk to the forge, ${waiting} waiting` : "Talk to the forge"; |
| @@ -808,7 +824,7 @@ export function page(options: PageOptions, status = 200): Response { | ||
| 808 | 824 | <meta charset="utf-8" /> |
| 809 | 825 | <meta |
| 810 | 826 | name="viewport" |
| 811 | content="width=device-width, initial-scale=1" | |
| 827 | content="width=device-width, initial-scale=1${options.keyboardResizes ? ", interactive-widget=resizes-content" : ""}" | |
| 812 | 828 | /> |
| 813 | 829 | <title>${tabTitle(options.title)}</title> |
| 814 | 830 | <meta name="description" content="${pageDescription(options)}" /> |
src/web/pages/new-forge.ts +31 −11
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /** |
| 2 | 2 | * `/forges/new`: "+ New forge" (#426), the page a signed-in person spawns a |
| 3 | * child from (they claim it and become its admin). It is the same door as `POST /api/v1/forges` and the MCP | |
| 4 | * `spawn` (`spawn/door.ts`), as one form that works without JavaScript. | |
| 3 | * child from (they claim it and become its admin). It is the same door as `POST /api/v1/forges` and | |
| 4 | * the MCP `spawn` (`spawn/door.ts`), as one form that works without JavaScript. | |
| 5 | 5 | * |
| 6 | 6 | * The path: the owner wants to send someone a forge; from the "+" menu he |
| 7 | 7 | * fills in a name and ticks the apps, presses **See the plan** (nothing is |
| @@ -94,7 +94,10 @@ function errorsOf(door: Door): Errors { | ||
| 94 | 94 | return { form: plainError(message) }; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | /** What the form reads before it draws: room, then (when there is room) the repositories and the crew. */ | |
| 97 | /** | |
| 98 | * What the form reads before it draws: room, then (when there is room) the repositories and the | |
| 99 | * crew. | |
| 100 | */ | |
| 98 | 101 | interface Reads { |
| 99 | 102 | readonly full: string | undefined; |
| 100 | 103 | /** Why even a small forge would pass the host's child quota; the form still draws. */ |
| @@ -138,7 +141,9 @@ function sizeOptions(chosen: string): { value: string; label: string; selected?: | ||
| 138 | 141 | })); |
| 139 | 142 | } |
| 140 | 143 | |
| 141 | /** The templates in order, Blank first; the one asked for chosen (Blank when it is not one of them). */ | |
| 144 | /** | |
| 145 | * The templates in order, Blank first; the one asked for chosen (Blank when it is not one of them). | |
| 146 | */ | |
| 142 | 147 | function templateOptions(chosen: string, repos: readonly string[]): { value: string; label: string; selected?: boolean }[] { |
| 143 | 148 | const known = TEMPLATES.some((t) => t.id === chosen) || repos.includes(chosen); |
| 144 | 149 | const at = known ? chosen : DEFAULT_TEMPLATE; |
| @@ -181,7 +186,10 @@ function freshError(errors: Errors, repoCount: number): string | undefined { | ||
| 181 | 186 | return errors["fresh"] ?? (repoCount === 0 ? errors["apps"] : undefined); |
| 182 | 187 | } |
| 183 | 188 | |
| 184 | /** The line under the heading: the crew starts on the included credit when there is one, else on the person's AI account. */ | |
| 189 | /** | |
| 190 | * The line under the heading: the crew starts on the included credit when there is one, else on the | |
| 191 | * person's AI account. | |
| 192 | */ | |
| 185 | 193 | function hostingTerms(includedUsd: number): string { |
| 186 | 194 | const crew = |
| 187 | 195 | includedUsd > 0 |
| @@ -220,7 +228,6 @@ function formView( | ||
| 220 | 228 | // /forges answers only an admin; to anyone else the link would lead to a 404. |
| 221 | 229 | actions: ctx.auth.user?.isAdmin ? sentLink() : undefined, |
| 222 | 230 | })} |
| 223 | <p class="muted small" id="hosting-terms">${hostingTerms(includedUsd)}</p> | |
| 224 | 231 | ${quota ? html`<p role="status" id="quota-full">This forge has no room for another forge: ${quota}.</p>` : null} |
| 225 | 232 | ${errors["form"] |
| 226 | 233 | ? html`<p class="error mb" role="alert">${errors["form"]}</p>` |
| @@ -383,7 +390,7 @@ function formView( | ||
| 383 | 390 | </p> |
| 384 | 391 | </details> |
| 385 | 392 | ${codeField(values.code, errors["code"])} |
| 386 | <div class="form-actions"> | |
| 393 | <div class="form-actions" data-stick> | |
| 387 | 394 | <button class="btn" type="submit" name="do" value="plan"> |
| 388 | 395 | See the plan |
| 389 | 396 | </button> |
| @@ -391,6 +398,7 @@ function formView( | ||
| 391 | 398 | </div> |
| 392 | 399 | </form> |
| 393 | 400 | </section> |
| 401 | <p class="muted small" id="hosting-terms">${hostingTerms(includedUsd)}</p> | |
| 394 | 402 | </div>`; |
| 395 | 403 | } |
| 396 | 404 | |
| @@ -449,12 +457,17 @@ function giftLine(g: unknown): Html | null { | ||
| 449 | 457 | return typeof gift?.plan === "string" ? html`<li><b>${giftWords({ plan: gift.plan })}</b></li>` : null; |
| 450 | 458 | } |
| 451 | 459 | |
| 452 | /** The way to the list of forges sent; /forges answers only an admin, so only an admin is shown it. */ | |
| 460 | /** | |
| 461 | * The way to the list of forges sent; /forges answers only an admin, so only an admin is shown it. | |
| 462 | */ | |
| 453 | 463 | function sentLink(): Html { |
| 454 | 464 | return btn("Forges you sent", { href: "/forges", size: "sm" }); |
| 455 | 465 | } |
| 456 | 466 | |
| 457 | /** A link on its own (made again, or paid for): what to do with it, the link, and for an admin the way back to the list. */ | |
| 467 | /** | |
| 468 | * A link on its own (made again, or paid for): what to do with it, the link, and for an admin the | |
| 469 | * way back to the list. | |
| 470 | */ | |
| 458 | 471 | export function claimLinkBody(link: string, isAdmin: boolean): Html { |
| 459 | 472 | return linkToSend(link, isAdmin ? html`<p>${sentLink()}</p>` : null); |
| 460 | 473 | } |
| @@ -493,7 +506,8 @@ export function newForgePage(ctx: Ctx): Response { | ||
| 493 | 506 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 494 | 507 | const reads = readsFor(ctx, user); |
| 495 | 508 | const rendering = performance.now(); |
| 496 | // A code in the address moves to a cookie and out of the address (the log and history never hold it). | |
| 509 | // A code in the address moves to a cookie and out of the address (the log and history never hold | |
| 510 | // it). | |
| 497 | 511 | const inUrl = ctx.url.searchParams.get("code"); |
| 498 | 512 | if (inUrl !== null && inUrl !== "") return keepGift(inUrl.slice(0, 64), "/forges/new", ctx.url, ctx.app.config.url); |
| 499 | 513 | // A link with a code arrives filled in, and says it is a gift, or plainly why not. |
| @@ -504,6 +518,7 @@ export function newForgePage(ctx: Ctx): Response { | ||
| 504 | 518 | const response = page({ |
| 505 | 519 | ctx, |
| 506 | 520 | title: "New forge", |
| 521 | keyboardResizes: true, | |
| 507 | 522 | body: formView(ctx, user, { ...EMPTY, code, name: (ctx.url.searchParams.get("name") ?? "").slice(0, 38), ...fromPack(ctx, user) }, errors, gift, reads), |
| 508 | 523 | }); |
| 509 | 524 | notePhase(ctx.request, "render", performance.now() - rendering); |
| @@ -558,6 +573,7 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> { | ||
| 558 | 573 | { |
| 559 | 574 | ctx, |
| 560 | 575 | title: "New forge", |
| 576 | keyboardResizes: true, | |
| 561 | 577 | body: formView(ctx, user, values, errorsOf(door), null, readsFor(ctx, user)), |
| 562 | 578 | }, |
| 563 | 579 | door.status === 422 ? 422 : door.status, |
| @@ -566,6 +582,7 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> { | ||
| 566 | 582 | return page({ |
| 567 | 583 | ctx, |
| 568 | 584 | title: "New forge", |
| 585 | keyboardResizes: true, | |
| 569 | 586 | body: formView(ctx, user, values, {}, planView(ctx, user, values, door.body), readsFor(ctx, user)), |
| 570 | 587 | }); |
| 571 | 588 | noteForgeMade(ctx); |
| @@ -591,7 +608,10 @@ export async function newForgeSubmit(ctx: Ctx): Promise<Response> { | ||
| 591 | 608 | return response; |
| 592 | 609 | } |
| 593 | 610 | |
| 594 | /** The code is asked for only when one is in play: filled in from a link, or behind a quiet disclosure that needs no script. */ | |
| 611 | /** | |
| 612 | * The code is asked for only when one is in play: filled in from a link, or behind a quiet | |
| 613 | * disclosure that needs no script. | |
| 614 | */ | |
| 595 | 615 | function codeField(value: string, error: string | undefined): Html { |
| 596 | 616 | const input = formField({ label: "Gift code", name: "code", value, autocomplete: "off", ...(error ? { error } : {}) }); |
| 597 | 617 | if (value !== "" || error) return input; |
src/web/style/components.ts +5
| @@ -165,6 +165,11 @@ fieldset.field > .check + .check { margin-top: 8px; } | ||
| 165 | 165 | .field-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; } |
| 166 | 166 | .field-row .field { flex: 1; min-width: 160px; margin-bottom: 0; } |
| 167 | 167 | .form-actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } |
| 168 | /* A long form's buttons stay in reach on a phone, with the keyboard up (#13005). */ | |
| 169 | @media (max-width: 640px) { | |
| 170 | .form-actions[data-stick] { position: sticky; bottom: 0; padding: 8px 0; margin-bottom: 0; background: var(--bg); } | |
| 171 | form:has(.form-actions[data-stick]) .input { min-width: 0; max-width: 100%; } | |
| 172 | } | |
| 168 | 173 | |
| 169 | 174 | /* ---- stat tile ---- fixed heights: a changing value shifts nothing */ |
| 170 | 175 | .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; } |
test/new-forge-phone.test.ts added +51
| @@ -0,0 +1,51 @@ | ||
| 1 | /** | |
| 2 | * /forges/new on a 360px phone with the keyboard up (#13005): the submit row sticks, | |
| 3 | * and the name field leads the form. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 11 | import { css } from "../src/web/style.ts"; | |
| 12 | ||
| 13 | let dir = ""; | |
| 14 | let app: App; | |
| 15 | let servers: Servers; | |
| 16 | ||
| 17 | beforeAll(async () => { | |
| 18 | dir = await mkdtemp(join(tmpdir(), "forge-new-forge-phone-")); | |
| 19 | app = createApp({ dataDir: dir, url: "https://forge.test", port: 0 }); | |
| 20 | servers = await serve(app); | |
| 21 | }); | |
| 22 | afterAll(async () => { | |
| 23 | servers.stop(); | |
| 24 | app.close(); | |
| 25 | await rm(dir, { recursive: true, force: true }); | |
| 26 | }); | |
| 27 | ||
| 28 | test("the buttons row is marked to stick and the name field comes first", async () => { | |
| 29 | const page = await (await fetch(`${servers.url}/forges/new`)).text(); | |
| 30 | const form = /<form[^>]*id="new-forge"[\s\S]*?<\/form>/.exec(page)?.[0] ?? ""; | |
| 31 | expect(form).toMatch(/<div class="form-actions" data-stick>/); | |
| 32 | expect(form.indexOf('name="name"')).toBeGreaterThan(-1); | |
| 33 | expect(form.indexOf('name="name"')).toBeLessThan(form.indexOf('name="direction"')); | |
This checks the name precedes direction, but the issue asks for the name in view: the lead line and hosting-terms paragraph sit above it. Assert the name is the first field after the heading and move the terms below the form. |
||
| 34 | expect(form).toContain("autofocus"); | |
| 35 | // The name is the first field after the heading, and the hosting terms sit below the form. | |
| 36 | const body = page.slice(page.indexOf("<h1")); | |
| 37 | expect(/<(?:input|textarea|select)\b[^>]*\bname="([^"]*)"/.exec(body)?.[1]).toBe("name"); | |
| 38 | expect(body.indexOf('name="name"')).toBeLessThan(body.indexOf('id="hosting-terms"')); | |
| 39 | expect(page.indexOf("</form>")).toBeLessThan(page.indexOf('id="hosting-terms"')); | |
| 40 | }); | |
| 41 | ||
| 42 | test("the viewport resizes with the keyboard, so the bottom edge moves up with it", async () => { | |
| 43 | const page = await (await fetch(`${servers.url}/forges/new`)).text(); | |
| 44 | expect(page).toMatch(/<meta\s+name="viewport"\s+content="[^"]*interactive-widget=resizes-content/); | |
| 45 | }); | |
| 46 | ||
| 47 | test("a narrow screen pins the marked row to the bottom, opaque, and keeps inputs inside", () => { | |
| 48 | const sheet = typeof css === "string" ? css : [...css].join("\n"); | |
| 49 | expect(sheet).toMatch(/max-width: 640px\)\s*\{\s*\.form-actions\[data-stick\]\s*\{[^}]*position: sticky;[^}]*bottom: 0;[^}]*background: var\(--bg\)/); | |
| 50 | expect(sheet).toContain("max-width: 100%"); | |
| 51 | }); |
new above
offline
Sticky bottom:0 follows the layout viewport, so with an iOS keyboard open the row may still sit under it. Pair with interactive-widget=resizes-content in the viewport meta or verify at 360x640 and say how.