Skip to content

Commit faf4cdc

Browse files
committed
docs(codegen): tell codegen to read deduped instances' textOverrides
figma_to_code prompt + figma-codegen SKILL now spell out that a deduped instance carries textOverrides (its own visible text) — fill each repeated element's content from that, since structure is identical but text differs per instance, instead of copying the first instance's text, re-fetching the un-deduped tree, or drilling per instance. Follows the get_design_context textOverrides feature (7efc92d).
1 parent f55d3d1 commit faf4cdc

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

packages/server/src/prompts/figma-to-code.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const promptText = (nodeId: string | undefined): string => {
1616
nodeId === undefined ? '(they default to the current selection)' : `with nodeId "${nodeId}"`;
1717
return `Generate code for ${target} that matches this project — reuse what already exists, build only what is missing. Do not guess layout from a screenshot; ground every decision in these tools, called ${arg}:
1818
19-
1. get_design_context (detail: full, dedupeComponents: true) — the layout tree with tokens resolved to names and each instance's componentProperties. Do not depth-limit a subtree you intend to build from: the first instance of a repeated component keeps its full structure while later ones show "deduped". Per node, carry every visual property the tree exposes, not just layout: fills, strokes, cornerRadius, opacity, and especially effects (a node's effects / styleIds.effect = a drop/inner shadow or blur — translate it to the stack's shadow utility). Effects are the easiest fidelity to drop because they come from a shared effect style and read as a single field; a card with no shadow when the design has one is the classic grounding miss.
19+
1. get_design_context (detail: full, dedupeComponents: true) — the layout tree with tokens resolved to names and each instance's componentProperties. Do not depth-limit a subtree you intend to build from: the first instance of a repeated component keeps its full structure while later ones show "deduped". A deduped instance still carries textOverrides (the visible text it actually renders, { name, characters } per TEXT) — fill each repeated element's content from that, since the structure is identical but the text differs per instance; don't copy the first instance's text or re-fetch the un-deduped tree just to get distinct titles / labels / rows. Per node, carry every visual property the tree exposes, not just layout: fills, strokes, cornerRadius, opacity, and especially effects (a node's effects / styleIds.effect = a drop/inner shadow or blur — translate it to the stack's shadow utility). Effects are the easiest fidelity to drop because they come from a shared effect style and read as a single field; a card with no shadow when the design has one is the classic grounding miss.
2020
2121
2. component_map — every Figma component grouped to a local code component with a status.
2222
- high / medium: import and reuse candidate.filePath; do not regenerate it.

packages/skills/figma-codegen/SKILL.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ the rendered image.
3030
keeps one complete copy. A `deduped` (or `truncated`) sibling means "identical to the first one,
3131
reuse that structure"; a depth cap, by contrast, throws the structure away — that's the trap that
3232
makes repeated rows/cards look empty.
33+
- **Same structure, different content: read each deduped instance's `textOverrides`.** A `deduped`
34+
stub carries its own `textOverrides` (`{ name, characters }` for every visible TEXT it renders) —
35+
fill each repeated element's text from that, so the cards/rows/form-fields get their distinct
36+
titles / labels / values without re-expanding the un-deduped tree or drilling per instance.
3337
- **Carry per-node visual properties, not just layout.** Each node also exposes `fills`, `strokes`,
3438
`cornerRadius`, `opacity`, and **`effects` / `styleIds.effect`** — translate every one to the
3539
stack's equivalent. **Effects (drop/inner shadow, blur) are the easiest fidelity to lose**: they

0 commit comments

Comments
 (0)