Access bound Figma variable names in Template API

Offen
#390 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
figma, typescript

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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,
)
Vorherrschende Sprache
TypeScript
Sterne
1.6k
Forks
126
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus figma/code-connect

Alle Issues in figma/code-connect

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.