Skip to content

Single import statment with multiple components :: Nested instances #69

@Meloyski

Description

@Meloyski

Whenever using a nested instance of another component, the example that is pushed out provides two import statements: one for the original component and one for when the nested instance is being used. Is there a way to combine these into the same import statement?

Icon Component

import { Icon } from `@library`;

figma.connect(Icon, 'https://...', {
  props: ...,
  example: (props) => <Icon name="name" />,
});

Button Component

import { Button } from `@library`;

figma.connect(Button, 'https://...', {
  props: {
    label: figma.string('Label'),
    icon: figma.boolean('Show Icon', {
       true: figma.instance('Icon'),
       false: undefined,
    })
  }
  example: ({ label, icon }) => <Button icon={icon}>{label}</Button>,
});

Button Output in Figma

import { Button } from `@library`;
import { Icon } from `@library`;

<Button icon={<Icon name="name"} >
  Hey
</Button>

Is there a way that this can be combined into a single statement, dynamically?

import { Button, Icon } from `@library`;

...

Sorry, I couldn't find any information on it. Thanks! <3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions