Public: anyone can read this; the crew can change it.
small: Print a deal page on one sheet of paper for the client meeting #279
mason/deal-clock:mason/278-small-print-a-deal-page-on-one-sheet-of → main 3 commits fork 1 thread · 1 unresolved
6 files
changed +135
−5
src/clockprint.test.ts added +19
| @@ -0,0 +1,19 @@ | ||
| 1 | /** The clock on paper: title, timeline and this week; no navigation, buttons or forms. */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { join } from "node:path"; | |
| 4 | import { clock } from "./pages/clock.ts"; | |
| 5 | ||
| 6 | test("the clock page marks itself for print and carries no inline script", () => { | |
| 7 | const html = clock({ who: { role: "user", id: "u", name: "Dana" }, on: "2026-10-10", deals: [] } as never); | |
| 8 | expect(html).toContain('<body class="clock-page">'); | |
| 9 | expect(html).not.toContain("<script>"); | |
| 10 | }); | |
| 11 | ||
| 12 | test("the clock's print rules hide the nav, buttons and forms and are scoped to it", async () => { | |
| 13 | const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text(); | |
| 14 | const media = css.slice(css.indexOf("/* The clock on paper")); | |
| 15 | expect(media).toContain("@media print"); | |
| 16 | expect(media).toMatch(/\.clock-page \.head[\s\S]*main button[\s\S]*main form[\s\S]*display: none/); | |
| 17 | const selectors = [...media.matchAll(/^\s*([^{}@\n]+)\{/gm)].map((m) => m[1]!.trim()); | |
| 18 | for (const sel of selectors) for (const part of sel.split(",")) expect(part.trim()).toStartWith(".clock-page"); | |
| 19 | }); |
src/dealprint.test.ts added +24
| @@ -0,0 +1,24 @@ | ||
| 1 | /** The deal page on paper: one sheet of address, parties and dates; no navigation, buttons or forms. */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { join } from "node:path"; | |
| 4 | import { dealPage } from "./pages/deal.ts"; | |
| 5 | import type { DealView } from "./deals.ts"; | |
| 6 | ||
| 7 | const deal = { id: 1, address: "A", closed: false, contract_date: "2026-10-01", closing: "2026-11-01", closing_time: null, closing_place: null, business_days: 0, parties: [], deadlines: [], conflicts: [], closingConflicts: [], sent: [] } as unknown as DealView; | |
| 8 | ||
| 9 | test("the deal page marks itself and the two blocks that print", () => { | |
| 10 | const html = dealPage({ who: { role: "user", id: "u", name: "Dana" }, on: "2026-10-10", deal }); | |
| 11 | expect(html).toContain('<body class="deal-page">'); | |
| 12 | expect(html.match(/class="card print-keep/g)?.length).toBe(2); | |
| 13 | expect(html).not.toContain("<script>"); | |
| 14 | }); | |
| 15 | ||
| 16 | test("the print rules hide the nav, buttons and forms and are scoped to the deal page", async () => { | |
| 17 | const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text(); | |
| 18 | const from = css.indexOf("/* The deal page on one sheet"); | |
| 19 | const media = css.slice(from, css.indexOf("/* The clock on paper")); | |
| 20 | expect(media).toContain("@media print"); | |
| 21 | expect(media).toMatch(/\.deal-page \.head[\s\S]*main button[\s\S]*main form[\s\S]*display: none/); | |
| 22 | const selectors = [...media.matchAll(/^\s*([^{}@\n]+)\{/gm)].map((m) => m[1]!.trim()); | |
| 23 | for (const sel of selectors) for (const part of sel.split(",")) expect(part.trim()).toStartWith(".deal-page"); | |
| 24 | }); |
src/file.test.ts +1 −1
| @@ -81,7 +81,7 @@ test("a fell-through deal shows its reason", () => { | ||
| 81 | 81 | test("the print rules hide navigation and stay scoped to the file page", async () => { |
| 82 | 82 | const css = await Bun.file(join(import.meta.dir, "..", "static", "app.css")).text(); |
| 83 | 83 | const print = css.slice(css.indexOf("/* The broker file")); |
| 84 | const media = print.slice(print.indexOf("@media print")); | |
| 84 | const media = print.slice(print.indexOf("@media print"), print.indexOf("/* The deal page on one sheet")); | |
| 85 | 85 | expect(media).toMatch(/\.file-page \.head[\s\S]*display: none/); |
| 86 | 86 | const selectors = [...media.matchAll(/^\s*([^{}@\n]+)\{/gm)].map((m) => m[1]!.trim()); |
| 87 | 87 | for (const sel of selectors) for (const part of sel.split(",")) expect(part.trim()).toStartWith(".file-page"); |
src/pages/clock.ts +1 −1
| @@ -267,5 +267,5 @@ function render(input: { | ||
| 267 | 267 | } |
| 268 | 268 | <p class="muted small">Each date reminds its parties a few days before (three unless you set another, per date) and the morning of, and the one who owes a date is asked for an update the morning after it slips. Send records your approval and opens your own Mail or Messages with the words.</p> |
| 269 | 269 | </section>`}`; |
| 270 | return layout({ body, who, agent, waiting: input.waiting, path: "/", notice, open: opened?.hrefs }); | |
| 270 | return layout({ body, who, agent, waiting: input.waiting, path: "/", notice, open: opened?.hrefs, bodyClass: "clock-page" }); | |
| 271 | 271 | } |
src/pages/deal.ts +3 −3
| @@ -381,13 +381,13 @@ export function dealPage(input: { | ||
| 381 | 381 | </section> |
| 382 | 382 | <div id="deal" data-live="deal.changed"> |
| 383 | 383 | <p class="progress">${progressLine(deal, on)}</p> |
| 384 | <section class="card"> | |
| 384 | <section class="card print-keep"> | |
| 385 | 385 | <h2>Dates</h2> |
| 386 | 386 | ${conflictLines(deal)} |
| 387 | 387 | <ol class="dates">${dates}</ol> |
| 388 | 388 | </section> |
| 389 | 389 | ${comingCard(deal, agent ?? defaults, on)} |
| 390 | <section class="card" id="parties"> | |
| 390 | <section class="card print-keep" id="parties"> | |
| 391 | 391 | <h2>Parties</h2> |
| 392 | 392 | ${parties} |
| 393 | 393 | </section> |
| @@ -413,7 +413,7 @@ export function dealPage(input: { | ||
| 413 | 413 | }) |
| 414 | 414 | : "" |
| 415 | 415 | }`; |
| 416 | return layout({ body, who, agent, waiting: input.waiting, path, heading: deal.address, notice, open: opened?.hrefs }); | |
| 416 | return layout({ body, who, agent, waiting: input.waiting, path, heading: deal.address, notice, open: opened?.hrefs, bodyClass: "deal-page" }); | |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** What the form was last sent with, what was wrong with it, and the dates it would make. */ |
static/app.css +87
| @@ -1123,3 +1123,90 @@ a.marker { | ||
| 1123 | 1123 | font-size: 1rem; |
| 1124 | 1124 | } |
| 1125 | 1125 | } |
| 1126 | ||
| 1127 | /* The deal page on one sheet: address, parties and the dated list, black on white; no tools. */ | |
| 1128 | @media print { | |
| 1129 | .deal-page { | |
| 1130 | background: white; | |
| 1131 | color: black; | |
| 1132 | font-size: 10pt; | |
| 1133 | } | |
| 1134 | .deal-page .head, | |
| 1135 | .deal-page footer, | |
| 1136 | .deal-page .toast, | |
| 1137 | .deal-page .crumb, | |
| 1138 | .deal-page .intro .row, | |
| 1139 | .deal-page .intro details, | |
| 1140 | .deal-page .intro form, | |
| 1141 | .deal-page .progress, | |
| 1142 | .deal-page main > :not(.intro):not(#deal), | |
| 1143 | .deal-page #deal > :not(.print-keep), | |
| 1144 | .deal-page main button, | |
| 1145 | .deal-page main form, | |
| 1146 | .deal-page main details, | |
| 1147 | .deal-page main [popover], | |
| 1148 | .deal-page .party-controls { | |
| 1149 | display: none; | |
| 1150 | } | |
| 1151 | .deal-page .page { | |
| 1152 | max-width: none; | |
| 1153 | padding: 0; | |
| 1154 | } | |
| 1155 | .deal-page .card { | |
| 1156 | border: 0; | |
| 1157 | box-shadow: none; | |
| 1158 | padding: 0; | |
| 1159 | background: white; | |
| 1160 | } | |
| 1161 | .deal-page .date-row, | |
| 1162 | .deal-page .party-row { | |
| 1163 | break-inside: avoid; | |
| 1164 | color: black; | |
| 1165 | } | |
| 1166 | .deal-page h2 { | |
| 1167 | break-after: avoid; | |
| 1168 | font-size: 1rem; | |
| 1169 | } | |
| 1170 | .deal-page .muted { | |
| 1171 | color: black; | |
| 1172 | } | |
| 1173 | } | |
| 1174 | ||
| 1175 | /* The clock on paper: the title, the timeline and this week, black on white; no tools. */ | |
| 1176 | @media print { | |
| 1177 | .clock-page { | |
| 1178 | background: white; | |
| 1179 | color: black; | |
| 1180 | font-size: 10pt; | |
| 1181 | } | |
| 1182 | .clock-page .head, | |
| 1183 | .clock-page footer, | |
| 1184 | .clock-page .toast, | |
| 1185 | .clock-page .intro .actions, | |
| 1186 | .clock-page .find, | |
| 1187 | .clock-page .legend, | |
| 1188 | .clock-page main > :not(.intro):not(#clock):not(#week), | |
| 1189 | .clock-page main button, | |
| 1190 | .clock-page main form, | |
| 1191 | .clock-page main details, | |
| 1192 | .clock-page main [popover] { | |
| 1193 | display: none; | |
| 1194 | } | |
| 1195 | .clock-page .page { | |
| 1196 | max-width: none; | |
| 1197 | padding: 0; | |
| 1198 | } | |
| 1199 | .clock-page .card { | |
| 1200 | border: 0; | |
| 1201 | box-shadow: none; | |
| 1202 | padding: 0; | |
| 1203 | background: white; | |
| 1204 | } | |
| 1205 | .clock-page .muted { | |
| 1206 | color: black; | |
| 1207 | } | |
| 1208 | .clock-page h2 { | |
| 1209 | break-after: avoid; | |
| 1210 | font-size: 1rem; | |
| 1211 | } | |
| 1212 | } |
new above
offline
This block covers only .deal-page. The issue also asks for the clock page. Add a scoped print block for it, with a test.