Repository navigation
Component Lab - #12
Merged
Merged
Conversation
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.
✅ Deploy Preview for ea-prototyping-playground ready!
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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 followsThe other changes:
playgroundId). The build leaves out a component file that doesn't compile, so one broken file can't stopyarn build.definePropsmetadata. A literal union becomes a select,booleana switch,stringa text field andnumbera number field. Any other type shows as "Set in code".<Example>block, split on Node.ComponentSource,ComponentLoadErrorsand the preview frame are now shared between Systems and the Lab. Systems pages behave as before.modal.vueandslideover.vueforwardupdate:open, so Esc and ✕ close them in the Playground.document-componentskill (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.lab,lab-variants,lab-playground,playground-preview,component-pagesandsystemspass. New scenarios cover:opencontrol following;yarn lint,yarn format:check,yarn typecheck,yarn studio sync --check,yarn buildandyarn build:inspectare clean.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.
propsandupdate.