How to Get the Icon Name from an Icon Instance in Figma Code Connect?

Aberta
#343 1 comentário 4 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
48/100
Tipo de issue
Documentação
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
figma, typescript
Domínio
tooling

Direção de pesquisa

Start with the Code Connect API documentation and the implementation for figma.instance, which the issue uses in its TypeScript example. Check whether the instance exposes a supported name or SVG property and how examples serialize it. Done means documenting a supported way to read the icon name, or clarifying that Code Connect does not expose one.

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

Descrição

API question

Please provide:

Summary
I am trying to extract the icon name (SVG name) from an icon instance in Figma using Code Connect, but I am not sure which property of the icon instance holds the actual name.

Details

Given an icon instance with these properties in the component:

Property Value
Button True
Is Toggled False
Ix Background False
Size Medium
Icon home (Instance type)
Badge False
Keyboard Focus False

And the following code structure:

{
  props: {
    icon: figma.instance('Icon'),
    size: figma.enum('Size', {
      'Extra Small': 'xs',
      Small: 's',
      Medium: 'm',
      Large: 'l',
    }),
    badge: figma.boolean('Badge'),
    button: figma.boolean('Button'),
    
  },
  example: (props: {
    icon: any;
    size?: string;
    badge?: boolean;
    button?: boolean;
  }) => html`
    <ct-icon
      icon="${props.icon}"
      size="${props.size}"
      badge="${props.badge}"
      button="${props.button}"
    >
    </ct-icon>
  `,
}

after publishing above code to figma, code connect code looks like as below,

<sh-icon
**icon="Code Connect Error: Unsupported type 'object' for attribute"**
size="m"
button
></sh-icon>

Question

How do I get the icon name from the icon instance?
From the properties above, is the Icon property (with value home) the correct way to get the icon name?
If not, which property or method should I use to get the SVG/icon name from the icon instance programmatically?

Expected Outcome

  • Guidance on which property contains the actual icon name.
  • Example on how to extract or read the icon name from the instance for further use.

Thank you!

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.