An open source design system that's fully customizable and agent ready
TypeScript
feat(sandbox): add Layout DSL (XLE/XLO) page (#3211)
Cindy Zhangce6a13198a39
diff --git a/apps/sandbox/.gitignore b/apps/sandbox/.gitignoreindex 340703d198..14fe6dc2f6 100644--- a/apps/sandbox/.gitignore+++ b/apps/sandbox/.gitignore@@ -13,3 +13,6 @@ outsrc/generated/src/app/(fullscreen)/templates/public/template-assets/++# Auto-generated by scripts/generate-xle-tokenizer.mjs+public/xle-tokenizer.mjsdiff --git a/apps/sandbox/package.json b/apps/sandbox/package.jsonindex d10900e76c..7bffa09752 100644--- a/apps/sandbox/package.json+++ b/apps/sandbox/package.json@@ -6,7 +6,8 @@"build:deps": "pnpm -F @astryxdesign/theme-neutral build && pnpm -F @astryxdesign/theme-matcha build && pnpm -F @astryxdesign/theme-stone build && pnpm -F @astryxdesign/theme-gothic build && pnpm -F @astryxdesign/theme-chocolate build && pnpm -F @astryxdesign/theme-y2k build && pnpm -F @astryxdesign/theme-butter build","generate:changelog": "node scripts/generate-changelog.js","generate:cli": "node scripts/generate-cli-registry.mjs",- "generate": "node ../../scripts/sync-templates.js && pnpm generate:changelog && pnpm generate:cli && node scripts/generate-foundation-docs.mjs",+ "generate:xle": "node scripts/generate-xle-registry.mjs && node scripts/generate-xle-tokenizer.mjs",+ "generate": "node ../../scripts/sync-templates.js && pnpm generate:changelog && pnpm generate:cli && node scripts/generate-foundation-docs.mjs && pnpm generate:xle","dev": "pnpm generate && (node ../../scripts/sync-templates.js --watch & next dev)","build": "pnpm generate && next build","start": "next start",diff --git a/apps/sandbox/scripts/generate-xle-registry.mjs b/apps/sandbox/scripts/generate-xle-registry.mjsnew file mode 100644index 0000000000..ba27172b6f--- /dev/null+++ b/apps/sandbox/scripts/generate-xle-registry.mjs@@ -0,0 +1,59 @@+#!/usr/bin/env node+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * Generates apps/sandbox/src/generated/xle-registry.json+ *+ * The XLE/XLO layout language validates against @astryxdesign/core .doc.mjs+ * metadata, which the CLI reads from disk (Node-only). The browser Layout DSL+ * page can't do that, so we build the registry here at deploy time and ship it+ * as plain JSON. Runs in the sandbox `generate` chain so new components/blocks+ * are picked up automatically.+ *+ * Run: node scripts/generate-xle-registry.mjs+ */++import {writeFileSync, mkdirSync} from 'node:fs';+import {dirname, resolve} from 'node:path';+import {fileURLToPath} from 'node:url';++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = resolve(__dirname, '..');+const REPO = resolve(ROOT, '../..');+const OUT = resolve(ROOT, 'src/generated/xle-registry.json');++const {buildRegistry, serializeRegistry} = await import(+ resolve(REPO, 'packages/cli/src/lib/xle/registry.mjs')+);+const {discoverTemplates} = await import(+ resolve(REPO, 'packages/cli/src/api/template.mjs')+);++const registry = await buildRegistry({cwd: REPO});++let blocks = [];+try {+ const all = await discoverTemplates(REPO);+ blocks = all+ .filter(t => t.type === 'block')+ .map(b => ({+ dirName: b.dirName,+ description: b.description || '',+ category: b.category || '',+ }));+} catch {+ // blocks are optional — {hint} just won't resolve in the page+}++const payload = {+ generated: 'scripts/generate-xle-registry.mjs',+ registry: serializeRegistry(registry),+ blocks,+};++mkdirSync(dirname(OUT), {recursive: true});+writeFileSync(OUT, JSON.stringify(payload));+console.log(+ `✓ xle-registry.json: ${payload.registry.components.length} components, ` ++ `${payload.registry.aliases.length} aliases, ${blocks.length} blocks`,+);diff --git a/apps/sandbox/scripts/generate-xle-tokenizer.mjs b/apps/sandbox/scripts/generate-xle-tokenizer.mjsnew file mode 100644index 0000000000..c5ddca4df2--- /dev/null+++ b/apps/sandbox/scripts/generate-xle-tokenizer.mjs@@ -0,0 +1,60 @@+#!/usr/bin/env node+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * Generates apps/sandbox/public/xle-tokenizer.mjs+ *+ * The Layout DSL page counts tokens CLIENT-SIDE. Rather than bundle+ * gpt-tokenizer through webpack (which hard-fails the whole build if the+ * package isn't installed), we esbuild-bundle its o200k_base encoding into a+ * single self-contained ESM module here, served from public/ and loaded via a+ * `webpackIgnore` dynamic import. If esbuild or gpt-tokenizer are unavailable,+ * we emit a heuristic module with the same export shape — so the sandbox+ * always builds and the page always has a counter.+ *+ * Runs in the sandbox `generate` chain.+ */++import {writeFileSync, mkdirSync} from 'node:fs';+import {dirname, resolve} from 'node:path';+import {fileURLToPath} from 'node:url';++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = resolve(__dirname, '..');+const REPO = resolve(ROOT, '../..');+const OUT = resolve(ROOT, 'public/xle-tokenizer.mjs');++const HEURISTIC =+ '// @generated fallback — gpt-tokenizer not bundled; using a heuristic.\n' ++ "export const ENCODER = 'est.';\n" ++ 'export const countTokens = s => (String(s).match(/\\w+|[^\\s\\w]/g) || []).length;\n';++let out = HEURISTIC;+try {+ const esbuild = await import('esbuild');+ const built = await esbuild.build({+ stdin: {+ contents:+ "import {countTokens as c} from 'gpt-tokenizer/encoding/o200k_base';\n" ++ "export const ENCODER = 'o200k_base';\n" ++ 'export const countTokens = s => c(String(s));\n',+ resolveDir: REPO,+ loader: 'js',+ },+ bundle: true,+ format: 'esm',+ platform: 'browser',+ write: false,+ legalComments: 'none',+ logLevel: 'silent',+ });+ out = built.outputFiles[0].text;+ console.log(+ `✓ xle-tokenizer.mjs: gpt-tokenizer o200k_base (${(out.length / 1024 / 1024).toFixed(1)} MB bundled)`,+ );+} catch {+ console.warn('xle-tokenizer.mjs: gpt-tokenizer/esbuild unavailable — wrote heuristic fallback');+}++mkdirSync(dirname(OUT), {recursive: true});+writeFileSync(OUT, out);diff --git a/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsxnew file mode 100644index 0000000000..b1d670e794--- /dev/null+++ b/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsx@@ -0,0 +1,487 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Sandbox page for XLE/XLO layout expressions (the "Layout DSL").+ *+ * Type a compressed layout expression (compact XLE or indented outline XLO),+ * see it live-validated against the @astryxdesign/core registry shipped as a+ * build-time JSON, watch the expanded TSX with input/output token counts,+ * browse a searchable example library, and copy the expanded TSX to the+ * clipboard. The whole pipeline runs in-browser via the pure+ * @astryxdesign/cli/xle barrel.+ *+ * Ported from the docsite Playground's "Layout DSL" tab so the layout grammar+ * has a standalone home in the component sandbox.+ *+ * @input user-typed expression+ * @output validity/errors, token metrics, live expanded TSX, example browser+ */++'use client';++import {useEffect, useMemo, useState} from 'react';+import * as stylex from '@stylexjs/stylex';+import {VStack, HStack} from '@astryxdesign/core/Stack';+import {Text} from '@astryxdesign/core/Text';+import {Heading} from '@astryxdesign/core/Heading';+import {Button} from '@astryxdesign/core/Button';+import {Badge} from '@astryxdesign/core/Badge';+import {+ SegmentedControl,+ SegmentedControlItem,+} from '@astryxdesign/core/SegmentedControl';+import {Banner} from '@astryxdesign/core/Banner';+import {checkExpression, expandExpression} from '@astryxdesign/cli/xle';+import xleData from '@/generated/xle-registry.json';+import {XLE_EXAMPLES, XLE_CATEGORIES} from './xleExamples';++type Surface = 'auto' | 'compact' | 'outline';++/** Heuristic fallback used until the BPE tokenizer loads (or if it can't). */+function heuristicTokens(src: string): number {+ return (src.match(/\w+|[^\s\w]/g) || []).length;+}++/**+ * Loads the build-time tokenizer module from public/xle-tokenizer.mjs+ * (esbuild-bundled gpt-tokenizer o200k_base, or a heuristic fallback — see+ * scripts/generate-xle-tokenizer.mjs). Loaded client-side via a webpackIgnore+ * runtime import so the sandbox build never depends on gpt-tokenizer resolving+ * through webpack. Falls back to the inline heuristic until it's ready. The+ * basePath prefix keeps the asset reachable under the GitHub Pages deployment.+ */+type TokenizerModule = {countTokens: (s: string) => number; ENCODER: string};+const TOKENIZER_URL = `${process.env.NEXT_PUBLIC_BASE_PATH || ''}/xle-tokenizer.mjs`;++function useTokenCounter() {+ const [bpe, setBpe] = useState<((s: string) => number) | null>(null);+ const [encoder, setEncoder] = useState('est.');+ useEffect(() => {+ let alive = true;+ (import(/* webpackIgnore: true */ TOKENIZER_URL) as Promise<TokenizerModule>)+ .then(m => {+ if (!alive) {+ return;+ }+ setBpe(() => (s: string) => m.countTokens(s));+ setEncoder(m.ENCODER || 'o200k_base');+ })+ .catch(() => {+ /* keep heuristic */+ });+ return () => {+ alive = false;+ };+ }, []);+ return {count: bpe ?? heuristicTokens, encoder: bpe ? encoder : 'est.'};+}++const s = stylex.create({+ page: {+ flex: 1,+ minHeight: 0,+ overflowY: 'auto',+ padding: 'var(--spacing-6)',+ gap: 'var(--spacing-4)',+ display: 'flex',+ flexDirection: 'column',+ maxWidth: 880,+ marginInline: 'auto',+ width: '100%',+ },+ editor: {+ width: '100%',+ minHeight: 120,+ resize: 'vertical',+ fontFamily: 'var(--font-family-mono, ui-monospace, monospace)',+ fontSize: 'var(--text-sm, 13px)',+ lineHeight: 1.6,+ padding: 'var(--spacing-3)',+ borderRadius: 'var(--radius-inner)',+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: 'var(--color-border)',+ backgroundColor: 'var(--color-background-base)',+ color: 'var(--color-content-primary)',+ tabSize: 2,+ },+ metrics: {+ display: 'flex',+ gap: 'var(--spacing-2)',+ flexWrap: 'wrap',+ alignItems: 'stretch',+ },+ metric: {+ flex: 1,+ minWidth: 96,+ padding: 'var(--spacing-2)',+ borderRadius: 'var(--radius-inner)',+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: 'var(--color-border)',+ backgroundColor: 'var(--color-background-muted)',+ },+ metricValue: {fontVariantNumeric: 'tabular-nums'},+ source: {+ whiteSpace: 'pre',+ fontFamily: 'var(--font-family-mono, ui-monospace, monospace)',+ fontSize: 'var(--text-xsm, 12px)',+ color: 'var(--color-content-primary)',+ backgroundColor: 'var(--color-background-base)',+ borderRadius: 'var(--radius-inner)',+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: 'var(--color-border)',+ padding: 'var(--spacing-3)',+ margin: 0,+ maxHeight: 360,+ overflow: 'auto',+ },+ echo: {+ whiteSpace: 'pre-wrap',+ fontFamily: 'var(--font-family-mono, ui-monospace, monospace)',+ fontSize: 'var(--text-xsm, 12px)',+ color: 'var(--color-content-secondary)',+ backgroundColor: 'var(--color-background-muted)',+ borderRadius: 'var(--radius-inner)',+ padding: 'var(--spacing-2)',+ margin: 0,+ overflowX: 'auto',+ },+ errorRow: {+ fontFamily: 'var(--font-family-mono, ui-monospace, monospace)',+ fontSize: 'var(--text-xsm, 12px)',+ },+ search: {+ width: '100%',+ padding: 'var(--spacing-2)',+ borderRadius: 'var(--radius-inner)',+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: 'var(--color-border)',+ backgroundColor: 'var(--color-background-base)',+ color: 'var(--color-content-primary)',+ fontSize: 'var(--text-sm, 13px)',+ },+ browser: {+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: 'var(--color-border)',+ borderRadius: 'var(--radius-inner)',+ maxHeight: 320,+ overflowY: 'auto',+ },+ catHeader: {+ position: 'sticky',+ top: 0,+ backgroundColor: 'var(--color-background-muted)',+ paddingBlock: 'var(--spacing-1)',+ paddingInline: 'var(--spacing-2)',+ fontSize: 'var(--text-2xs, 10px)',+ textTransform: 'uppercase',+ letterSpacing: '0.05em',+ color: 'var(--color-content-secondary)',+ borderBottomWidth: '1px',+ borderBottomStyle: 'solid',+ borderBottomColor: 'var(--color-border)',+ },+ row: {+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'center',+ gap: 'var(--spacing-2)',+ width: '100%',+ textAlign: 'start',+ paddingBlock: 'var(--spacing-1)',+ paddingInline: 'var(--spacing-2)',+ border: 'none',+ backgroundColor: {+ default: 'transparent',+ ':hover': 'var(--color-background-hover, var(--color-background-muted))',+ },+ cursor: 'pointer',+ color: 'var(--color-content-primary)',+ borderBottomWidth: '1px',+ borderBottomStyle: 'solid',+ borderBottomColor: 'var(--color-border-subtle, var(--color-border))',+ },+ rowActive: {+ backgroundColor: 'var(--color-background-active, var(--color-background-muted))',+ },+ rowLabel: {fontSize: 'var(--text-sm, 13px)', fontWeight: 600},+ rowExpr: {+ fontFamily: 'var(--font-family-mono, ui-monospace, monospace)',+ fontSize: 'var(--text-2xs, 11px)',+ color: 'var(--color-content-secondary)',+ whiteSpace: 'nowrap',+ overflow: 'hidden',+ textOverflow: 'ellipsis',+ maxWidth: '100%',+ },+ rowTok: {+ flexShrink: 0,+ fontVariantNumeric: 'tabular-nums',+ fontSize: 'var(--text-2xs, 11px)',+ color: 'var(--color-content-secondary)',+ },+ min0: {minWidth: 0},+});++function Metric({label, value, sub}: {label: string; value: string; sub?: string}) {+ return (+ <div {...stylex.props(s.metric)}>+ <Text type="supporting">{label}</Text>+ <Text weight="semibold" xstyle={s.metricValue}>+ {value}+ </Text>+ {sub && <Text type="supporting">{sub}</Text>}+ </div>+ );+}++export default function LayoutDSLPage() {+ const [expr, setExpr] = useState(XLE_EXAMPLES[0].expr);+ // 'surface' is the displayed dialect; parsing is always auto-detected, so a+ // compact expression never "fails" just because Outline is selected.+ const [surface, setSurface] = useState<Surface>('auto');+ const [query, setQuery] = useState('');+ const [activeLabel, setActiveLabel] = useState(XLE_EXAMPLES[0].label);+ const [copied, setCopied] = useState(false);+ const {count: countTokens, encoder} = useTokenCounter();++ const check = useMemo(+ () =>+ checkExpression(expr, xleData.registry, {+ blocks: xleData.blocks,+ form: 'auto',+ }),+ [expr],+ );++ const valid = check.ok && check.valid;++ const expanded = useMemo(+ () =>+ valid+ ? expandExpression(expr, xleData.registry, {+ blocks: xleData.blocks,+ form: 'auto',+ name: 'PlaygroundLayout',+ })+ : null,+ [expr, valid],+ );++ const inTokens = countTokens(expr);+ const outCode = expanded?.ok ? expanded.code : '';+ const outTokens = outCode ? countTokens(outCode) : 0;++ const filtered = useMemo(() => {+ const q = query.trim().toLowerCase();+ if (!q) {+ return XLE_EXAMPLES;+ }+ return XLE_EXAMPLES.filter(+ e =>+ e.label.toLowerCase().includes(q) ||+ e.category.toLowerCase().includes(q) ||+ e.expr.toLowerCase().includes(q),+ );+ }, [query]);++ // Switching the dialect converts the current expression to that surface+ // (using the canonical printers) rather than forcing a mismatched parse.+ const switchSurface = (next: Surface) => {+ setSurface(next);+ if (next === 'auto') {+ return;+ }+ const c = checkExpression(expr, xleData.registry, {+ blocks: xleData.blocks,+ form: 'auto',+ });+ if (c.ok && c.valid) {+ const converted = next === 'compact' ? c.compact : c.outline;+ if (converted) {+ setExpr(converted);+ }+ }+ };++ const pick = (label: string, exprText: string) => {+ setActiveLabel(label);+ setExpr(exprText);+ setSurface('auto'); // examples carry their own surface; let auto-detect handle it+ };++ const copyCode = () => {+ if (!expanded?.ok) {+ return;+ }+ void navigator.clipboard?.writeText(expanded.code);+ setCopied(true);+ window.setTimeout(() => setCopied(false), 1500);+ };++ return (+ <div {...stylex.props(s.page)}>+ <VStack gap={1}>+ <Heading level={2}>Layout DSL</Heading>+ <Text type="supporting">+ Write a compressed layout expression (compact XLE or indented outline+ XLO). It is validated live against @astryxdesign/core; the expanded TSX+ and token counts update below. The whole pipeline runs in-browser via+ the @astryxdesign/cli/xle barrel.+ </Text>+ </VStack>++ <SegmentedControl+ label="Surface"+ size="sm"+ value={surface}+ onChange={v => v && switchSurface(v as Surface)}>+ <SegmentedControlItem value="auto" label="Auto" />+ <SegmentedControlItem value="compact" label="Compact (XLE)" />+ <SegmentedControlItem value="outline" label="Outline (XLO)" />+ </SegmentedControl>++ <textarea+ {...stylex.props(s.editor)}+ value={expr}+ spellCheck={false}+ onChange={e => setExpr(e.target.value)}+ aria-label="Layout expression"+ />++ <HStack gap={2} align="center">+ <Button+ variant="primary"+ size="sm"+ label={copied ? 'Copied!' : 'Copy expanded TSX'}+ isDisabled={!valid}+ onClick={copyCode}+ />+ <Badge+ variant={valid ? 'success' : 'error'}+ label={+ check.ok+ ? valid+ ? `Valid · ${check.form}`+ : `${check.errors.length} error${check.errors.length === 1 ? '' : 's'}`+ : 'Parse error'+ }+ />+ {valid && check.warnings.length > 0 && (+ <Badge variant="warning" label={`${check.warnings.length} warning`} />+ )}+ </HStack>++ {/* Token economics (BPE via gpt-tokenizer o200k_base; 'est.' until loaded) */}+ <div {...stylex.props(s.metrics)}>+ <Metric+ label={`XLE input · ${encoder}`}+ value={`${inTokens} tok`}+ sub={`${expr.length} chars`}+ />+ <Metric+ label={`Output TSX · ${encoder}`}+ value={`${outTokens} tok`}+ sub={outCode ? `${outCode.length} chars` : '—'}+ />+ <Metric+ label="Expansion"+ value={inTokens > 0 && outTokens > 0 ? `${(outTokens / inTokens).toFixed(1)}×` : '—'}+ sub="output ÷ input"+ />+ </div>++ {!valid && check.errors.length > 0 && (+ <VStack gap={1}>+ {check.errors.map((e, i) => (+ <Banner+ key={i}+ status="error"+ title={+ <span {...stylex.props(s.errorRow)}>+ {e.formatted}+ {e.suggestions && e.suggestions.length > 0+ ? ` — did you mean: ${e.suggestions.join(', ')}?`+ : ''}+ </span>+ }+ />+ ))}+ </VStack>+ )}++ {valid && expanded?.ok && (+ <VStack gap={1}>+ <HStack gap={2} align="center">+ <Text type="label">Rendered source (TSX)</Text>+ {expanded.componentsUsed.length > 0 && (+ <Text type="supporting">+ {expanded.componentsUsed.length} components+ {expanded.states ? ` · ${expanded.states} state hooks` : ''}+ {expanded.todos.length ? ` · ${expanded.todos.length} TODO` : ''}+ </Text>+ )}+ </HStack>+ <pre {...stylex.props(s.source)}>{expanded.code}</pre>+ </VStack>+ )}++ {valid && (+ <VStack gap={1}>+ <Text type="label">Canonical forms</Text>+ <pre {...stylex.props(s.echo)}>{`compact:\n${check.compact}\n\noutline:\n${check.outline}`}</pre>+ </VStack>+ )}++ {/* Example browser */}+ <VStack gap={1}>+ <HStack gap={2} align="center" justify="between">+ <Text type="label">Examples</Text>+ <Text type="supporting">+ {filtered.length} of {XLE_EXAMPLES.length}+ </Text>+ </HStack>+ <input+ {...stylex.props(s.search)}+ type="search"+ placeholder="Search examples (label, category, or expression)…"+ value={query}+ onChange={e => setQuery(e.target.value)}+ aria-label="Search examples"+ />+ <div {...stylex.props(s.browser)}>+ {XLE_CATEGORIES.map(cat => {+ const rows = filtered.filter(e => e.category === cat);+ if (rows.length === 0) {+ return null;+ }+ return (+ <div key={cat}>+ <div {...stylex.props(s.catHeader)}>{cat}</div>+ {rows.map(ex => (+ <button+ key={ex.label}+ type="button"+ {...stylex.props(s.row, ex.label === activeLabel && s.rowActive)}+ onClick={() => pick(ex.label, ex.expr)}>+ <VStack gap={0} xstyle={s.min0}>+ <span {...stylex.props(s.rowLabel)}>{ex.label}</span>+ <span {...stylex.props(s.rowExpr)}>+ {ex.expr.replace(/\n/g, ' ⏎ ')}+ </span>+ </VStack>+ <span {...stylex.props(s.rowTok)}>{countTokens(ex.expr)} tok</span>+ </button>+ ))}+ </div>+ );+ })}+ </div>+ </VStack>+ </div>+ );+}diff --git a/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/xleExamples.ts b/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/xleExamples.tsnew file mode 100644index 0000000000..3a69f0013b--- /dev/null+++ b/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/xleExamples.ts@@ -0,0 +1,95 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file XLE/XLO playground examples — every entry verified against the+ * validator. @generated-ish: curated then machine-formatted; edit the+ * source list in tooling rather than by hand.+ */++export type XLEExample = {category: string; label: string; expr: string};++export const XLE_EXAMPLES: XLEExample[] = [+ {category: "Pages", label: "Analytics dashboard", expr: "A[cp6 @topNav=TN @sideNav=SN] > L > LC > V[g6] > (H[j=between a=center] > Hd\"Analytics\"[level=2] + (H[g2] > B\"Export\" + B.primary\"New report\")) + (G[c4 g4] > (C[p6] > V[g1] > Tx.lg\"\\$42k\" + Tx[t=supporting]\"Revenue\")*4) + (G[c{min:340} g4] > C{card-callout} + C{card-callout}) + (C[p0] > T[striped] > (TR>THC\"Order\"+THC\"Customer\"+THC\"Status\"+THC\"Total\") + (TR>TC\"#10$\"+TC\"Acme Inc\"+(TC>Bd.success\"Paid\")+TC\"\\$120\")*5)"},+ {category: "Pages", label: "Settings page", expr: "A[cp6 @topNav=TN @sideNav=SN] > L > LC > S[p6] > V[g6] > Hd\"Settings\"[level=2] + (C[p6] > V[g4] > Hd\"Profile\"[level=4] + (F > TI\"Name\"[req] + TI\"Email\"[t=email req]) + B.primary\"Save\") + (C[p6] > V[g4] > Hd\"Notifications\"[level=4] + (H[j=between a=center] > Tx\"Email alerts\" + SW\"Email alerts\") + (H[j=between a=center] > Tx\"Push\" + SW\"Push\"))"},+ {category: "Pages", label: "Order detail", expr: "A[cp6 @topNav=TN] > L > LC > V[g6] > (H[j=between a=center] > (V[g1] > Hd\"Order #1042\"[level=2] + Tx[t=supporting]\"Created today\") + Bd.success\"Paid\") + (G[c{min:280} g6] > (C[p6] > V[g4] > Hd\"Items\"[level=4] + (T > (TR>THC\"Item\"+THC\"Qty\") + (TR>TC\"Widget\"+TC\"2\")*3)) + (C[p6] > V[g3] > Hd\"Customer\"[level=4] + (ML > MLI\"Name\":\"Acme\" + MLI\"Email\":\"[email protected]\" + MLI\"Plan\":\"Pro\")))"},+ {category: "Pages", label: "Users table page", expr: "A[cp6 @topNav=TN @sideNav=SN] > L > LC > V[g4] > (Tbar\"Users\" > B\"Filter\" + B\"Export\" + B.primary\"Invite\") + (C[p0] > T[striped] > (TR>THC\"Name\"+THC\"Role\"+THC\"Status\") + (TR>TC\"Person $\"+TC\"Engineer\"+(TC>Bd.success\"Active\"))*8) + (H[j=end] > PG[variant=count])"},+ {category: "Pages", label: "Pricing page", expr: "S[p8] > V[g8] > (Ctr > V[g2] > Hd\"Pricing\"[level=1] + Tx[t=supporting]\"Pick a plan that fits\") + (G[c3 g6] > (C[p6] > V[g4] > Hd\"Pro\"[level=3] + Tx.lg\"\\$29/mo\" + (UL > LI\"Feature one\" + LI\"Feature two\" + LI\"Feature three\") + B.primary\"Choose Pro\")*3)"},+ {category: "Pages", label: "Login split", expr: "G[c2 h=\"100dvh\"] > (S[p8 v=muted] > Ctr > V[g2] > Hd\"Acme\"[level=1] + Tx[t=supporting]\"Welcome back\") + (Ctr > C[w=360 p8] > V[g6] > (F > TI\"Email\"[t=email req] + TI\"Password\"[t=password req]) + (H[j=between a=center] > CB\"Remember me\" + Lk[href=\"/forgot\"]\"Forgot?\") + B.primary\"Sign in\")"},+ {category: "Pages", label: "Profile header", expr: "C[p6] > H[j=between a=center] > (H[g4 a=center] > Av + (V[g1] > Hd\"Jane Doe\"[level=3] + Tx[t=supporting]\"Product Designer\")) + (H[g2] > B\"Message\" + B.primary\"Follow\")"},+ {category: "Pages", label: "Kanban board", expr: "G[c3 g4] > (C[p4] > V[g3] > (H[j=between a=center] > Hd\"To Do\"[level=5] + Bd\"3\") + (V[g2] > (C[p3] > Tx\"Task item\")*3))*3"},+ {category: "Pages", label: "Dashboard with sidebar nav", expr: "A[cp0 @sideNav=(SN > (SNS\"Main\" > SNI\"Dashboard\" + SNI\"Reports\" + SNI\"Settings\"))] > L > LC > S[p6] > V[g6] > Hd\"Dashboard\"[level=2] + (G[c4 g4] > (C[p6] > V[g1] > Tx.lg\"128\" + Tx[t=supporting]\"Metric\")*4)"},+ {category: "Pages", label: "Feed with composer", expr: "Ctr > C[w=560 p0] > V > (C[p4] > V[g3] > (H[g2 a=center] > Av + Tx\"Share an update\") + (H[j=end] > B.primary\"Post\")) + D + (V[g0] > (C[p4] > V[g2] > (H[g2 a=center] > Av + (V[g0.5] > Tx\"User $\" + Tx[t=supporting]\"2h ago\")) + Tx\"A post body goes here.\")*3)"},+ {category: "Pages", label: "Two-column form", expr: "A[cp6 @topNav=TN] > L > LC > S[p6] > C[p6] > V[g4] > Hd\"New employee\"[level=3] + (G[c2 g4] > TI\"First name\"[req] + TI\"Last name\"[req] + TI\"Email\"[t=email req] + TI\"Phone\" + (RL\"Department\" > RLI\"Engineering\" + RLI\"Design\") + (CL\"Access\" > CLI\"Admin\" + CLI\"Billing\")) + (H[j=end g2] > B\"Cancel\" + B.primary\"Create\")"},+ {category: "Pages", label: "Stats + chart + activity", expr: "V[g6] > (G[c3 g4] > (C[p6] > V[g1] > Tx.lg\"\\$12k\" + Tx[t=supporting]\"This week\")*3) + (G[c{min:320} g6] > C{card-callout} + (C[p6] > V[g3] > Hd\"Recent activity\"[level=4] + (UL > LI\"Event one\" + LI\"Event two\" + LI\"Event three\")))"},+ {category: "Pages", label: "Confirm dialog flow", expr: "V[g4] > (Tbar\"Document\" > B\"Share\" + B.destructive\"Delete\"[opens=#del]) + (C[p6] > Tx\"Document body content\") ;; AD#del\"Delete this document?\""},+ {category: "Pages", label: "Outline settings (XLO)", expr: "AppShell cp=6\n topNav: TN\n sideNav: SN\n Layout > LayoutContent\n Section p=6\n VStack g=6\n Heading \"Settings\" level=2\n Card p=6\n VStack g=4\n Heading \"Profile\" level=4\n FormLayout\n TextInput \"Name\" req\n TextInput \"Email\" t=email req\n Button.primary \"Save\"\n Card p=6\n VStack g=4\n Heading \"Danger zone\" level=4\n Button.destructive \"Delete account\" opens=#del\n\noverlays:\n AlertDialog#del \"Delete your account?\""},+ {category: "Pages", label: "Outline product page (XLO)", expr: "Section p=8\n Grid c={min:320} g=8\n Card p=0\n Center h=240\n Text t=supporting \"Image\"\n VStack g=4\n Heading \"Product name\" level=1\n Text.lg \"\\$129\"\n Text t=supporting \"A short product description goes here.\"\n HStack g=2\n Button.primary \"Add to cart\"\n Button \"Save\""},+ {category: "Layout", label: "Centered box", expr: "Ctr[h=\"100dvh\"] > C[w=400 p8] > Tx\"Hello world\""},+ {category: "Layout", label: "App shell", expr: "A[cp6 @topNav=TN @sideNav=SN] > L > LC > S[p6] > Tx\"Page content\""},+ {category: "Layout", label: "App shell + header", expr: "A[cp4 @topNav=TN] > L > LH\"Page header\" + LC > S[p4] > Tx\"Body\""},+ {category: "Layout", label: "Vertical stack", expr: "V[g4] > Tx\"One\" + Tx\"Two\" + Tx\"Three\""},+ {category: "Layout", label: "Spread row", expr: "H[j=between a=center] > Tx.lg\"Title\" + B.primary\"Action\""},+ {category: "Layout", label: "Grid 4-up", expr: "G[c4 g4] > C[p6]*4"},+ {category: "Layout", label: "Responsive grid", expr: "G[c{min:320} g4] > C{card-callout}*3"},+ {category: "Layout", label: "Section muted", expr: "S[p6 v=muted] > Tx\"Muted section\""},+ {category: "Layout", label: "Nested stacks", expr: "V[g6] > (H[j=between] > Tx.lg\"Header\" + B\"Edit\") + (G[c3 g4] > C[p4]*3)"},+ {category: "Layout", label: "Layout regions", expr: "L > LH\"Header\" + LC > S[p4] > Tx\"Body\""},+ {category: "Layout", label: "Divider between", expr: "V[g4] > Tx\"Above\" + D + Tx\"Below\""},+ {category: "Layout", label: "Fill stack item", expr: "H[g4] > Tx\"Fixed\" + (SI[size=fill] > Tx\"Grows\")"},+ {category: "Layout", label: "Toolbar + content", expr: "V[g4] > (Tbar\"Actions\" > B\"Filter\" + B.primary\"New\") + S[p4] > Tx\"Below toolbar\""},+ {category: "Cards", label: "Titled card", expr: "C[p6] > V[g2] > Hd\"Card title\"[level=3] + Tx[t=supporting]\"Supporting copy\""},+ {category: "Cards", label: "KPI tile", expr: "C[p6] > V[g1] > Tx.lg\"1,284\" + Tx[t=supporting]\"Active users\""},+ {category: "Cards", label: "KPI grid", expr: "G[c4 g4] > (C[p6] > V[g1] > Tx.lg\"\\$42k\" + Tx[t=supporting]\"Revenue\")*4"},+ {category: "Cards", label: "Clickable card", expr: "CC[p6] > H[j=between a=center] > Tx\"Open project\" + Ic[icon=arrow-right]"},+ {category: "Cards", label: "Card grid", expr: "G[c3 g4] > (C[p6] > V[g2] > Hd\"A\"[level=4] + Tx\"text\")*3"},+ {category: "Cards", label: "Callout block", expr: "S[p6] > C{card-callout}"},+ {category: "Cards", label: "Badge row", expr: "H[g2] > Bd.success\"Active\" + Bd.warning\"Pending\" + Bd.error\"Failed\" + Bd.info\"New\""},+ {category: "Cards", label: "Avatar row", expr: "H[g2 a=center] > Av + (V[g0.5] > Tx\"Jane Doe\" + Tx[t=supporting]\"Admin\")"},+ {category: "Cards", label: "Metadata list", expr: "C[p6] > ML > MLI\"Status\":\"Active\" + MLI\"Owner\":\"Jane\" + MLI\"Region\":\"us-east\""},+ {category: "Content", label: "List", expr: "UL > LI\"First item\" + LI\"Second item\" + LI\"Third item\""},+ {category: "Content", label: "Kbd hint", expr: "H[g2 a=center] > Tx\"Press\" + K\"mod+k\" + Tx\"to search\""},+ {category: "Content", label: "Headings scale", expr: "V[g3] > Hd\"H1\"[level=1] + Hd\"H2\"[level=2] + Hd\"H3\"[level=3]"},+ {category: "Content", label: "Text + link", expr: "H[g1] > Tx\"Read\" + Lk[href=\"/docs\"]\"the docs\""},+ {category: "Content", label: "Tokens", expr: "H[g2] > Tk\"react\" + Tk\"typescript\" + Tk\"stylex\""},+ {category: "Tables", label: "Simple table", expr: "C[p0] > T[striped] > (TR > THC\"Name\" + THC\"Email\") + (TR > TC\"Alice\" + TC\"[email protected]\")*5"},+ {category: "Tables", label: "Table + status cell", expr: "T > (TR > THC\"Service\" + THC\"Status\") + (TR > TC\"api-gateway\" + (TC > Bd.success\"Up\"))*4"},+ {category: "Tables", label: "Dense table", expr: "T[density=compact dividers=rows] > (TR > THC\"ID\" + THC\"Value\") + (TR > TC\"row-$\" + TC\"\\$12.00\")*6"},+ {category: "Tables", label: "Table in card", expr: "C[p0] > T[striped] > (TR>THC\"Item\"+THC\"Qty\") + (TR>TC\"Widget\"+TC\"3\")*3"},+ {category: "Forms", label: "Login form", expr: "Ctr[h=\"100dvh\"] > C[w=400 p8] > V[g6] > (F > TI\"Email\"[t=email req] + TI\"Password\"[t=password req]) + B.primary\"Sign in\""},+ {category: "Forms", label: "Field set", expr: "F > TI\"Full name\"[req] + TI\"Email\"[t=email req] + TA\"Bio\" + B.primary\"Save\""},+ {category: "Forms", label: "Inline controls", expr: "H[j=between a=center] > CB\"Remember me\" + Lk[href=\"/forgot\"]\"Forgot password?\""},+ {category: "Forms", label: "Number + switch", expr: "V[g4] > NI\"Quantity\" + (H[j=between a=center] > Tx\"Notifications\" + SW\"Enable notifications\")"},+ {category: "Forms", label: "Two column form", expr: "G[c2 g4] > TI\"First name\"[req] + TI\"Last name\"[req] + TI\"Email\"[t=email req] + TI\"Phone\""},+ {category: "Forms", label: "Checkbox list", expr: "CL\"Permissions\" > CLI\"Read\" + CLI\"Write\" + CLI\"Admin\""},+ {category: "Forms", label: "Radio list", expr: "RL\"Plan\" > RLI\"Free\" + RLI\"Pro\" + RLI\"Enterprise\""},+ {category: "Forms", label: "Slider", expr: "V[g4] > SL\"Volume\" + SL\"Brightness\""},+ {category: "Forms", label: "Date input", expr: "F > DI\"Start date\" + DI\"End date\""},+ {category: "Forms", label: "Search field", expr: "TI\"Search\"[t=text]"},+ {category: "Nav", label: "Tabs", expr: "TL > Tab\"Overview\"! + Tab\"Activity\" + Tab\"Settings\""},+ {category: "Nav", label: "Breadcrumbs", expr: "BC > BCI\"Home\"[href=\"/\"] + BCI\"Projects\"[href=\"/projects\"] + BCI\"Detail\""},+ {category: "Nav", label: "Segmented control", expr: "SG > SGI\"Day\" + SGI\"Week\" + SGI\"Month\""},+ {category: "Nav", label: "Top nav", expr: "TN > TNH\"Acme\" + TNI\"Docs\" + TNI\"Pricing\""},+ {category: "Nav", label: "Side nav", expr: "SN > (SNS\"Main\" > SNI\"Dashboard\" + SNI\"Reports\") + (SNS\"Settings\" > SNI\"Profile\")"},+ {category: "Nav", label: "Pagination", expr: "PG[variant=count]"},+ {category: "Nav", label: "Tabs + content", expr: "V[g4] > (TL > Tab\"All\"! + Tab\"Active\") + S[p4] > Tx\"Tab body\""},+ {category: "Feedback", label: "Success banner", expr: "Bn.success\"Changes saved successfully\""},+ {category: "Feedback", label: "Empty state", expr: "ES\"No results found\"[description=\"Try adjusting your filters\"]"},+ {category: "Feedback", label: "Spinner", expr: "Ctr[h=200] > Sp"},+ {category: "Feedback", label: "Progress bar", expr: "V[g4] > PB[value=60] + PB[value=90]"},+ {category: "Feedback", label: "Skeletons", expr: "V[g2] > Sk*4"},+ {category: "Feedback", label: "Delete dialog", expr: "V > B.destructive\"Delete\"[opens=#confirm] ;; AD#confirm\"Delete this item?\""},+ {category: "Feedback", label: "Status dots", expr: "V[g2] > (H[g2 a=center] > SD.success + Tx\"Operational\") + (H[g2 a=center] > SD.error + Tx\"Outage\")"},+ {category: "Feedback", label: "Toolbar actions", expr: "Tbar\"Actions\" > B\"Filter\" + B\"Export\" + B.primary\"New\""},+ {category: "Blocks", label: "Splice block", expr: "S[p6] > C{card-callout}"},+ {category: "Blocks", label: "Block grid", expr: "G[c2 g4] > {card-callout}*2"},+ {category: "Blocks", label: "Standalone block", expr: "{card-callout}"},+ {category: "Outline", label: "Outline app shell", expr: "AppShell cp=6\n topNav: TN\n Layout > LayoutContent\n Section p=6\n Grid cols=4 gap=4\n Card p=6 x4"},+ {category: "Outline", label: "Outline form", expr: "Center h=\"100dvh\"\n Card w=400 p=8\n VStack g=6\n FormLayout\n TextInput \"Email\" t=email req\n TextInput \"Password\" t=password req\n Button.primary \"Sign in\""},+ {category: "Outline", label: "Outline dashboard", expr: "Section p=6\n VStack g=6\n HStack j=between a=center\n Heading \"Dashboard\" level=2\n Button.primary \"New\"\n Grid c=4 g=4\n Card {card-callout} x4"},+ {category: "Outline", label: "Outline table", expr: "Card p=0\n Table striped\n TableRow\n TableHeaderCell \"Name\"\n TableHeaderCell \"Role\"\n repeat 4:\n TableRow\n TableCell \"Person\"\n TableCell \"Engineer\""},+ {category: "Outline", label: "Outline with overlay", expr: "VStack g=4\n Button.destructive \"Delete\" opens=#confirm\n\noverlays:\n AlertDialog#confirm \"Delete this item?\""},+ {category: "Outline", label: "Outline tabs", expr: "VStack g=4\n TabList\n Tab \"Overview\" !\n Tab \"Activity\"\n Tab \"Settings\"\n Section p=4\n Text \"Tab content\""},+ {category: "Chat", label: "Chat layout", expr: "ChL > ChML > ChS\"Today\" + (ChM > ChB\"Hello there\") + (ChM > ChB\"Hi, how can I help?\")"},+];++export const XLE_CATEGORIES = [...new Set(XLE_EXAMPLES.map(e => e.category))];diff --git a/apps/sandbox/src/app/sandboxPages.ts b/apps/sandbox/src/app/sandboxPages.tsindex 31670eecaa..12f1967106 100644--- a/apps/sandbox/src/app/sandboxPages.ts+++ b/apps/sandbox/src/app/sandboxPages.ts@@ -160,6 +160,12 @@ export const categories: SandboxCategory[] = [slug: 'tools',description: 'Interactive tools for building and exploring Astryx components.',pages: [+ {+ name: 'Layout DSL',+ href: '/pages/layout-dsl/',+ description:+ 'Write compressed XLE/XLO layout expressions and expand them to TSX with live token metrics',+ },{name: 'CodeBlock Perf',href: '/pages/codeblock-perf/',