Skip to content

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

@ZabGo

Description

@ZabGo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions