Plate My Component
Plate the Studio catalog preview (`apps/studio/src/lib/life-specimens/previews/<Name>.tsx`) for a shippable React component in packages/life/src. Use to showcase states and interactions in the docs catalog — not to replace the React implementation.
Production-ready: PRODUCTION_READY.md · Index. This skill supports visual regression / specimen parity only. Plating does not earn the green dot — only packages/life/src React meeting the full bar does (component-cycle).
Turn a Studio catalog preview (previews/<Name>.tsx, registered in preview-registration.ts) into something people can use immediately in the catalog and still explore every supported state. The specimen Preview in <Name>.docs.mdx must match what you plate here — see COMPONENT_DOCS.md. The specimen is a prototype for docs — the component that ships is the React module in packages/life/src/<Name>/. The preview must use the same variant and size names as that React component so the two never drift. Variant and size names follow Tatva when a counterpart exists (Tatva parity); show deprecated aliases only if Tatva still documents them. Previews inherit light as the default theme (data-theme / tokens from packages/life/design-system/tokens.css); verify dark via [data-theme="dark"]. Work in apps/studio/src/lib/life-specimens/previews/<Name>.tsx unless the user asks to change the product implementation. Register its lazy import and metadata in preview-registration.ts, then run pnpm --filter studio catalog:sync. Previews import @sarvam/life only.
Find the source of truth
- Read
AGENTS.mdand Life DESIGN.md for presentation, interaction, accessibility, icons, and focus (greyscale rings only). - Inspect
previews/<Name>.tsx, the shippablepackages/life/src/<Name>/index.tsx, and any reference the user supplied. Identify the default interaction, supported states, and expected outcomes. - Keep catalog metadata beside its loader in
preview-registration.ts. Put demo-only layout in the preview module, not in the shippable component. - Stage the specimen the way visual-direction composes a screen: the component on the ground plane (
--sv-background-canvas), realistic content, and the closest moodboard screen as the visual check.
One live component in the catalog
The catalog iframe loads previews with ?embedded=1. Studio specimen chrome CSS in apps/studio/src/lib/life-specimens/specimen-sync/specimen-embedded.css hides instructional chrome and centers the live example.
| Surface | What to show |
|---|---|
Catalog (embedded=1) | Only the interactive specimen instance (and any UI required for its default workflow). No titles, try-it copy, usage notes, or side-by-side state galleries (except the group view for variant × size components, below). |
Standalone preview (open in new tab, no embedded) | Optional specimen-chrome: headings, instructions, reset controls, and preview-note for authors. Mark chrome with specimen-chrome, or use existing hooks: .preview-instructions, .preview-note, .sc-demo-label, .preview-result. |
- Lead with one working specimen instance people can drive with pointer and keyboard. Use realistic fixtures; avoid stacking multiple labeled copies of the same pattern on one page.
- Put status feedback for the demo in
#resultwith classpreview-resultfor standalone use (hidden in embedded catalog).
Group view (only for variant × size components)
Some React components are understood fastest as a whole: many variants crossed with sizes. The group view renders that matrix with the exported Life component. For those, the catalog frame opens on a group view, an ordered variant × size matrix, and Configure → View switches to the single interactive instance. Everything else keeps the single live component above.
Decide first. Use a group view only when all of these hold:
- The component has two or more axes that multiply into a visual matrix: at least three variants (tone, treatment, font) and at least two sizes.
- The variants are static visual differences that a reader compares by eye (Button, Tag, Badge, Avatar sizes).
- Showing them side by side needs no explanation, instruction, or live data.
Do not use it when:
- The component is a workflow or overlay: menus, popovers, dialogs, composers, pickers, command palettes.
- Variants are behaviors rather than looks (loading, streaming, validation, multi-step), or it has only one size or one variant.
- The matrix would need scrolling, long labels, or fixtures to make sense.
If unsure, keep the single live component. State the decision and the reason in your report.
How:
- Use the React Button preview as the group-view reference. Render the exported Life component for each variant and size.
- Give the matrix accessible row and column labels. Use the component's own labels for visible content.
- Put View first in the Configure sections. Handle its value in React state and restore the default view on reset.
- Keep the live instance available in standalone mode.
- Icons: Hugeicons Stroke Standard only in specimens (bundled
stroke-standard/SVGs); Solid Standard only where fill/active state requires it.
Configure side panel (properties, not preset list)
Variations belong in the Configure side panel (header control beside the color palette), not as extra components on the page or a list of named presets.
The panel docks to the right of the preview (stacked on narrow viewports). Each row is a property: label on the left, control on the right—inset rows with toggles, selects, sliders, or actions.
- Register the React preview through Studio's
useLifeSpecimenPlatformhook. Pass the sections, the property change handler and the reset handler. Include the state used to build the sections in the hook's dependency list. - Build
sectionsas grouped fields:
type | Control | Fields |
|---|---|---|
boolean | Toggle | id, label, value |
select | Dropdown | id, label, value, options[] |
number | Slider + value | id, label, value, optional min / max / step |
action | Button | id, label, action: "reset" |
onChange(id, value)applies one property and updates the live preview deterministically.reset()restores defaults and re-registers field values when needed.- Derive field values from the same React state as the rendered example so in-preview changes reach Configure.
Parent ↔ iframe contract:
- Child → parent:
{ type: "specimen-configure", title, sections } - Parent → child:
{ type: "specimen-set", id, value }or{ type: "specimen-reset" }
Shortcut V toggles the panel when sections are registered.
Authoring checklist
- One primary interactive instance; no state matrix on the page, unless the component passes the group-view test, in which case the matrix is the default catalog view and Configure → View switches to the live instance.
- Register grouped configurable fields with
useLifeSpecimenPlatform. -
onChange+resetare deterministic and replayable. - Optional standalone-only chrome for authors, hidden when embedded.
- Keyboard paths and focus behavior work in the live instance (including overlays and dismissal) — aligns with PRODUCTION_READY APG keyboard and greyscale focus on the React side.
- Light and dark verified — supports PRODUCTION_READY light + dark.
Verify
Open /components/<Name> in the catalog: only the live React preview in the frame (or the group view for variant × size components, with Configure → View switching to it); Configure (V) opens the side panel with interactive properties. Open the standalone preview (header M) to confirm author chrome still helps when embedded is absent. Check light and dark and a narrow width. Return the catalog link and any state that could only be shown statically or was not verified.
Plating does not earn the catalog green dot. Complete PRODUCTION_READY.md on the React component. Orange T = Tatva parity, not production-ready.