Skip to content

feat(docs): add a print stylesheet for documentation pages (DX-063) - #638

Merged
IbrahimIjai merged 1 commit into
SO4-Markets:mainfrom
Ay-obami:feat/print-stylesheet-issue-575
Aug 30, 2026
Merged

feat(docs): add a print stylesheet for documentation pages (DX-063)#638
IbrahimIjai merged 1 commit into
SO4-Markets:mainfrom
Ay-obami:feat/print-stylesheet-issue-575

Conversation

@Ay-obami

@Ay-obami Ay-obami commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Closes #575
Closes #582
Closes #579

Summary

Adds a print stylesheet for the documentation site so reference pages (particularly /resources/terms and /concepts/risk) print as clean, light, content-only documents instead of a navigation header followed by theme-dependent, unreadable output.

  • apps/docs/src/styles/print.css (new) — @media print rules that:
    • hide the page chrome: static page header, DocsLayout sidebar/TOC/header/footer (data-slot hooks), search dialog, mobile TOC, heading anchors, and the (not-yet-built) reading-progress / feedback controls via documented hooks;
    • force the light palette regardless of the active theme by re-declaring every token the .dark block in packages/ui/src/styles/globals.css overrides with that file's :root light values;
    • expand the content column to the full page width;
    • expand every collapsible (grid-rows override) and tab panel — inactive panels stay mounted and get data-tab-label prefixes so the reader can still tell the alternatives apart;
    • print the destination URL after internal links (main a[href^="/"]::after);
    • avoid page breaks inside code blocks, callouts, and table rows (break-inside: avoid + repeating thead);
    • render a print-only footer with the page URL and last-updated date.
  • The rules live in a docs-print cascade layer declared before Tailwind's theme, base, components, utilities layers, so their !important rules beat the base-layer preflight [hidden] { display: none !important } that guards inactive tab panels (Base UI keepMounted panels and the content Tabs both hide inactive panels with the hidden attribute).
  • scripts/build.ts renders the print footer (canonical URL from the new DEFAULT_SITE_URL in src/lib/seo.ts + the frontmatter updated date) — no client JS is needed for any print path, including headless PDF export.
  • mdx/components.tsx content Tabs now keep every panel mounted (inactive ones hidden via the hidden attribute), so print/search can reach content that was previously never rendered to the DOM; this matches the primitives-based Tabs (keepMounted) convention. mdx/Tabs.tsx panels carry data-tab-label.
  • DocsLayout.tsx marks its chrome regions with data-slot hooks (docs-shell/header/sidebar/toc/footer) that the print sheet targets.

Pre-existing main defects repaired (required to build/verify this change)

  • scripts/build.ts — the feat(docs): implement DX-027, DX-030, DX-033, and DX-037 #636 merge left an orphaned inline-styled page template referencing undefined variables, and removed the vite stylesheet build that the page template's /assets/${stylesheet} link depends on. Restored the bunx vite build + hashed-stylesheet pipeline; bun run --cwd apps/docs build now completes (25 static routes).
  • scripts/check-content.ts — the glossary check crashed on entry.answer (a field headingEntries() no longer returns); it now reads each entry's own section of the glossary body. The home page is reachable by definition, so it is exempted from the orphan-page check.
  • scripts/generate-faq.ts — same stale entry.answer crash; each FAQ entry's answer is now derived from its own section body.
  • mdx/components.tsx — removed the import { Tab, Tabs } from "./Tabs" that conflicted with the local Tabs declaration (TS2440).

Verification

  • bun run --cwd apps/docs build — all content gates pass, 25 static routes + Pagefind-ready output.
  • bun test (apps/docs) — 54 pass / 12 fail / 3 errors; the failures are identical on clean main (pre-existing: Sidebar/Pager route fixtures, docs shortcuts, test-hook timeouts) plus a new passing test MDX content tabs keep every panel mounted for print and search.
  • Headless-Chrome (Playwright) PDF exports of three representative pages with DOM assertions under print emulation:
    • /resources/termsterms.pdf
    • /concepts/riskrisk.pdf
    • /resources/faqfaq.pdf
    • Each verified: header hidden, print footer present with Last updated <date> · https://docs.so4.market/<route>, internal links print their destination (… (/concepts/risk)), and dark-theme variants (terms-dark-active.pdf, risk-dark-active.pdf) print identically in the light palette when .dark is forced on <html>.
    • A fixture harness against the built stylesheet confirms hidden tab panels expand, collapsibles expand, and DocsLayout chrome slots hide in print.
  • PDFs and the reproduction scripts are in the local print-exports/ folder — attach the three PDFs to this PR (GitHub doesn't accept file uploads via the API).

Notes

  • Dependency (DX-062, issue DX-062: Add reading time and reading progress #574) has not landed — the reading-progress indicator does not exist on main yet. The print sheet hides the header (where DX-062's indicator is specified to live) and documents data-reading-progress / data-page-feedback / print:hidden as the convention for components that land later.
  • /resources/terms is status: draft, so the real build intentionally excludes it; its PDF was rendered locally with the exact production template (print-exports/render-draft-terms.ts) for verification only.
  • The current static renderer emits headings/lists/callouts but no <pre>/<table>/tabs yet (the full MDX pipeline is deferred per the DX-097–100 note in docs/dx_1/001_docs_site.md); the print rules for those elements are in place and verified via the fixture harness so they apply the moment the renderer catches up.
  • Light-mode --surface-*/--text-* and status subtle token values are not declared in :root upstream (light mode currently degrades via inheritance, and the subtle fills are dark tints that print as near-black boxes); print states the surface/text values explicitly and neutralizes callout fills to bordered boxes so printed callouts are readable.

Reference pages — particularly /resources/terms and /concepts/risk — get
printed and saved as PDFs. Without print rules the output is a navigation
header followed by whatever the active theme happens to be.

- apps/docs/src/styles/print.css (new): @media print rules that hide the
  page chrome (static header, DocsLayout sidebar/TOC/header/footer slots,
  search dialog, mobile TOC, heading anchors), force the light palette by
  re-declaring the dark-theme token overrides, expand the content column,
  open every collapsible and tab panel, print destination URLs after
  internal links, keep code blocks/callouts/table rows unsplit, and show a
  print-only footer with the page URL and last-updated date.
- the rules live in a docs-print cascade layer declared before Tailwind's
  layers, so their !important rules beat the base preflight
  [hidden]{display:none!important} that guards inactive tab panels.
- the static generator emits the print footer (canonical URL from seo.ts
  DEFAULT_SITE_URL + frontmatter updated date) — no client JS needed.
- the content-map Tabs now keep every panel mounted (inactive ones hidden)
  so print/search can reach them, matching the primitives Tabs convention.
- DocsLayout marks its chrome regions with data-slot hooks the print sheet
  targets.

Also repairs pre-existing docs-gate defects on main that blocked building
and verifying this change:
- scripts/build.ts: drop the orphaned inline-styled page template left by
  the SO4-Markets#636 merge and restore the vite stylesheet pipeline it clobbered.
- scripts/check-content.ts: the glossary check read entry.answer, a field
  headingEntries() no longer returns (crash); read each entry's own section.
  The home page is reachable by definition, so it is exempt from the
  orphan-page check.
- scripts/generate-faq.ts: same stale entry.answer usage (crash); derive
  each entry's answer from its FAQ section body.
- mdx/components.tsx: remove the imported Tabs that conflicted with the
  local Tabs declaration (TS2440).

Closes SO4-Markets#575
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Ay-obami is attempting to deploy a commit to the Ijai's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Ay-obami Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@IbrahimIjai
IbrahimIjai merged commit f4aa8b9 into SO4-Markets:main Aug 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DX-070: Write /get-started/testnet DX-067: Write /get-started/introduction DX-063: Add a print stylesheet for documentation pages

2 participants