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

The signed-out home scrolls sideways on a phone: 403 px wide in a 390 px window #13232

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/13230-the-signed-out-home-scrolls-sideways-on → main 6 commits fork

  • Merged. torque/13230-the-signed-out-home-scrolls-sideways-on was merged into main as c86bac8.

Review

Sign in to review this change.
3 files changed +77 −6
src/web/studio/home.ts +10 −5
@@ -2,8 +2,8 @@
22 * The home in the studio: signed in, the feed — the composer, then one
33 * timeline — with your apps and what is on you beside it (#599). Built from
44 * the same cards as the rest of the forge, from grouped reads only, so the
5 * page does not get slower as the apps grow. A stranger gets the door instead: the forge featured, then the
6 * best of what is public (`actions/front.ts`).
5 * page does not get slower as the apps grow. A stranger gets the door instead: the forge featured,
6 * then the best of what is public (`actions/front.ts`).
77 */
88
99 import { UPSTREAM_REPO } from "../../core/upstream.ts";
@@ -483,7 +483,9 @@ function frontControls(ctx: Ctx, front: FrontPage): Html {
483483 );
484484 }
485485
486 /** How many apps the door shows: the pins, then the best of the rest, with a link to all of them. */
486 /**
487 * How many apps the door shows: the pins, then the best of the rest, with a link to all of them.
488 */
487489 const DOOR_TILES = 8;
488490
489491 /** The live address of an app a stranger may open, or nothing. */
@@ -500,7 +502,10 @@ const DOOR_STATE: Partial<Record<EnvState, string>> = {
500502 deploying: "Updating",
501503 };
502504
503 /** What a stranger can do to help with an app: make an account if this forge takes new ones, or send its keepers a note. */
505 /**
506 * What a stranger can do to help with an app: make an account if this forge takes new ones, or send
507 * its keepers a note.
508 */
504509 function helpDoor(repo: FrontEntry["repo"], accounts: boolean): Html {
505510 return accounts
506511 ? html`<a href="/signup?next=${encodeURIComponent(repoBase(repo))}">Help build</a>`
@@ -840,7 +845,7 @@ bun run src/main.ts</code></pre>
840845 ...(visitor
841846 ? {
842847 tools: html`<a class="small door-wide" href="#made">Made here</a>
843 <a class="small" href="/pricing">Pricing</a>
848 <a class="small door-wide" href="/pricing">Pricing</a>
844849 <a class="small door-wide" href="${FORGE_REPO}">Code</a>
845850 ${signup
846851 ? html`<a class="small" href="/signin${nextQuery}">Sign in</a>
test/home-signedout-fit.test.ts added +66
@@ -0,0 +1,66 @@
1 /**
2 * The signed-out home fits a 390 px phone (#13230): its top bar held the
3 * wordmark, Pricing, Sign in and a nowrap "Create an account" button, 403 px
4 * of fixed-size items in a 390 px window. Pricing now leaves the bar below
5 * 560 px (the page's own plans section carries it), and in a real Chromium
6 * the page does not scroll sideways.
7 */
8 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
9 import { mkdtemp, rm } from "node:fs/promises";
10 import { tmpdir } from "node:os";
11 import { join } from "node:path";
12 import { createApp, type App } from "../src/app.ts";
13 import { serve, type Servers } from "../src/http/server.ts";
14 import { content } from "../src/web/style/content.ts";
15 import { findChromium } from "../src/looks/capture.ts";
16 import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts";
17
18 let dir: string;
19 let app: App;
20 let servers: Servers;
21 let page: string;
22
23 beforeAll(async () => {
24 dir = await mkdtemp(join(tmpdir(), "forge-home-out-fit-"));
25 app = createApp({ dataDir: dir, port: 0 });
26 servers = await serve(app);
27 page = await (await fetch(`${servers.url}/?as=signedout`)).text();
28 }, 60_000);
29 afterAll(async () => {
30 servers.stop();
31 app.close();
32 await rm(dir, { recursive: true, force: true });
33 });
34
35 describe("the signed-out home's top bar at 390 px", () => {
36 test("only Sign in and Create an account stay in the bar on a phone", () => {
37 const bar = page.match(/<span class="topbar-tools">[\s\S]*?<\/span>/)?.[0] ?? "";
38 expect(bar).toContain("Sign in");
39 expect(bar).toContain("Create an account");
40 expect(bar).toMatch(/class="small door-wide" href="\/pricing"/);
41 expect(bar).toMatch(/class="small door-wide" href="#made"/);
42 });
43
44 test("the rule that hides the wide-only links on a phone exists", () => {
45 expect(content).toMatch(/@media \(max-width: 559px\)\s*\{\s*\.door-wide\s*\{\s*display:\s*none/);
46 });
47 });
48
49 const found = findChromium();
50 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
51 if (chromium === undefined) console.log("SKIPPING: no chromium that starts on this machine, so the signed-out phone look is not measured");
52
53 describe.skipIf(chromium === undefined)("the signed-out home, measured at 390x844", () => {
54 test("no sideways scroll", async () => {
55 const measure = `(() => {
56 const vw = document.documentElement.clientWidth;
57 const overflowing = [...document.querySelectorAll("body *")].filter((el) => el.getBoundingClientRect().right > vw + 1).slice(0, 8).map((el) => el.tagName.toLowerCase() + "." + el.className);
58 return JSON.stringify({ scrollWidth: document.documentElement.scrollWidth, viewportWidth: vw, overflowing });
59 })()`;
60 const m = JSON.parse(await evaluateLoaded(chromium!, `${servers.url}/?as=signedout`, { width: 390, height: 844 }, [], measure)) as { scrollWidth: number; viewportWidth: number; overflowing: string[] };
61 console.log(`signed-out home 390x844: ${JSON.stringify(m)}`);
62 // The page itself must not scroll sideways; elements clipped or scrolled inside their own box
63 // may reach past the edge.
64 expect(m.scrollWidth, `overflowing: ${m.overflowing.join(", ")}`).toBeLessThanOrEqual(m.viewportWidth);
65 }, 30_000);
66 });
test/web-ui.test.ts +1 −1
@@ -474,7 +474,7 @@ describe("web ui", () => {
474474
475475 test("the signed-out home links to /pricing in the top bar", async () => {
476476 const out = await (await fetch(`${base}/`)).text();
477 expect(out).toContain('<a class="small" href="/pricing">Pricing</a>');
477 expect(out).toContain('<a class="small door-wide" href="/pricing">Pricing</a>');
478478 });
479479
480480 test("a 404 offers a search for what was asked, and a stranger an account", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs