Support for parsing instance().getProps() in nested props

Aperta
#307 0 commenti 6 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
49/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
typescript

Direzione di ricerca

Start by tracing how figma.nestedProps, figma.enum, and figma.instance().getProps() are parsed and emitted, using the example in the issue as the expected case. Check the relevant parser and output tests, then add coverage for the nested icon property mapping; done means the generated example preserves the requested instance property only when its enum condition is true.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature request

Our UX team is using nested components for reusability in Figma which has created a challenge for us when hooking it up to code connect. It seems like code connect isn't parsing instance().getProps in this example:

import figma from "@figma/code-connect";
import { Button } from "./DesignSystem/Button";

figma.connect(
  Button,
  "https://www.figma.com/design/example",
  {
    props: {
      type: figma.string("type"),
      disabled: figma.enum("state", {
        default: false,
        hover: false,
        disabled: true,
      }),
      buttonBaseProps: figma.nestedProps(".button-base", {
        size: figma.string("size"),
        label: figma.string("label"),
        leftIcon: figma.enum("has-left-icon", {
          true: figma.instance("left-icon").getProps().type,
          false: undefined,
        }),
        rightIcon: figma.enum("has-right-icon", {
          true: figma.instance("right-icon").getProps().type,
          false: undefined,
        }),
      }),
    },
    example: ({ type, disabled, buttonBaseProps }: { type: any; disabled: boolean; buttonBaseProps: any }) => (
      <Button
        type={type}
        size={buttonBaseProps.size}
        leftIcon={buttonBaseProps.leftIcon}
        rightIcon={buttonBaseProps.rightIcon}
        label={buttonBaseProps.label}
        disabled={disabled}
        onPress={() => {}}
      />
    ),
  }
);

Output in Figma:

import { Button } from "./DesignSystem/Button"

<Button
    type="primary"
    size="small"
    rightIcon={figma.instance("right-icon").getProps().type}
    label="Button"
    onPress={() => {}}
/>

Since we also need to handle the nested has-right-icon properties, it makes sense to use the enum to try to map the icon only when it's present. But then we need to access the type prop for the instance, as we are not passing the icon component to the button, just the type.

Lingua principale
TypeScript
Stelle
1.6k
Fork
126
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di figma/code-connect

Tutte le issue di figma/code-connect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.