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

The review page and a deal page read on a phone-width screen with no sideways scroll, pinned by a test #267

Merged opened this

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

Merged

mason/deal-clock:mason/261-the-review-page-and-a-deal-page-read-on → main 3 commits fork

  • Merged. mason/261-the-review-page-and-a-deal-page-read-on was merged into main as 09ab42b.

Review

Sign in to review this change.
2 files changed +75 −0
src/phone.test.ts added +43
@@ -0,0 +1,43 @@
1 /** Review and a deal page stay readable on a phone: the narrow-screen rules exist and no fixed width is wide. */
2 import { expect, test } from "bun:test";
3 import { join } from "node:path";
4
5 const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text();
6 const layout = await Bun.file(join(import.meta.dir, "pages", "layout.ts")).text();
7
8 const narrow = (): string => {
9 const at = css.search(/@media \(max-width: 30rem\)/);
10 expect(at).toBeGreaterThanOrEqual(0);
11 return css.slice(at);
12 };
13
14 test("the page declares a device-width viewport", () => {
15 expect(layout).toContain('<meta name="viewport" content="width=device-width, initial-scale=1">');
16 });
17
18 test("a narrow-screen rule set stacks the Review buttons and the deal's date rows", () => {
19 const rules = narrow();
20 expect(rules).toMatch(/\.move \.button[^{]*\{[^}]*width: 100%/);
21 expect(rules).toMatch(/\.date-row \{[^}]*flex-direction: column/);
22 expect(rules).toMatch(/\.state \{[^}]*white-space: normal/);
23 expect(rules).toMatch(/min-height: var\(--size-tap\)/);
24 });
25
26 test("the tap size is at least 44px", async () => {
27 const tokens = await Bun.file(join(import.meta.dir, "..", "design", "tokens.json")).json();
28 const px = Number(String(tokens.size.tap.$value).replace("px", ""));
29 expect(px).toBeGreaterThanOrEqual(44);
30 });
31
32 test("no rule for Review or deal-page classes sets a fixed width over 360px", () => {
33 const classes = ["card", "narrow", "move", "draft", "drafts", "draft-text", "draft-body", "draft-who", "dates", "date-row", "parties", "input", "button", "actions", "stack", "pair"];
34 for (const [, selector = "", body = ""] of css.matchAll(/([^{}@]+)\{([^{}]*)\}/g)) {
35 if (!classes.some((c) => new RegExp(`\\.${c}(?![\\w-])`).test(selector))) continue;
36 for (const [, prop = "", value = ""] of body.matchAll(/(?:^|;|\s)((?:min-)?width)\s*:\s*([^;]+)/g)) {
37 const px = /^(\d+(?:\.\d+)?)(px|rem)$/.exec(value.trim());
38 if (px === null) continue;
39 const size = Number(px[1]) * (px[2] === "rem" ? 16 : 1);
40 expect({ selector: selector.trim(), prop, size: size > 360 }).toEqual({ selector: selector.trim(), prop, size: false });
41 }
42 }
43 });
static/app.css +32
@@ -959,6 +959,38 @@ a.marker {
959959 display: none;
960960 }
961961
962 /* Phone width (about 480px): Review and a deal's dates stack and wrap, no sideways scroll. */
963 @media (max-width: 30rem) {
964 .move .button,
965 .actions .button,
966 .date-row .button {
967 width: 100%;
968 min-height: var(--size-tap);
969 }
970 .move .input,
971 .move textarea {
972 max-width: 100%;
973 }
974 .date-row {
975 flex-direction: column;
976 align-items: stretch;
977 }
978 .date-row > div {
979 min-width: 0;
980 overflow-wrap: anywhere;
981 }
982 .draft,
983 .draft summary {
984 flex-wrap: wrap;
985 }
986 .state {
987 white-space: normal;
988 }
989 .actions {
990 flex-direction: column;
991 }
992 }
993
962994 /* On paper: only the client timeline changes — black on white, no tools, no row split. */
963995 .progress-text {
964996 display: block;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs