Skip to content

Component Lab - #12

Merged
bcsfreitas merged 24 commits into
mainfrom
component-lab
Nov 17, 2026
Merged

bcsfreitas merged 24 commits into
mainfrom
component-lab

Conversation

@bcsfreitas

@bcsfreitas bcsfreitas commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A new Lab area on the rail: a bench for one design-system component at a time, with Overview, Variants and Playground tabs. It reads the Systems module's build data and writes no files. It works the same in the local studio and on the deployed site.

/lab/<system id>/<component>                 Overview: guide, Source, Props, "Open in Systems"
/lab/<system id>/<component>/variants        every example in a grid, each with Show code / Copy code
/lab/<system id>/<component>/playground      the real component file + controls built from its props
<LabSystem> (src/modules/lab/pages/system.vue)
  <LabComponentList>            search, system picker, highlighted component
  <LabComponent>                header + LabTabBar, provideLabComponent()
    overview.vue                ComponentGuide · ComponentSource · ComponentProps (shared with Systems)
    variants.vue                LabVariantCard × examples → SystemPreview + per-example snippet
    playground.vue              LabPlaygroundStage + LabPlaygroundControls
sequenceDiagram
    participant Controls as Playground controls
    participant Stage as LabPlaygroundStage
    participant Doc as System preview document
    Controls->>Stage: values (also kept in the address)
    Stage->>Doc: { kind: 'props', props }
    Doc-->>Doc: mounted component updates in place (no reload)
    Doc->>Stage: { kind: 'update', prop, value } (Esc / ✕ on a Modal)
    Stage->>Controls: control follows
Loading

The other changes:

  • Preview runtime: each component with a component file gets a playground preview entry (playgroundId). The build leaves out a component file that doesn't compile, so one broken file can't stop yarn build.
  • Controls: they come only from defineProps metadata. A literal union becomes a select, boolean a switch, string a text field and number a number field. Any other type shows as "Set in code".
  • Variants: each variant's code is that example's own <Example> block, split on Node.
  • Systems: component pages gain "Open in Lab". ComponentSource, ComponentLoadErrors and the preview frame are now shared between Systems and the Lab. Systems pages behave as before.
  • Endless Studios: modal.vue and slideover.vue forward update:open, so Esc and ✕ close them in the Playground.
  • Docs: the Lab README, the Systems README, the document-component skill (what makes a good Playground) and GLOSSARY entries for Lab, Variant and Playground.

Out of scope, per the spec: the Experiments and In real screens tabs from the concept, and copying a Playground setup as code.

Evidence

  • yarn test: 123 files, 986/986 passing.
  • E2E on the dev server and the static build: lab, lab-variants, lab-playground, playground-preview, component-pages and systems pass. New scenarios cover:
    • tabs, addresses and the back button;
    • variants that fail alone;
    • props updating without a frame reload, values kept in and restored from the address, bad values ignored, Reset;
    • a Modal closing with Esc with its open control following;
    • a component that throws and then recovers;
    • the Playground following its file on disk;
    • a broken component file still letting the static build ship.
  • yarn lint, yarn format:check, yarn typecheck, yarn studio sync --check, yarn build and yarn build:inspect are clean.
  • CI is green on the head commit: all six browser-test shards (including every static build under a sub-path), unit and integration tests, lint, types and the production build. An earlier run caught the Lab's redirect pages pulling build-data JSON into the app's entry, which broke prerendering under a sub-path; they now load their lookups only when they run.
  • The Playground starts from the component's Default example (or its first example) when one exists, then from the prop's literal default.

Merge Danger

Door: two-way. The Lab is a new module that can be turned off in studio.config.json. Every other change is additive.

Blast Radius: Systems and the build.

  • Systems component pages share the extracted pieces and the preview frame with the Lab.
  • The build now bundles one playground entry per component file in each system's preview document, which adds startup weight per system.
  • The preview protocol gains two messages, props and update.

A new lab module with a rail button after Systems. /lab opens the default system's first component; the list has a search and, with more than one active system with components, a system picker. Each component has Overview, Variants and Playground tabs at their own addresses. Overview reuses the Systems guide, Source and Props; Variants and Playground are placeholders for now. The Systems component page links to the Lab, and Overview links back. The Source block and the load errors move into their own Systems components so both pages share them.
Each component with a component file gets a playground preview ID in its
system's preview document, listed beside its examples and named on the
catalog component. The preview protocol gains a props host message,
validated to plain JSON values.
The preview runtime mounts a playground entry's component file at its
defaults and applies each props message in place, deleting keys no longer
sent, so the component updates without remounting. Props that make it
throw report an error, and the next props mount it again.
LabPlaygroundStage shows it in a frame that fits its content up to a cap,
sending the props after each ready and whenever they change.
…er test

The rail order test now expects Prototypes, Systems, the Lab, then the Manual.
Each PropDoc becomes a select, switch, text, number or set-in-code row with a starting value; changed values round-trip through the query, dropping what no longer fits.
Every example of the examples file renders in its own SystemPreview,
two columns on a wide bench and one on a narrow one. SystemPreview
emits wide when an example's content outgrows its frame or stretches
across it, and that card takes the whole row.
Props from the component's metadata become labelled controls with their description on hover; changed values live in the address, Reset clears them. A component without a component file, with unreadable props, or with a required prop the panel can't fill says why.
The build stops on a component file it can't compile, so unreadable props are a dev-server-only scenario.
The component page data carries each example's snippet, cut from the
examples file by its top-level <Example name> blocks and dedented on
Node; a file the splitter can't read gives the whole file under every
example. Each variant gets Show code and Copy Code.
One broken component file stopped the whole static build once each component got a playground preview. The build now skips the playground of a file Vue can't compile, using the props reader's compile check, so the site ships and that Playground says its props can't be read. The dev server keeps every playground.
Reverts the workaround that removed the broken file from the static-build scenario.
# Conflicts:
#	src/modules/lab/README.md
The Lab README covers the stage's growth and errors and the build leaving out a playground that doesn't compile; the Systems README lists each component's playground preview; the document-component skill says what makes a good Playground; the glossary defines Lab, Variant and Playground.
A component that changes one of its own props (a modal closing with
Escape or its close button) tells the studio through a new preview
message, and that prop's control follows. Escape in the stage brings the
keyboard back to the control last used once any overlay has closed.
Reset stays enabled and announces itself, is left out when no prop has a
control, and the controls are disabled while the stage can't start.
The Endless Studios modal and slideover pass update:open on, as
v-model:open expects.
Each prop's description shows under its control and describes it, in
place of a hover tooltip. The component sits centred on the stage, which
stays in view while the controls scroll (beside them on wide screens,
above them and capped lower on narrow ones). When nothing on the stage
takes any room, a note under it says why it may be blank.
Copy code is in sentence case, styled like Show code beside it, and
named for its variant for screen readers. A copy the browser blocks says
so in plain words and points to Show code. Snippets have Unix line
endings even when the whole file stands in for a block. Each card's
title, preview and code are rows of the grid, so a row lines up.
The list's header names the system when there is no picker, and the
search matches descriptions after titles and addresses. Page not found
inside the Lab offers View components. Overview reads at the Systems
page's width. A Playground address with ignored values is rewritten
without them.
SystemPreviewFrame measures the preview document, sizes the iframe and
shows the loading and error messages; SystemPreview and the Playground
stage pass their sizes and words and act on the measured content. The
Lab's tab pages read the component's file stem from useLabComponent. A
component file's compile check is kept per file until its time or size
changes.
Through the Lab itself: a value that makes the component throw shows its
error on the stage and another value renders it again; locally, the
stage follows its component file on disk and keeps the chosen values;
and the tabs switch from the keyboard, the current one announced.
@netlify

netlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for ea-prototyping-playground ready!

Name Link
🔨 Latest commit 38f4bf5
🔍 Latest deploy log https://app.netlify.com/projects/ea-prototyping-playground/deploys/6afbc86038818e0a856d7d80
😎 Deploy Preview https://deploy-preview-12--ea-prototyping-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Each control now starts from the literal attributes of the component's own
tag in its Default example (or first example), read on Node beside the
snippet splitter and shipped as seeds in the component page data; then the
prop's literal default; then, for text that shows, a sample from its name.
Seeded starts reach the stage, stay out of the address and are where Reset
returns. A seeded prop emptied or set to Default is kept as an empty
parameter so it doesn't spring back.
Nuxt copies a page's definePageMeta middleware into the route table,
which ships in the app's entry chunk. The Lab's /lab and /lab/<system>
middleware imported useManifest and useSystemCatalog statically, so the
manifest and every module's build data URLs moved into the entry. The
entry's JSON assets then became prefetch links on every page, and under
a sub-path (STUDIO_BASE_PATH) the prerender crawler followed them to
404s and `nuxt generate` stopped.

The middleware now imports its lookups on demand from utils/redirects,
so the build data stays in the chunks of the pages that read it.
@bcsfreitas
bcsfreitas marked this pull request as ready for review November 17, 2026 03:34
@bcsfreitas
bcsfreitas merged commit 69236de into main Nov 17, 2026
14 checks passed
@bcsfreitas
bcsfreitas deleted the component-lab branch November 17, 2026 04:23
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