bridge icon indicating copy to clipboard operation
bridge copied to clipboard

Codegen: FRAME nodes without `fill` (and the root frame) keep an unbound white default fill — no "no fill" syntax

Open deriazjulien opened this issue 2 months ago • 0 comments

Summary

Two related codegen behaviours in bridge-ds compile (7.3.1) leave unbound, hardcoded white fills in the generated design, contradicting the "no hardcoded values" guarantee:

  1. FRAME nodes without a fill field keep Figma's default fill. figma.createFrame() creates a frame with a solid #FFFFFF fill. Codegen only emits frame.fills = mf(var) when the scene graph declares fill; otherwise nothing is emitted, so the frame stays opaque white and unbound. Layout wrapper frames (a "Form" column, a "Heading" stack, an "Actions" row) are therefore white in dark mode.
  2. The compiler-generated root frame (root = figma.createFrame(); root.name = …; root.resize(…)) has the same default white fill, and the scene graph has no way to address it (no metadata.fill).

There is also no syntax for "no fill" in the scene graph — fill is a string token or absent — so the only compliant workaround is to bind every wrapper frame to a surface token ($color/bg/surface), which is semantically wrong for transparent wrappers and still leaves the root frame white.

Reproduction

Scene graph:

{ "type": "FRAME", "name": "Form", "layout": "VERTICAL", "gap": "$spacing/4", "fillH": true,
  "children": [ { "type": "INSTANCE", "name": "Email", "component": "Forms/Input Field" } ] }

After execution, Form.fills = [{ type: "SOLID", color: {1,1,1} }] with no boundVariables. Same for the root LoginScreen frame.

Checked with a snapshot script listing every node whose paint has no boundVariables.color: only these compiler-created defaults show up; every declared token is bound correctly.

Proposal

  • Emit frame.fills = [] for every FRAME (including the root) that has no fill in the scene graph — a wrapper frame should be transparent by default.
  • Optionally accept "fill": "none" explicitly, and metadata.fill (a $token) for the root frame.
  • Consider the same for strokes (frames have none by default, so no change needed there) and for RECTANGLE/ELLIPSE which default to grey #D9D9D9 when fill is omitted.

This would remove the last class of unbound paints from compiler output. Happy to send a PR.

deriazjulien avatar Sep 08 '26 12:09 deriazjulien