Access bound Figma variable names in Template API

Aperta
#390 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
figma, typescript

Direzione di ricerca

Start by reading the Template API entry points for getString(), getBoolean(), getEnum(), and getInstanceSwap(), then trace how visual properties such as fills and strokes are exposed from a Figma instance. Check existing Template API tests and identify how they verify property access. Done means templates can read a bound variable name for the requested property and the behavior is covered by tests.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature request

Problem

The Template API provides getString(), getBoolean(), getEnum(), getInstanceSwap() — but has no way to read bound Figma variables on visual properties (fills, strokes, text color).

When a component's fill color is set via a Figma variable (e.g. errorColor), the template cannot access that variable name to generate the correct code token.

Use Case

We have a Flutter Badge component where background color is controlled by bound Figma variables. The variable can be any color from our full design system palette — primaryColor, errorColor, successColor, warningColor, and many others. In code, these map directly to theme accessors:

PbBadge(
  value: 'Text',
  color: context.theme.primaryColor,
)

PbBadge(
  value: 'Error',
  color: context.theme.errorColor,
)

Currently the template cannot output color: at all — developers must manually look up the correct token.

Proposed API

instance.getBoundVariable('fills')    // → "primaryColor"
instance.getBoundVariable('strokes')  // → "borderColor"

Template usage (Flutter example):

const fillVar = instance.getBoundVariable('fills');
const colorPart = fillVar ? `\n  color: context.theme.${fillVar},` : "";

export default {
  example: figma.code`PbBadge(
  value: "${value}",${colorPart}
)`,
};

This would generate:

PbBadge(
  value: 'TextValue',
  color: context.theme.primaryColor,
)
Lingua principale
TypeScript
Stelle
1.6k
Fork
126
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di figma/code-connect

Tutte le issue di figma/code-connect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.