Skip to main content
Question

Getting export settings from the main component in a team library

  • July 21, 2024
  • 1 reply
  • 33 views

BrickBuiltBen

Please excuse me…I’m not a professional developer. I’m trying to write a plugin that is able to find the export settings (set by the user in the app) of a component in a team library when I pull an instance. In the console, I get [object, Object] for mainComponent.exportSettings:

figma.on('selectionchange', async () => {
  const selection = figma.currentPage.selection;
  const instance = selection[0];
  if(instance.type === "INSTANCE" && selection.length === 1){
    const mainComponent = await instance.getMainComponentAsync();
    if(mainComponent){
      console.log("Main component: " + mainComponent.parent?.name);
      console.log("Main component's export settings: " + mainComponent.exportSettings);
      figma.closePlugin();
    }
  }

I’d really appreciate any help, especially if it’s accompanied by a good explanation (since, I’m trying to learn this stuff). Thanks!!!

This topic has been closed for replies.

1 reply

BrickBuiltBen

I figured out that my code IS actually working! The “mainComponent.exportSettings” might have been showing up as just [object, Object] in the console, but if I had actually applied those exportSettings to my instance, I would have seen that they carried through. Duh. Sorry.

A thing I discovered that may be of interest: When you change the export settings on a component, or a variant in a component set in a team library, it doesn’t register as publishable. The library shows “no changes” when I went to publish. I had to make some other change, like a color or something, for the changed export settings to publish along with the rest of the library. Weird.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings