Skip to content

feat(cli): make scaffolded templates render correctly anywhere — no blank pages#3102

Merged
josephfarina merged 2 commits into
mainfrom
feat/portable-templates
Jun 25, 2026
Merged

feat(cli): make scaffolded templates render correctly anywhere — no blank pages#3102
josephfarina merged 2 commits into
mainfrom
feat/portable-templates

Conversation

@josephfarina

@josephfarina josephfarina commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🎯 Why this exists

Part of a broader push to make Astryx the easiest design system for AI agents to build real UIs with — one-shot, no escape hatches, no broken renders. We're vibe-testing the full agent journey (install → init → discover → compose → build → typecheck → render) and fixing every friction point it surfaces, so an agent given a one-line prompt lands a correct, fully-styled, type-safe page using only design-system components.

Summary

Astryx ships two ways: components (@astryxdesign/core) are precompiled (they ship dist/astryx.css), but page and block templates authored StyleX directly in app source (stylex.create, xstyle=, stylex.props(...), and *.stylex token imports). When an agent scaffolds one of these templates into a plain Vite app with no @stylexjs/babel-plugin, the StyleX never compiles — producing a blank page (runtime Unexpected 'stylex.create' call at runtime throw) or a silently unstyled layout. This was the single biggest thing breaking real scaffolded output (~26 of 37 page templates + many blocks).

This PR makes every page and block template render correctly in a plain Vite + React + TS app with no StyleX compiler — no runtime throw, full styling, visual parity with today.

What changed

  • Removed all consumer-authored StyleX from 82 templates under packages/cli/templates/ (27 pages + 55 blocks):
    • dropped import * as stylex and *.stylex token imports
    • preferred Astryx component props; otherwise plain inline style={{ ... }} using the design-token CSS variables emitted at :root by the precompiled @astryxdesign/core/astryx.css (e.g. var(--spacing-4), var(--color-border), var(--radius-element)) — exact token names, no invented vars
    • reproduced container/media queries with a compiler-free <style> tag + className (or the existing useMediaQuery hook)
    • where a style targeted a TableRow (which doesn't reliably forward style), moved it to the TableCell
  • Updated a few display strings that referenced StyleX (a docs "install the StyleX compiler" step → "import the precompiled CSS"; code/citation samples) so scaffolded output no longer points users back at StyleX.
  • No changes to @astryxdesign/core component source or its precompiled CSS. Consumers do not need to install or configure @stylexjs/babel-plugin.

Test plan

  • rg "stylex|xstyle|\.stylex" packages/cli/templates returns nothing
  • Scaffolded the worst offenders (payment-form, table-grouped, detail-page, Chat* blocks) and every complex page (editor, ide, ai-chat, login-split, mixed-gallery, theme-showcase, settings-dialog, file-explorer) into a throwaway plain Vite app (@astryxdesign/core + @astryxdesign/theme-neutral from npm, no StyleX) — npm run build (tsc + vite) passes and each renders fully styled with no page errors / no stylex.create runtime throw
  • All 82 changed files pass tsc --noEmit (strict) against the real published @astryxdesign/core types
  • Spot-rendered sample blocks (incl. PaginationWithTable, which uses Table)
  • npx vitest run packages/cli — passes except 2 pre-existing failures in import-hint-correctness.test.mjs (about the Theme component's documented import path; fail identically on main, unrelated to templates)

Made with Cursor

Page and block templates authored StyleX directly in app source
(stylex.create, xstyle, stylex.props, *.stylex token imports). When
scaffolded into a plain Vite app with no @stylexjs/babel-plugin, the
StyleX never compiled — causing a blank page (runtime "Unexpected
'stylex.create' call at runtime" throw) or silently unstyled layout.

Remove all consumer-authored StyleX from the 82 offending templates:
- drop `import * as stylex` and `*.stylex` token imports
- prefer Astryx component props; otherwise plain inline `style={{...}}`
  using the design-token CSS variables emitted at :root by the
  precompiled @astryxdesign/core/astryx.css (e.g. var(--spacing-4),
  var(--color-border), var(--radius-element))
- reproduce container/media queries with a compiler-free <style> tag +
  className (or the existing useMediaQuery hook)
- where styles hit a TableRow (which doesn't forward `style`), move them
  to the TableCell

Components (@astryxdesign/core) and their precompiled CSS are unchanged.
Templates now render fully styled in a plain Vite + React + TS app with
zero StyleX/build config.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
astryx Ignored Ignored Jun 25, 2026 6:11pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 25, 2026
@josephfarina josephfarina changed the title feat(cli): make page + block templates render without a StyleX compiler feat(cli): make scaffolded templates render correctly anywhere — no blank pages Jun 25, 2026
Resolve conflicts in 5 templates that main also changed by taking main's
updated versions and re-applying the StyleX removal (inline styles +
var(--token) design tokens, no compiler): documentation, documentation-design,
documentation-technical, form-two-column, ide.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Vercel Preview Deployment

Status ✅ Deployed
Preview Open Preview
Commit d7284b7
Inspect Vercel Dashboard
Workflow View Logs

No authentication required — anyone with the link can view the preview.

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jun 25, 2026
@josephfarina josephfarina merged commit 9c16d98 into main Jun 25, 2026
15 checks passed
@josephfarina josephfarina deleted the feat/portable-templates branch June 25, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants