Skip to content

feat(marketing): render route for graphics with state from the URL - #8

Merged
AdrianOrlow merged 1 commit into
mainfrom
feat/render-route
Oct 8, 2026
Merged

AdrianOrlow merged 1 commit into
mainfrom
feat/render-route

Conversation

@AdrianOrlow

Copy link
Copy Markdown
Member

Closes #6

Changes

  • New route /marketing/render (src/pages/marketing_.render.tsx, component GraphicRender) that shows one graphic built from URL parameters: template, format and the template's field values under the same ids as in the editor. Missing fields keep their defaultValue.
  • It reuses the editor's code instead of a second implementation: GRAPHIC_TEMPLATES, GRAPHIC_FORMATS, getDefaultFieldValues, validateContent, loadGraphicFonts, rasterizeGraphic, usePhoto and describeContent. The page shows the PNG that rasterizeGraphic produced, so what a script reads is the file the editor would export.
  • Contract for automation, as data-render-* attributes on <main>: status (loading, awaiting-photo, ready, error), overflow (from contentOverflows / data-fit), error (a machine-readable code) and error-fields. Wrong URLs show a readable message in a role="alert" element, never a blank page.
  • Background photo: a URL cannot carry a file, so photo=1 makes the page wait for a file in its input[type=file] (focalX / focalY set the focal point). The file goes through the editor's usePhoto, including downscaling.
  • root.tsx skips ConsoleShell for routes that export handle = { isBare: true }, so the render page has no sidebar and does not call the publisher worker.
  • README: a "Render route (Marketing)" section with every parameter and attribute.

Notes for the reviewer

  • Same image as the editor. The e2e test exports all four formats in the editor and through the route and compares the PNGs. In Firefox and WebKit all four are identical. In Chromium three are byte-identical; story differs in 0.66% of pixels, all inside a 52 px strip of the funding banner (the 3603 px wide PROO images scaled down). The two crops are visually indistinguishable. I did not find the cause - it is not render order within one page, which I ruled out - so the test allows up to 1% differing pixels instead of requiring identical bytes.
  • Structure. GraphicRender imports from ../ExportLab/... instead of moving the templates and utils to a shared place. That bends the encapsulation rule in CLAUDE.md §3.2; moving about twenty files felt out of scope here. Happy to do it in a follow-up if you prefer.
  • Language. Error messages are in Polish like the rest of the UI; the data-render-error codes are English and stable.
  • e2e is disabled in CI (if: false), so the Playwright results below are from a local run.

How to test

  • yarn build && yarn preview --host 127.0.0.1 --port 4173
  • Open http://127.0.0.1:4173/marketing/render?template=standard&format=portrait&title=Nowy%20*projekt* - only the 1080×1350 graphic is shown, and <main> has data-render-status="ready".
  • Add &subtitle= with a very long text and format=landscape - data-render-overflow="true".
  • Change template=poster - an error message and data-render-error="unknown-template".
  • Add &photo=1&focalX=20 - the page waits (awaiting-photo) until a file is chosen in the input.
  • yarn e2e e2e/marketing/render.spec.ts

Run locally on this branch: yarn lint, yarn typecheck, yarn test:coverage (275 tests, 99.05% statements, GraphicRender at 100%), render.spec.ts in all four Playwright projects (24 passed), and the existing dashboard.spec.ts and marketing.spec.ts in Chromium (9 passed).

Checklist

  • Follows front-end standards - with the one deviation described above
  • No unused code / console.log / leftover comments
  • Resolved merge conflicts (if applicable)
  • Added / updated unit tests (if applicable)
  • Added / updated storybook stories (if applicable) - not applicable, no shared component

🤖 Generated with Claude Code

/marketing/render shows one graphic, without the Console shell, built from
URL parameters: template, format and the template's field values. It reuses
the editor's templates, validation and rasterizer, and reports readiness,
text overflow and errors through data-render-* attributes on the root
element so scripts can wait for a result instead of a timeout.

A background photo cannot travel in a URL, so photo=1 makes the page wait
for a file in its file input.

Closes #6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T23:35:35.885684Z 3269aea PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AdrianOrlow
AdrianOrlow merged commit 4e1b303 into main Oct 8, 2026
4 checks passed
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.

Render route for graphic templates with state from the URL

1 participant