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

Rendering different code based on the parent component. Is it possible?

Open rkieru opened this issue 1 year ago • 3 comments

In Figma we rely on a List primitive to output a type of UI across multiple components. So for example:

  • Select Dropdown
  • Side Navigation
  • Mobile Navigation

These 3 components may all use the List primitive. But in our SDK implementation we do not use the same component for each.

Is there a way to identify through code connect when a "List" is being consumed in "Component A" vs. "Component B" and based on that offer a different output?

rkieru avatar Sep 17 '24 19:09 rkieru

@rkieru I had this same exact question. I gave a longer, more annoying version of this question here 😛

ericandrewscott avatar Sep 17 '24 20:09 ericandrewscott

I think it would be nice if we could provide an optional param to figma.children. I could see it looking like:

children: figma.children("_ / ListItem", <DropdownListItem>),

or:

children: figma.children(["_ / ListItem", "_ / Icon"], [<DropdownListItem>, <DropdownIcon>]),

Figma friends, do you accept PRs from forks?

ericandrewscott avatar Sep 19 '24 15:09 ericandrewscott

I would like to follow up on this feature as it would be of great utility to my team. Being able to assign “Instance of Child X in Component A” to a specific code connect asset allows our designers to reuse components in Figma, while still allowing the SDK output to reflect accurately.

rkieru avatar Apr 24 '25 02:04 rkieru