Skip to content

Render: honor invalid variant entries (invalid: true) #271

Description

@nathanacurtis

Remaining work

Variant entries flagged invalid: true (partial configurations) are treated as blanket exclusion rules. When they collapse the combination matrix to a single survivor, Component.write() takes the single-COMPONENT branch — no ComponentSet is created, no VARIANT properties are minted, and the round-tripped spec shows props: {} and nodeType: COMPONENT.

Approach

Branch on "spec has variant-typed props", not "more than one combination survived": figma.combineAsVariants([node], page) accepts a single element and still yields a COMPONENT_SET with real VARIANT property definitions.

Known ceiling

Figma derives variantOptions from actual sibling values — declared-but-unused enum options are unrecoverable when filtering collapses the matrix. nodeType and props presence are fixable; full enum breadth is not.

Affected fixtures

testInvalidVariants (also check testVariantsMissing1/2 for the same branch trap)

Where (code)

  • Branch trap: specs-from-figma/packages/figma-from-specs/src/Component.ts (write(), the resolved.length === 1 single-COMPONENT branch)
  • Exclusion filtering: src/Variants/Variants.ts (resolve(), invalidRules + isSubset)
  • Variant prop detection for the new condition: src/Props/Props.ts (isVariant)

Shared verification loop and working context: see parent #208.

Additional impacted fixture: testGradientStrokes (declares both invalid variants and invalidCombinations; its round-trip diff shows whole variant entries missing — 43 lines — after all #261 gradient math was fixed).

Metadata

Metadata

Assignees

Labels

generatorspecs-from-figma processing engine

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions