Skip to content

feat(script): scale-to-fit preview + DESIGN.md overlays named theme#8

Merged
cuio merged 1 commit intomainfrom
feat/preview-scale-and-brand-colors
Apr 25, 2026
Merged

feat(script): scale-to-fit preview + DESIGN.md overlays named theme#8
cuio merged 1 commit intomainfrom
feat/preview-scale-and-brand-colors

Conversation

@cuio
Copy link
Copy Markdown
Owner

@cuio cuio commented Apr 25, 2026

Summary

Two fixes that together let projects render the way their DESIGN.md says they should — and let humans actually see what they rendered.

Preview scale-to-fit

Before: body was hardcoded to 1920×1080 pixels. In any viewport smaller than 1920×1080 (preview embeds, narrow browser windows, the studio's own iframe panel), only the upper-left chunk of the canvas was visible.

After:

  • body is 100vw / 100vh with flex centering
  • .hf-stage keeps native pixel dimensions but applies transform: scale(min(calc(100vw / Wpx), calc(100vh / Hpx))) so the whole canvas stays visible at any viewport
  • The producer launches Puppeteer at viewport === canvas, so scale evaluates to 1 during real renders — no impact on captured output
  • Both calc() operands carry px units so the division yields a unitless number (scale() rejects raw lengths)

DESIGN.md overlays the named theme instead of being skipped

Before: resolveProjectTokens short-circuited — if hyperframes.json had design.theme, it returned that theme and ignored DESIGN.md entirely. After hyperframes init that was the common case: every project shipped with a default theme name, and DESIGN.md was dead weight.

After: composition order is DEFAULT_TOKENS → named theme → DESIGN.md, with DESIGN.md overlaying only the roles its parser actually finds. So a project can pick data-drift-dark as a starting palette and tweak individual hex codes in DESIGN.md without losing the rest of the theme.

parseDesignBriefToTokens now takes an optional base parameter (defaults to DEFAULT_TOKENS) so callers can stack briefs on any starting tokens — backwards-compatible signature.

Test plan

  • my-first-video (hyperframes.json says hackernoon-ft, DESIGN.md says deep black + electric purple + cyan) now resolves to bg=#0a0a0a, accent=#7c3aed, accent2=#06b6d4
  • Reassembled the project — chart-scene renders the HyperSpeedrun "Data Drift meets Swiss Pulse" aesthetic (purple + amber timeline badges on deep black) instead of cream data-journalism
  • Resized preview viewport to 1280×720 — transform: matrix(0.666667, ...) applied, full 1920×1080 canvas visible inside, body bg is dark
  • Lint, format check, typecheck all pass

Notes

This compounds with PR #7 (atmospheres + transitions + kinetic templates) — once both land, the dark-themed projects will get the dramatic aurora/mesh atmospheres on their actual brand colours instead of the muted cream-multiplied versions.

Two fixes that together let projects render the way their DESIGN.md says
they should and let humans actually see what they rendered.

Preview scale-to-fit:
- assembleMaster's body switches to 100vw/100vh with flex centering.
- .hf-stage keeps its native pixel dimensions but applies
  transform: scale(min(calc(100vw / Wpx), calc(100vh / Hpx))) so the
  whole canvas stays visible inside any viewport instead of being
  cropped to the upper-left chunk in narrow embeds and small browser
  windows. The producer launches Puppeteer at viewport === canvas, so
  scale evaluates to 1 during real renders — no impact on captured
  output. Both length operands carry px so calc() yields a unitless
  number; scale() rejects raw lengths.

DESIGN.md overlays named theme:
- resolveProjectTokens used to short-circuit: if hyperframes.json had
  design.theme it returned that theme and ignored DESIGN.md entirely.
  After hyperframes init that was the common case — every project
  shipped with a default theme name and DESIGN.md was dead weight.
- New composition: DEFAULT_TOKENS → named theme → DESIGN.md, with
  DESIGN.md only overriding the roles its parser actually finds. So
  a project can pick "data-drift-dark" as a starting palette and tweak
  individual hex codes in DESIGN.md without losing the rest of the
  theme.
- parseDesignBriefToTokens takes an optional base parameter so callers
  can stack briefs on any starting tokens; defaults to DEFAULT_TOKENS,
  preserving its existing signature.

Verified on my-first-video: hyperframes.json says hackernoon-ft (cream)
but DESIGN.md says deep black + electric purple + cyan. Tokens now
resolve to bg #0a0a0a, accent #7c3aed, accent2 #06b6d4 — and the rendered
chart-scene reads as the HyperSpeedrun "Data Drift meets Swiss Pulse"
brief instead of cream data-journalism.
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