Skip to content

Token references on dimension styles are applied as resolved values, dropping the binding #289

Description

@nathanacurtis

A $token reference is replaced by the number it resolved to, so the rendered node carries a literal instead of a bound variable and the reference is gone on read-back.

Evidence

component path baseline round-trip
FormErrorMessage default.elements.errorIcon.styles.width {$token: "Constants/Sizing/4x", $type: dimension} 16
CheckboxGroup default.elements.errorIcon.styles.width {$token: "Constants/Sizing/4x", $type: dimension} 16

Same shape appears on root.styles.height (3 components), root.styles.width (2) and root.styles.opacity (2) across the aligned set.

Not the same as the opacity crash

A sibling issue covers opacity receiving an unresolved token object and throwing. That is the opposite direction — there the token is not resolved at all, here it is resolved and the binding discarded. Fix them separately or the two changes will fight.

Where

packages/figma-from-specs/src/Styles/Styles.ts (StylesApplier), Styles/resolve.ts, and VariableResolver.ts. Exact handler not identified. The question to answer first: does the writer bind the Figma variable to the property, or only compute and apply its value?

Fixtures

  • FormErrorMessage — 5 total differences, of which this is the only non-metadata one. The cleanest possible reproduction.
  • CheckboxGroup — 19 differences, same defect on the same path plus aspectRatio.

Verification

Round-trip both. errorIcon.styles.width comes back as {$token: "Constants/Sizing/4x", $type: dimension}. Inspect the rendered node in Figma and confirm the width is a bound variable, not a literal — a round-trip that merely re-derives the token name is not the same as a bound property.

Part of #281.

Metadata

Metadata

Assignees

No one assigned

    Labels

    generatorspecs-from-figma processing engine

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions