figma / code-connect

A tool for connecting your design system components in code with your design system in Figma
MIT License
843 stars 64 forks source link

How can i change property of "nestedProps" depending on conditional #118

Closed jongjunpark closed 3 days ago

jongjunpark commented 1 month ago

How can I control it?

tomduncalf-figma commented 1 month ago

Hi, could you share your Code Connect for this? I'm not 100% clear on what the question is. Thanks

jongjunpark commented 1 month ago

Hi, @tomduncalf-figma. If stickyHeader is set to false, then nestedProps("Desktop") should have the properties type, withDescription, and closeButton. On the other hand, if stickyHeader is set to true, then nestedProps("Desktop") should not include these properties.

I think it can be set up like this code,

      stickyHeader: figma.boolean("stickyHeader", {
        true: undefined,
        false: figma.nestedProps("Desktop", {
          type: figma.enum("type", {
            leftAlign: "leftAlign",
            centerAlign: "centerAlign",
          }),
          closeButton: figma.boolean("closeButtton"),
          showHeadingText: figma.boolean("showHeadingText"),
        }),
      }),

but I'm getting an error saying "Could not find prop mapping for stickyHeader in the props object"

jongjunpark commented 1 month ago

Additionally, even though I set stickyHeader.type as an enum, it shows up as a string instead of an enum.

tomduncalf-figma commented 1 month ago

It might be easiest if we can see your Figma file and your full Code Connect file for this case. Assuming you don't want to share that publicly, you can contact Figma support, mentioning that you have been referred from Github and would like to share your files with the team, and they have a process to give us temporary access

karlpetersson commented 1 week ago

Hey! Just wanted to follow up here that we're including a fix for using figma.nestedProps in figma.boolean in the next release - it looks like it will hopefully solve this issue for you, will follow up here once we've made the release

tomduncalf-figma commented 3 days ago

We just released Code Connect v1.1.1 which should resolve this issue. Please feel free to reopen the issue or create a new one if you continue to have issues.