Access bound Figma variable names in Template API

オープン
#390 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
figma, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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,
)
主要言語
TypeScript
スター
1.6k
フォーク
126
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

figma/code-connect のほかの issue

figma/code-connect の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。