[Compose] Passing the value of a Figma variable in another Figma variable

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
28/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript

調査の方向性

Start by reading the Compose Figma Connect documentation and tracing how Figma.mapping values are represented when generating component code. The issue provides a Kotlin example but names no repository files or tests, so first locate the Compose integration and its mapping tests. Done means mapped variable values render as their values instead of their variable names.

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

説明

API question

Hello, I'm trying to pass the value of a Figma variable in another figma variable as below (full Figma code connect doc down below):

@FigmaProperty(FigmaType.Text, "Title content")
val titleContent: String = "this is a title"

@FigmaProperty(FigmaType.Boolean, "hasTitle")
val hasTitle: String? = Figma.mapping(
    true to contentTitle,
    false to null
)

When I use hasTitle in the component, Figma displays the name of the variable contentTitle rather than its value.
So Figma shows this:

Notification(
    title = contentTitle, // hasTitle is set to true in the Figma instance
    descripton = descripton
)

Instead of this:

Notification(
    title = "this is my title"
    descripton = descripton
)

Here the full Figma code connect doc:

@FigmaConnect(url="http://figma.com/component1")
@FigmaVariant("Device", "Android")
class NotificationDoc {
    @FigmaProperty(FigmaType.Text, "Title content")
    val titleContent: String = "this is a title"

    @FigmaProperty(FigmaType.Boolean, "hasTitle")
    val hasTitle: String? = Figma.mapping(
        true to contentTitle,
        false to null
    )

    @FigmaProperty(FigmaType.Text, "description")
    val descripton: String = "this is a description"

    @FigmaProperty(FigmaType.Enum, "Variant")
    val type: ButtonType = Figma.mapping(
        "Primary" to ButtonType.Primary,
        "Secondary" to ButtonType.Secondary
    )

    @Composable
    fun Component() {
        Notification(
            title = hasTitle,
            descripton = descripton
        )
    }
}

Is there a way to display the value of the variable rather than the variable name?

Thank you for you help. :-)

主要言語
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 を短くまとめたダイジェスト。