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

Đang mở
#324 2 bình luận 6 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
28/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
developer-experience

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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. :-)

Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
126
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của figma/code-connect

Tất cả issue của figma/code-connect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.