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

Home tiles on a phone: thumbnails are 200×125 corner crops upscaled 1.8×, status badge stretches full width, hero CTA touches the grid #10038

Closed opened this in answer to
Closed without merging

scout/forge:scout/473-home-tiles-on-a-phone-thumbnails-are-200 → main 3 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
8 files changed +59 −12
src/core/looks.ts +17 −3
@@ -16,15 +16,29 @@ export const isLookKind = (value: string): value is LookKind =>
1616
1717 /**
1818 * The three widths, as a person holds them: a phone, a laptop's window, and
19 * a thumbnail — taken at the size a slot actually shows, at desktop's own
20 * aspect, rather than a full picture squeezed into a small box.
19 * a thumbnail — the picture's own pixel size. The window each is taken in
20 * is `LOOK_VIEWPORTS`.
2121 */
2222 export const LOOK_SIZES: Readonly<
2323 Record<LookKind, { readonly width: number; readonly height: number }>
2424 > = {
2525 phone: { width: 390, height: 844 },
2626 desktop: { width: 1280, height: 800 },
27 thumb: { width: 200, height: 125 },
27 thumb: { width: 640, height: 400 },
28 };
29
30 /**
31 * The window each picture is taken in, and the scale it is written at. A
32 * thumb is the whole desktop window drawn at half size — 1280×800 seen at
33 * 0.5 is 640×400 — not a corner of it, so a tile shows the page, and its 2×
34 * is the desktop picture itself.
35 */
36 export const LOOK_VIEWPORTS: Readonly<
37 Record<LookKind, { readonly width: number; readonly height: number; readonly scale: number }>
38 > = {
39 phone: { width: 390, height: 844, scale: 1 },
40 desktop: { width: 1280, height: 800, scale: 1 },
41 thumb: { width: 1280, height: 800, scale: 0.5 },
2842 };
2943
3044 /** A look with no page recorded — every row before `app.looks` existed. */
src/looks/capture.ts +3 −1
@@ -46,6 +46,8 @@ export interface LookInput {
4646 readonly out: string;
4747 readonly width: number;
4848 readonly height: number;
49 /** Device scale factor: 0.5 writes the window at half size. */
50 readonly scale?: number | undefined;
4951 /** A browser that has no picture by then is killed; the look fails. */
5052 readonly timeoutMs: number;
5153 }
@@ -141,7 +143,7 @@ async function shoot(
141143 // The app's hostname is the forge's own listener: no DNS, no edge.
142144 `--host-resolver-rules=MAP ${host} 127.0.0.1`,
143145 `--window-size=${input.width},${input.height}`,
144 "--force-device-scale-factor=1",
146 `--force-device-scale-factor=${input.scale ?? 1}`,
145147 "--js-flags=--max-old-space-size=256",
146148 `--timeout=${LOAD_MS}`,
147149 `--screenshot=${input.out}`,
src/looks/service.ts +2 −2
@@ -34,7 +34,7 @@ import {
3434 deleteLooks,
3535 DEFAULT_PAGE,
3636 LOOK_KINDS,
37 LOOK_SIZES,
37 LOOK_VIEWPORTS,
3838 lookSlot,
3939 looksForEnv,
4040 recordLook,
@@ -319,7 +319,7 @@ export function startLooks(app: App, options: LooksOptions): LooksHandle {
319319 const taken = await capture({
320320 url,
321321 out: staged,
322 ...LOOK_SIZES[kind],
322 ...LOOK_VIEWPORTS[kind],
323323 timeoutMs: CAPTURE_TIMEOUT_MS,
324324 });
325325 const row = {
src/web/studio/home.ts +8
@@ -227,11 +227,19 @@ export function studioDoor(ctx: Ctx): Response {
227227 );
228228 const look = pictured(ofApp, "thumb") ?? pictured(ofApp, "desktop");
229229 const base = repoBase(repo);
230 // The thumb is half the desktop picture; the desktop one is its 2×.
231 const sharp =
232 look?.kind === "thumb" ? pictured(ofApp, "desktop") : undefined;
233 const srcset =
234 look !== undefined && sharp !== undefined
235 ? `${lookUrl(base, "production", look.commitOid, DEFAULT_PAGE, "thumb")} 1x, ${lookUrl(base, "production", sharp.commitOid, DEFAULT_PAGE, "desktop")} 2x`
236 : undefined;
230237 return html`<a class="app-tile" href="${base}">
231238 ${look
232239 ? html`<img
233240 class="app-tile-look"
234241 src="${lookUrl(base, "production", look.commitOid, DEFAULT_PAGE, look.kind)}"
242 ${srcset === undefined ? null : html`srcset="${srcset}"`}
235243 width="${LOOK_SIZES[look.kind].width}"
236244 height="${LOOK_SIZES[look.kind].height}"
237245 alt=""
src/web/style/content.ts +3 −2
@@ -363,7 +363,7 @@ form.inline { display: inline; margin-left: auto; }
363363 .lineage .row[aria-current="page"] { background: var(--muted); }
364364 @media (max-width: 719px) { .lineage-children { margin-left: 12px; } }
365365
366 .hero { max-width: 620px; margin: 12dvh auto 0; text-align: center; }
366 .hero { max-width: 620px; margin: 12dvh auto 32px; text-align: center; }
367367 .hero h1 { font-size: clamp(30px, 7vw, 44px); letter-spacing: -0.04em; line-height: 1.05; }
368368 .hero p { margin: 12px 0 24px; font-size: 16px; color: var(--muted-fg); text-wrap: pretty; }
369369 .hero-terminal { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 6px 14px; margin: -8px 0 28px; font-size: 14px; }
@@ -381,12 +381,13 @@ form.inline { display: inline; margin-left: auto; }
381381 overflow: hidden; background: var(--card); color: inherit; text-decoration: none;
382382 }
383383 .app-tile:hover { border-color: var(--accent); }
384 .app-tile-look { display: block; width: 100%; height: auto; background: var(--muted); }
384 .app-tile-look { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; object-fit: cover; object-position: top; background: var(--muted); }
385385 .app-tile-blank {
386386 display: flex; align-items: center; justify-content: center;
387387 aspect-ratio: 1280 / 800; background: var(--muted); color: var(--muted-fg);
388388 }
389389 .app-tile-body { display: grid; gap: 6px; padding: 10px 12px; }
390 .app-tile-body .badge { justify-self: start; }
390391 .app-tile-name { font-weight: 600; font-size: 14px; }
391392 .app-tile-desc { color: var(--muted-fg); font-size: 12.5px; }
392393
test/home-tiles.test.ts added +21
@@ -0,0 +1,21 @@
1 import { describe, expect, test } from "bun:test";
2 import { LOOK_SIZES, LOOK_VIEWPORTS } from "../src/core/looks.ts";
3 import { content } from "../src/web/style/content.ts";
4
5 describe("home tiles", () => {
6 test("a thumb is the whole desktop window at half size", () => {
7 const v = LOOK_VIEWPORTS.thumb;
8 expect(v).toEqual({ ...LOOK_VIEWPORTS.desktop, scale: 0.5 });
9 expect(LOOK_SIZES.thumb).toEqual({
10 width: v.width * v.scale,
11 height: v.height * v.scale,
12 });
13 });
14
15 test("the picture is covered from the top, the badge shrinks, the hero clears the grid", () => {
16 expect(content).toMatch(/\.app-tile-look \{[^}]*object-fit: cover; object-position: top/);
17 expect(content).toMatch(/\.app-tile-body \.badge \{ justify-self: start; \}/);
18 const hero = /\.hero \{[^}]*margin: 12dvh auto (\d+)px;/.exec(content);
19 expect(Number(hero?.[1])).toBeGreaterThanOrEqual(24);
20 });
21 });
test/looks.test.ts +3 −2
@@ -209,8 +209,9 @@ describe("the look", () => {
209209 expect(readdirSync(join(dataDir, "looks", ".taking"))).toEqual([]);
210210 const phone = calls.find((c) => c.width === 390)!;
211211 expect(phone.height).toBe(844);
212 expect(calls.find((c) => c.width === 1280)?.height).toBe(800);
213 expect(calls.find((c) => c.width === 200)?.height).toBe(125);
212 expect(calls.find((c) => c.width === 1280 && c.scale === 1)?.height).toBe(800);
213 expect(calls.filter((c) => c.width === 1280)).toHaveLength(2);
214 expect(calls.find((c) => c.scale === 0.5)?.height).toBe(800);
214215 const url = new URL(phone.url);
215216 expect(url.host).toBe(`hello.${DOMAIN}:${servers.port}`);
216217 expect(url.pathname).toBe("/__forge/grant");
test/studio.test.ts +2 −2
@@ -1448,8 +1448,8 @@ describe("the studio", () => {
14481448 );
14491449 expect(tile).toBeDefined();
14501450 expect(tile).toContain(`/looks/production/${commit}/thumb.png`);
1451 expect(tile).toContain('width="200"');
1452 expect(tile).toContain('height="125"');
1451 expect(tile).toContain('width="640"');
1452 expect(tile).toContain('height="400"');
14531453 });
14541454
14551455 test("the front door's tile still renders at desktop's size for a commit from before thumbs existed (#287)", async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs