Skip to content

refactor(widgets): render widgets with one shared SVG renderer - #21

Merged
TheGeniusOfEternity merged 3 commits into
mainfrom
refactor/single-svg-renderer
Oct 3, 2026
Merged

TheGeniusOfEternity merged 3 commits into
mainfrom
refactor/single-svg-renderer

Conversation

@TheGeniusOfEternity

Copy link
Copy Markdown
Owner

Step 1 of the grid refactor (4×5 grid + size-aware blocks). No visual change intended.

Why

Every block was implemented twice: as HTML/CSS (editor, public page, iframe) and as SVG (export). Size-specific block variants would double that again. Now there is one implementation.

What changed

  • server/src/shared/widget/ split into:
    • svgPrimitives.tsx: text, rows, truncation
    • BlockContent.tsx: per-type drawing, skeleton / error / preview states
    • canvasParts.tsx: CanvasBackground, BlockShell, CanvasEmptyState, canvasBoxes
    • WidgetCanvas.tsx: the /image.svg composition, same output as before
  • Client WidgetSurface renders the same parts in the browser: the background and each block as separate <svg>s positioned by canvasBoxes, with per-instance SVG ids. WidgetCanvas and the skeleton are now thin wrappers. Removed the HTML canvas, its CSS and canvasStyle.ts.
  • Editor: each block is a DOM overlay (drag handle, size buttons, remove, selection ring) wrapping its SVG, so drag, swap, FLIP and resize keep working; drop cells live in a layer over the grid area that also anchors the pointer math.
  • Loading placeholder is an SVG skeleton (pulse), shared with the export.
  • Docs: AGENTS.md, add-block-type and widget-render-parity skills updated for the single renderer.

Test plan

  • Five-block widget with live data: iframe vs image.svg are identical
  • Editor: selection ring, resize to 2×1 (neighbour pushed down), drag-and-drop swap
  • Server SVG tests unchanged and green; client canvas tests adapted to SVG output
  • format:check, lint, typecheck, test (51 client + 62 server), build, typecheck:api

- Split server/src/shared/widget into svgPrimitives, BlockContent,
  canvasParts and the WidgetCanvas export composition
- Client WidgetSurface places the shared CanvasBackground and a BlockShell
  per block (separate SVGs positioned by canvasBoxes); WidgetCanvas and the
  skeleton are thin wrappers; the HTML canvas and its CSS are removed
- Editor blocks are DOM overlays (drag, size, remove, selection) around the
  shared block SVG; drop cells sit in a layer over the grid area
- Loading state is an SVG skeleton shared with the export
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
widgecode Ignored Ignored Preview Oct 3, 2026 3:21pm UTC

tsc-alias pulled in braces@3.0.3 (via chokidar and globby), which has a
high-severity advisory with no patched release (GHSA-vfj7-8cjw-p6xm), so
npm audit --audit-level=high failed CI on every branch.

- server/scripts/resolve-aliases.mjs rewrites @server/* and @shared/*
  imports in dist to relative paths (tested)
- npm audit fix for brace-expansion and ip-address
@TheGeniusOfEternity
TheGeniusOfEternity merged commit fee6062 into main Oct 3, 2026
3 checks passed
@TheGeniusOfEternity
TheGeniusOfEternity deleted the refactor/single-svg-renderer branch October 3, 2026 15:29
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.

1 participant