figma / code-connect

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

Can I combine string and children values and map them to one property? #92

Open alisonjoseph opened 4 months ago

alisonjoseph commented 4 months ago
titleItem: figma.nestedProps('_Contained list title item', {
  label: figma.boolean('Tooltip', {
    true: figma.string('List title text') + figma.children('Tooltip'), <--how can I do this?
    false: figma.string('List title text'),
  }),
}),
Chanki-Min commented 2 months ago

In this stage of code-connect (v 1.0.6) it is not possible. but we can get same results with variant restriction.

see this -> https://github.com/figma/code-connect/issues/80#issuecomment-2200476356

alisonjoseph commented 2 months ago

@Chanki-Min I'm not sure variant restrictions would help me here since its a nested prop, unless I missed something and variant restrictions support nesting.

higuchimmy commented 1 month ago

+1

@Chanki-Min In my case, there are multiple nested components that I want to display based on specific boolean conditions. I'd like this feature to be supported.

accentButton: figma.boolean('accentButton', {
  true: figma.nestedProps('Button', {
    variant: figma.enum('variant', {
      normal: 'normal',
      outlined: 'outlined',
    }),
  }) + figma.nestedProps('ButtonContent', {
    label: figma.string('label'),
  }), // Please support this case.
  false: {
    variant: undefined,
    label: undefined,
  },
}),