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

Aberta
#324 2 comentários 6 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
28/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
typescript

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
1.6k
Forks
126
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de figma/code-connect

Todas as issues de figma/code-connect

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.