code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

How to implement Code Connect if in Figma have a toggle

Open pttchsswk opened this issue 1 year ago • 4 comments

in Figma I have a toggle "is Unavailable" (can be "Yes", "No") Screenshot 2567-06-24 at 13 59 04

in component.figma.tsx

  AvatarCTA,
  "https://www.figma.com/design/213213213wasfasdasdsad/asdsadasdsad-%26-Organisms?node-id=13-sssad&m=dev",
  {
    props: {
      label: figma.string("Label"),
      showDescription: figma.boolean("show Description"),
      isUnavailable: figma.boolean("is Unavailable"),
    },
    example: (props) => <AvatarCTA isUnAvailable={props.isUnavailable} />,
  }
);```

I want to show code in connect at figma like

`<AvatarCTA isUnAvailable={true} /> // when isUnavailable toggle is Yes`
`<AvatarCTA isUnAvailable={false} /> // when isUnavailable toggle is No`

how should I implement?

very urgent please help

pttchsswk avatar Jun 24 '24 07:06 pttchsswk

Hi, this seems like code that should work. What issue are you seeing when publishing?

ptomas-figma avatar Jun 24 '24 23:06 ptomas-figma

Hi @ptomas-figma thanks for your support

this my code Screenshot 2567-06-25 at 10 10 34

and this is result

  • showIcon props is not visible Screenshot 2567-06-25 at 10 09 38

how should I implement code to show showIcon like red text in second image?

pttchsswk avatar Jun 25 '24 03:06 pttchsswk

Hi @pttchsswk! Your examples look correct. I'm not able to reproduce this, I'd like to get some more information here if possible. What are the different values of show Icon - is it "Yes" / "No" like in the original post? Could you screenshot what the variant configuration looks like in design mode?

One note is that we omit falsy props entirely, and we pass true like this:

<Button showIcon />

Will this work for you or do you need to be able to explicitly pass false as in showIcon={false} ?

karlpetersson avatar Jun 25 '24 13:06 karlpetersson

Hey again - I was able to reproduce this issue now. A possible workaround for this is to rename the values of show Icon to "True" or "False" (case sensitive) in Figma - this seems to be an issue if lowercase values are used like "yes" or "true". Let me know if that works for you. In any case, we'll aim to have this fixed in the next release

karlpetersson avatar Jun 25 '24 17:06 karlpetersson