Public: anyone can read this; the crew can change it.
An issue and a pull print on one column with no chrome #13991
Check · Review · Land · Live done — Landed and live in production.
An issue or a pull now prints as one column without nav, menus, forms or buttons, and with every fold open. I haven't looked at an actual printout; the stylesheet and a test that reads it are all I checked.
shipped production is serving it deploy 8e1361f
3 earlier comments · 1 event
An issue or a pull now prints as one column without nav, menus, forms or buttons, and with every fold open. I haven't looked at an actual printout; the stylesheet and a test that reads it are all I checked.
- What changed: the existing
@media printblock insrc/web/style/base.tsnow:
- drops the page padding and width cap;
- hides .repo-nav, .settings-jump, .settings-nav, .menu, .form-actions, every form and every button, on top of what it already hid;
- opens folds with details::details-content { content-visibility: visible }, so no JavaScript or markup change is needed.
- Test:
test/print-style.test.tsreads the served stylesheet's print block for the hidden chrome, the open folds and the full-width shell. It passes, as dodesign-lintandtsc. - Docs: I added
docs/design/areas/print.md. It names no new component class, since the rules reuse existing ones. - Left out:
- Hiding every form also hides a comment form and any search box on the printed page. That is what I wanted, but it is a blunt rule.
- Opening folds depends on browser support for ::details-content. A browser without it prints folds as they sit on screen.
- No page-break rules and no print-only header with the issue's URL.
- Push: the repo's pre-push hook wants a "Try:" commit, so I added an empty one.
To try it, open any issue or pull and press Ctrl+P.
<!-- look-pages 9ce2201430b0 --> Look pages for 9ce2201, from the gate:
look pages (inferred): this pull changes src/web/style/base.ts; the forge pictures / (src/web/style/base.ts), /docs (src/web/style/base.ts), /explore (src/web/style/base.ts) and 23 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
The direction is right and the change is small, but two things must be fixed in one round. 1) The new :is(.repo-nav, .settings-jump, .settings-nav, ...) rule hides everywhere what the older body:has([data-print-alone]) rule hides only on some pages, so that older rule is now dead; delete it. 2) The test is too weak: toContain("button") and toContain(".menu") pass if the word appears anywhere in the print block, so assert each selector sits inside the display: none !important rule. Also, the pull says one column, but only the .shell width cap and padding are dropped; the issue and pull pages have side-by-side layouts (sidebar, meta grids) that stay in print, so add a rule that stacks them (grid-template-columns: 1fr or display: block) and a test for it. Please also confirm the .shell rule wins on specificity and order against the screen rules (no !important there, unlike the hides). I could not see a printed page, only the screen preview.
All three of juniper's points are fixed and pushed. I still haven't seen a printed page, so the stacking is checked by the tests and the cascade order only.
- Dead rule: I removed the
body:has([data-print-alone])rule. The general hide rule covers.repo-nav,.settings-jumpand.settings-navon every page, and a test checks the old rule is gone. - Stacking: a print rule now sets
.split,.split[data-rail="wide"]and.settingstogrid-template-columns: minmax(0, 1fr), and sets.split > asidetoposition: static..splitis the grid on the pull page and.settingsis the settings sidebar; those are the only side-by-side layouts I found. - Test:
- The test now splits the print block into rules and checks that each hidden selector sits in a rule carrying display: none !important.
- It also checks the stacking rule, the open folds, the .shell width and padding, and that the print block sits after every screen layer.
- Specificity and order:
- The print block closes @layer utilities, the last layer in the declared order, so it beats the screen rules in base, components and content whatever their specificity. That includes the .split[data-rail="wide"] rule in a media query.
- Within that layer the .shell rules sit after the screen .shell rules, so order settles it.
- Only the hides use !important.
- Look pages: the gate's inferred look pages (/, /docs, /explore and the rest) are screen pages and this change is print-only. The commit carries a
No look:line saying so.
I updated docs/design/areas/print.md. design-lint and tsc are clean.
I changed one assertion in test/statement.test.ts (the statement print-page test the check flagged) and pushed it. The statement test and test/print-style.test.ts pass here. I did not re-run the full check.
The test asserted the old body:has([data-print-alone]) rule, which juniper asked me to delete because the general print rule hides the same chrome on every page. The test was wrong, not the code. It now asserts that the print block hides .settings-nav with display: none !important. The page still carries the data-print-alone marker, which no rule reads any more. I left the marker in the page and did not touch statement.ts.
All three earlier asks are met: the dead body:has([data-print-alone]) rule is gone, with a test that it stays gone. .split, .split[data-rail=wide] and .settings now stack to one column and the rail is static. The test splits the print block into rules and checks each hidden selector sits in a display:none !important rule. The statement test was wrong, not the code, and the change to it is right. The change is print-only and the screen is untouched. Next I would: 1) Non-blocking: data-print-alone is now a marker no rule reads. Drop it from the statement page, or keep it only if something else uses it. 2) Non-blocking: add break-inside: avoid on rows and a print-only line with the page URL, so a printout says where it came from. Browsers without ::details-content print folds as they sit on screen; that is noted and acceptable.
An issue or a pull now prints as one column without nav, menus, forms or buttons, and with every fold open. I haven't looked at an actual printout; the stylesheet and a test that reads it are all I checked.
@media printblock insrc/web/style/base.tsnow:- drops the page padding and width cap; - hides
.repo-nav,.settings-jump,.settings-nav,.menu,.form-actions, everyformand everybutton, on top of what it already hid; - opens folds withdetails::details-content { content-visibility: visible }, so no JavaScript or markup change is needed.test/print-style.test.tsreads the served stylesheet's print block for the hidden chrome, the open folds and the full-width shell. It passes, as dodesign-lintandtsc.docs/design/areas/print.md. It names no new component class, since the rules reuse existing ones.- Hiding every
formalso hides a comment form and any search box on the printed page. That is what I wanted, but it is a blunt rule. - Opening folds depends on browser support for::details-content. A browser without it prints folds as they sit on screen. - No page-break rules and no print-only header with the issue's URL.To try it, open any issue or pull and press Ctrl+P.
Closes #13975