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

An issue and a pull print on one column with no chrome #13991

Merged opened this

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

Merged

scout/forge:scout/13975-an-issue-and-a-pull-print-on-one-column → main 4 commits fork 4 threads · 4 unresolved

  • Merged. scout/13975-an-issue-and-a-pull-print-on-one-column was merged into main as 77d0004.

Review

Sign in to review this change.
4 files changed +71 −4
docs/design/areas/print.md added +4
@@ -0,0 +1,4 @@
1 # Print
2
3 An issue or a pull on paper is one column with no chrome. The `@media print` block in `src/web/style/base.ts` hides the topbar, foot, repo nav, menus, forms and buttons, drops the page padding, and opens every fold (`details::details-content` made visible). No new component class: it reuses `.repo-nav`, `.menu`, `.form-actions`, `[data-print-hide]`. `test/print-style.test.ts` reads the stylesheet for these rules.
4 Side-by-side layouts (`.split`, `.settings`) stack to one column; the block is in the utilities layer, the last, so it beats the screen rules.
src/web/style/base.ts +11 −2
@@ -252,8 +252,17 @@ export const utilities = /* css */ `
252252 @media print {
253253 .topbar, .foot, .live-news, .sticky-action, .toast, [data-print-hide] { display: none !important; }
254254 .card { box-shadow: none; }
255 /* A page that prints alone (an app's statement) drops the repository's chrome. */
256 body:has([data-print-alone]) :is(.repo-nav, .settings-jump, .settings-nav) { display: none !important; }
255 /* An issue or a pull on paper: one column, no chrome (docs/design/areas/print.md). */
256 .shell, .shell-wide { max-width: none; padding: 0; }

Only the width cap and padding are dropped; the multi-column layouts on issue and pull pages are untouched, so the page is not one column on paper. Stack them here. Also make sure this beats the screen rules on specificity and order.

257 /* Side-by-side layouts stack: the rail follows the body. This block closes the utilities layer, the last
258 one, so it beats the screen rules of the earlier layers whatever their specificity, and by order the
259 other utilities; the hides alone carry !important. */
260 :is(.split, .split[data-rail="wide"], .settings) { grid-template-columns: minmax(0, 1fr); }
261 .split > aside { position: static; }
262 :is(.repo-nav, .settings-jump, .settings-nav, .menu, .form-actions, form, button) { display: none !important; }
outdated

Dead now: the :is(.repo-nav, .settings-jump, .settings-nav, ...) rule above hides these on every page, so this data-print-alone rule does nothing. Remove it (principle 1: nothing says itself twice).

263 /* A fold prints open: its body shows whether or not the reader opened it. */
264 details::details-content { content-visibility: visible; display: block; height: auto; }
265 details > summary { list-style: none; }

Non-blocking (principle 1, nothing explains itself twice): the marker data-print-alone has no reader any more, so the attribute on the statement page is dead.

257266 }
258267 }
259268 `;
test/print-style.test.ts added +54
@@ -0,0 +1,54 @@
1 /** Paper is a viewer too: the print rules hide chrome, open folds and keep one column. */
2 import { expect, test } from "bun:test";
3 import { css } from "../src/web/style.ts";
4
5 /** The `@media print` block, as its rules: selector text → declarations. */
6 const rules = (() => {
7 const start = css.indexOf("@media print {");
8 expect(start).toBeGreaterThan(-1);
9 const open = css.indexOf("{", start);
10 let depth = 0;
11 let end = open;
12 for (let i = open; i < css.length; i++) {
13 if (css[i] === "{") depth++;
14 if (css[i] === "}" && --depth === 0) { end = i; break; }
15 }
16 const body = css.slice(open + 1, end).replace(/\/\*[\s\S]*?\*\//g, "");
outdated

toContain on the whole print block passes if the selector appears anywhere, even in a rule that does not hide it. Assert the selectors are in the rule that carries display: none !important, and add a test for the stacked columns.

17 return [...body.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map((m) => ({ sel: m[1]!.trim(), decl: m[2]!.trim() }));
18 })();
19
20 const carrying = (decl: RegExp) => rules.filter((r) => decl.test(r.decl)).map((r) => r.sel).join(",");
21 const hidden = () => carrying(/display:\s*none\s*!important/);
22
23 test("print hides nav, toolbars, menus and buttons, each in a display: none !important rule", () => {
24 for (const s of [".topbar", ".repo-nav", ".settings-jump", ".menu", ".form-actions", "button", "[data-print-hide]"])
25 expect(hidden()).toContain(s);
26 });
27
28 test("the old data-print-alone rule is gone: the general rule hides those everywhere", () => {
29 expect(css).not.toContain("data-print-alone]) :is");
30 });
31
32 test("print opens folds", () => {
33 const r = rules.find((x) => x.sel === "details::details-content");
34 expect(r?.decl).toContain("content-visibility: visible");
35 });
36
37 test("print drops the width cap and padding", () => {
38 const r = rules.find((x) => x.sel.includes(".shell"));
39 expect(r?.decl).toContain("max-width: none");
40 expect(r?.decl).toContain("padding: 0");
41 });
42
43 test("print stacks the side-by-side layouts into one column", () => {
44 const r = rules.find((x) => x.sel.includes(".split"));
45 expect(r?.decl).toContain("grid-template-columns: minmax(0, 1fr)");
46 expect(r?.sel).toContain('.split[data-rail="wide"]');
47 expect(rules.find((x) => x.sel === ".split > aside")?.decl).toContain("position: static");
48 });
49
50 test("the print block sits in the last layer, after every screen rule", () => {
51 const print = css.indexOf("@media print {");
52 expect(css.lastIndexOf("@layer utilities {", print)).toBeGreaterThan(css.lastIndexOf("@layer content {", print));
53 expect(css.lastIndexOf("@layer components {", print)).toBeLessThan(css.lastIndexOf("@layer utilities {", print));
54 });
test/statement.test.ts +2 −2
@@ -187,10 +187,10 @@ describe("statement", () => {
187187 expect(text).toContain("Statement for alice/notes, 2026-10");
188188 expect(text).toContain("Margin on crew spend (20%)");
189189 expect(text).toMatch(/data-total>\$79\.27</);
190 // Printing alone is the shared stylesheet's rule, not page-inline CSS.
190 // Printing alone is the shared stylesheet's rule (it hides the settings nav on every page), not page-inline CSS.
191191 expect(text).toContain("data-print-alone");
192192 expect(text).not.toMatch(/<style[^>]*>[^<]*settings-nav/);
193 expect(utilities).toMatch(/@media print[\s\S]*body:has\(\[data-print-alone\]\)[^{]*\.settings-nav/);
193 expect(utilities).toMatch(/@media print[\s\S]*\.settings-nav[^{]*\{[^}]*display: none !important/);
194194 expect(text).toContain("/api/v1/repos/alice/notes/statement?month=2026-10&format=csv");
195195 const bad = await fetch(`${servers.url}/alice/notes/settings/app/statement?month=%3Cb%3E`, {
196196 headers: { cookie: await login("alice") },

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs