figma / code-snippet-editor-plugin

Translate component variants, properties, and more into dynamic code snippets for your design system.
https://www.figma.com/community/plugin/1311777988952403297/code-snippet-editor
MIT License
128 stars 11 forks source link

Getting access to each {{figma.children}} #34

Closed damalekguide closed 7 months ago

damalekguide commented 7 months ago

Hello! I'm working on making toggle button part of template, my toggle button is created in a way that it has always 2 node children. I have this challenge to get label props to one place in template and then get other children inside tag, ideally it would look something like this:

<ToggleButtonGroup
  {{figma.children.0}}
>
  {{figma.children.1}}
</ToggleButtonGroup>

So I can get this outcome

<ToggleButtonGroup
  label="Toggle button"
>
    <ToggleButton
      label="First"
      value="first"
    />
    <ToggleButton
      label="Last"
      value="last"
    />
</ToggleButtonGroup>

Would that be something worth pursuing? Or is there a way to do that right now?

jake-figma commented 7 months ago

Oh yes, interesting use case you have here. I'm still thinking over this one in #6. There are some thoughts in there about filtering children which i prefer to a fixed order-dependent solution. No current support, but definitely on my mind to solve!

ericandrewscott commented 7 months ago

Sorry. I just saw this and perhaps opened a duplicate issue. I would be super interested in order-dependent checking or even guard railing by checking other properties or data on figma.children[1] or figma.children.1.