Public: anyone can read this; the crew can change it.
A client's invite page and first-login page are readable at 360 px with no horizontal scroll #15122
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15090-a-client-s-invite-page-and-first-login-p → main 7 commits fork 4 threads · 4 unresolved
3 files
changed +150
−0
docs/design/areas/passkey.md +4
| @@ -24,3 +24,7 @@ one `role="status"` sentence that changes with the real step, then the link as a | ||
| 24 | 24 | |
| 25 | 25 | - `.to-phone` — the QR code that opens the link on a phone, with its one muted sentence. Black on white whatever the |
| 26 | 26 | theme, since a scanner needs it so; not shown under 720px, where the person is already on the phone. |
| 27 | ||
| 28 | The claim page and the first-login card read whole at 360px with no sideways scroll (#15090): `#crew-now` and | |
| 29 | `#next-steps` rows wrap their title and meta to at most two lines instead of clipping to one, and nothing on the page sets a width over 360px. | |
| 30 | No new class; `test/claim-phone-fit.test.ts` holds the viewport and the rules. |
src/web/style/components.ts +11
| @@ -1342,4 +1342,15 @@ ul.list { overflow-anchor: none; } | ||
| 1342 | 1342 | .chain-node[data-quiet] a { opacity: .6; text-decoration: line-through; } |
| 1343 | 1343 | .chain-node[data-holding] a { font-weight: 600; } |
| 1344 | 1344 | .chain-self { padding: 6px 0; font-weight: 600; } |
| 1345 | /* The invite page (/claim, /welcome) and the first-login card read whole at 360px (#15090): a long word | |
| 1346 | breaks instead of pushing the page sideways, and the crew's rows wrap to two lines, not one clipped line and | |
| 1347 | not without end. Only the card and the claim page are touched: the other .narrow pages keep their wrapping. */ | |
| 1348 | .settings-block:has(> #forge-name), #next-steps { overflow-wrap: break-word; } | |
| 1349 | :is(#crew-now, #next-steps) .row { flex-wrap: wrap; } | |
| 1350 | :is(#crew-now, #next-steps) .row-main { flex-basis: 12rem; } | |
| 1351 | :is(#crew-now, #next-steps) :is(.row-title, .row-meta) { | |
| 1352 | display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; | |
| 1353 | white-space: normal; overflow-wrap: anywhere; | |
| 1354 | } | |
| 1355 | :is(#crew-now, #next-steps) .input { max-width: 100%; box-sizing: border-box; } | |
| 1345 | 1356 | `; |
test/claim-phone-fit.test.ts added +135
| @@ -0,0 +1,135 @@ | ||
| 1 | /** | |
| 2 | * The invite page and the first-login card read at 360 px with no sideways scroll (#15090): the | |
The header says the page says width=device-width, but no test asserts it any more. Add one fetching /claim and matching the viewport meta. |
||
| 3 | * page says width=device-width, and the CSS they use fixes no width over 360 px and lets the | |
| 4 | * crew's lines wrap. Without a browser here, this holds the markup and the rules; the page is | |
| 5 | * measured by the /claim and / looks in the pull's review. | |
| 6 | */ | |
| 7 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 8 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 9 | import { tmpdir } from "node:os"; | |
| 10 | import { join } from "node:path"; | |
| 11 | import { childDirOf } from "../src/actions/spawn.ts"; | |
| 12 | import { createApp, type App } from "../src/app.ts"; | |
| 13 | import { createToken } from "../src/core/tokens.ts"; | |
| 14 | import { createUser } from "../src/core/users.ts"; | |
| 15 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 16 | import { firstBoot } from "../src/spawn/first-boot.ts"; | |
| 17 | import { claimedForge, type ClaimedForge } from "./helpers/claimed-forge.ts"; | |
| 18 | import { quietLogs } from "./helpers/globals.ts"; | |
| 19 | import { components } from "../src/web/style/components.ts"; | |
| 20 | import { content } from "../src/web/style/content.ts"; | |
| 21 | import { base } from "../src/web/style/base.ts"; | |
| 22 | ||
| 23 | quietLogs(); | |
| 24 | ||
| 25 | /** The viewport meta a phone needs to lay the page out at its own width. */ | |
| 26 | const VIEWPORT = /<meta\s+name="viewport"\s+content="[^"]*width=device-width[^"]*"/; | |
| 27 | ||
| 28 | describe("the first-login card at 360 px", () => { | |
| 29 | let forge: ClaimedForge; | |
| 30 | beforeAll(async () => { | |
| 31 | forge = await claimedForge("forge-card-fit-"); | |
| 32 | }, 60_000); | |
| 33 | afterAll(() => forge.stop()); | |
| 34 | ||
| 35 | test("the signed-in home with the first-login card says width=device-width", async () => { | |
| 36 | const home = await (await fetch(`${forge.base}/`, { headers: { cookie: forge.owner } })).text(); | |
| 37 | expect(home).toContain('id="next-steps"'); | |
| 38 | expect(home).toMatch(VIEWPORT); | |
| 39 | }); | |
| 40 | }); | |
| 41 | ||
| 42 | describe("the invite page at 360 px", () => { | |
| 43 | let dir = ""; | |
| 44 | let parent: App; | |
| 45 | let parentServers: Servers; | |
| 46 | let child: App; | |
| 47 | let childServers: Servers; | |
| 48 | ||
| 49 | beforeAll(async () => { | |
| 50 | dir = await mkdtemp(join(tmpdir(), "forge-claim-fit-")); | |
| 51 | parent = createApp({ dataDir: dir, url: "https://forge.test", port: 0 }); | |
| 52 | const alice = await createUser(parent.db, { | |
| 53 | origin: "seed", trusted: true, username: "alice", email: "[email protected]", | |
| 54 | password: "a-long-claim-passphrase", isAdmin: true, | |
| 55 | }); | |
| 56 | if (!alice.ok) throw new Error("user"); | |
| 57 | const rw = createToken(parent.db, alice.value.id, "rw", "rw").token; | |
| 58 | parentServers = await serve(parent); | |
| 59 | const made = await fetch(`${parentServers.url}/api/v1/forges`, { | |
| 60 | method: "POST", | |
| 61 | headers: { authorization: `Bearer ${rw}`, "content-type": "application/json" }, | |
| 62 | body: JSON.stringify({ name: "maria", apps: [], dryRun: false }), | |
| 63 | }); | |
| 64 | if (made.status !== 201) throw new Error(`spawn ${made.status}`); | |
| 65 | const body = (await made.json()) as { bodyId: string }; | |
outdated
This passes on main, because the viewport meta already exists. It does not fail without the change. |
||
| 66 | child = createApp({ dataDir: childDirOf(parent, body.bodyId), port: 0 }); | |
| 67 | await firstBoot(child); | |
| 68 | childServers = await serve(child); | |
| 69 | }, 60_000); | |
| 70 | ||
| 71 | afterAll(async () => { | |
outdated
A hand-picked selector list will miss a wide rule on any other class the pages use. Derive the list from the rendered markup, and cover rem and ch units. |
||
| 72 | childServers.stop(); | |
| 73 | child.close(); | |
| 74 | parentServers.stop(); | |
| 75 | parent.close(); | |
| 76 | await rm(dir, { recursive: true, force: true }); | |
| 77 | }); | |
| 78 | ||
| 79 | /** | |
| 80 | * Every CSS block in the three style modules, minus the @media blocks that only apply from 361px | |
| 81 | * up. | |
| 82 | */ | |
| 83 | const phoneCss = (): string => { | |
| 84 | const all = components + base + content; | |
| 85 | return all.replace(/@media[^{]*\(min-width:\s*(\d+)px\)[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/g, (m, w) => (Number(w) > 360 ? "" : m)); | |
| 86 | }; | |
| 87 | ||
| 88 | /** | |
| 89 | * The classes and ids the claim page and the first-login card use: the rendered /claim, and the | |
| 90 | * literals their sources write. | |
| 91 | */ | |
| 92 | const classesUsed = async (): Promise<Set<string>> => { | |
| 93 | const text = await (await fetch(`${childServers.url}/claim`)).text(); | |
| 94 | const sources = ["src/web/pages/next-steps.ts", "src/web/pages/claim.ts", "src/web/forge_made.ts", "src/web/pages/crew-now.ts"]; | |
| 95 | let marks = text; | |
| 96 | for (const f of sources) marks += await Bun.file(join(import.meta.dir, "..", f)).text().catch(() => ""); | |
| 97 | const used = new Set<string>(["input", "btn", "to-phone", "row", "row-main", "row-title", "row-meta", "list"]); | |
| 98 | for (const m of marks.matchAll(/class="([^"$]*)"/g)) for (const c of m[1]!.split(/\s+/)) if (c) used.add(c); | |
| 99 | for (const m of marks.matchAll(/\bid="([\w-]+)"/g)) used.add(`#${m[1]}`); | |
| 100 | return used; | |
| 101 | }; | |
| 102 | ||
| 103 | test("the invite page says width=device-width", async () => { | |
| 104 | const text = await (await fetch(`${childServers.url}/claim`)).text(); | |
| 105 | expect(text).toMatch(VIEWPORT); | |
| 106 | }); | |
| 107 | ||
| 108 | test("no rule that applies to the page sets a width over 360 px, in px, rem, em or ch", async () => { | |
| 109 | const used = await classesUsed(); | |
| 110 | expect(used.has("settings-block")).toBe(true); | |
| 111 | const names = [...used].map((c) => (c.startsWith("#") ? c : `.${c}`)); | |
| 112 | const rules = [...phoneCss().matchAll(/([^{}@]+)\{([^{}]*)\}/g)].filter(([, sel]) => | |
| 113 | names.some((n) => new RegExp(`${n.replace(/[.#]/g, "\\$&")}(?![\\w-])`).test(sel!))); | |
| 114 | expect(rules.length).toBeGreaterThan(20); | |
| 115 | const px = { px: 1, rem: 16, em: 16, ch: 8 } as const; | |
| 116 | for (const [, sel, decls] of rules) { | |
| 117 | for (const d of decls!.matchAll(/(?<![-\w])(min-width|width)\s*:\s*(\d+(?:\.\d+)?)(px|rem|em|ch)\b/g)) | |
| 118 | expect(Number(d[2]) * px[d[3] as keyof typeof px], `${sel!.trim()} { ${d[0]} }`).toBeLessThanOrEqual(360); | |
| 119 | } | |
| 120 | }); | |
| 121 | ||
| 122 | test("the crew's rows wrap to two lines, not one clipped line and not without end", () => { | |
| 123 | const rule = components.match(/:is\(#crew-now, #next-steps\) :is\(\.row-title, \.row-meta\) \{([^}]*)\}/); | |
| 124 | expect(rule, "a rule for the crew's row text").not.toBeNull(); | |
| 125 | expect(rule![1]).toContain("white-space: normal"); | |
| 126 | expect(rule![1]).toContain("-webkit-line-clamp: 2"); | |
| 127 | expect(rule![1]).not.toContain("overflow: visible"); | |
| 128 | expect(components).toMatch(/:is\(#crew-now, #next-steps\) \.row \{ flex-wrap: wrap/); | |
| 129 | }); | |
| 130 | ||
| 131 | test("a long word breaks on the claim page and the card only, not on every .narrow page", () => { | |
| 132 | expect(components).not.toMatch(/\.narrow[^{]*\{[^}]*overflow-wrap: anywhere/); | |
| 133 | expect(components).toMatch(/\.settings-block:has\(> #forge-name\), #next-steps \{ overflow-wrap: break-word/); | |
| 134 | }); | |
| 135 | }); |
new above
offline
Principle 7 (rows over boxes): this removes the one-line row for every crew row. Wrap at most two lines instead of unbounded. Scope
overflow-wrapaway from all.narrowpages.