Skip to content

Render enum code-only props from nested single-variant instances #297

Description

@nathanacurtis

Problem

render rebuilds the hidden code-only props container for string, number, boolean and image props, but not enum ones.

An enum code-only prop is authored in Figma as a nested instance of a single-variant component whose variants supply the enumerated values. Rendering skips these with a warning, so the prop is lost on the way into Figma:

  • The spec declares the prop with its enum values and default
  • The rendered component has no corresponding property
  • Reading that component back drops the prop entirely

A Heading component's role prop is the clearest case — it survives every other stage of the pipeline but disappears through render.

Solution

Render an enum code-only prop as the nested instance the convention calls for, so it survives a spec → Figma → spec round-trip like every other code-only prop type.

Acceptance criteria

  • An enum code-only prop renders as a nested instance inside the code-only props container
  • A round-trip returns the prop with its enum values, default, and codeOnlyProp provenance intact
  • A component whose enum source cannot be resolved still degrades with a warning rather than failing the whole render

Workspace

Found during round-trip testing of code-only props support in render — specs rendered into Figma and read back, then diffed against the baseline.

Impacted code

  • specs-from-figma/packages/figma-from-specs/src/Props/CodeOnlyProps.ts — the write path that currently skips enum props
  • specs-from-figma/packages/specs-from-figma/src/Component/Props/CodeOnlyProps/InstanceCodeOnlyProp.ts — the read-side counterpart to mirror

Text fixtures

  • Heading (role)
  • Form Group Heading (role)

Notes

The blocker is resolution, not the container: the instance manifest carries no entry for the enum's source component, so the renderer has nothing to instantiate. Any fix likely needs the manifest extended to cover components referenced only from code-only props.

Related: string, number, boolean and image code-only props, plus slot anyOf, already round-trip losslessly. Nested boolean-gated code-only containers remain unsupported and are deliberately not covered here.


Implementation details are tracked internally.

Metadata

Metadata

Assignees

Projects

Status
Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions