Last active
September 12, 2021 23:40
-
-
Save rogie/c88a80b8c911ea2e6cc57af45969cb07 to your computer and use it in GitHub Desktop.
Insert Components from Figma published team library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function insertAllComponentsFromFile(){ | |
| // Uses the Web api..more here https://www.figma.com/developers/api#files-endpoints | |
| // Ideally, you don't hit this api every time the plugin runs, but maybe use figma.clientStorage | |
| // to store the keys for a set amount of time, then refresh on expiration | |
| let result = await fetch('https://api.figma.com/v1/files/08U6xAT28gUfHkx2l2kUhc', { | |
| method: 'GET', | |
| headers: { | |
| 'X-Figma-Token': '236259-788a3c64-e9b2-4ca2-851b-193954b2ad6d' | |
| } | |
| }) | |
| let figmaFile = await result.json() | |
| for(var id in figmaFile.components){ | |
| let component = figmaFile.components[id] | |
| // See also: importComponentSetByKeyAsync, importStyleByKeyAsync | |
| let c = await figma.importComponentByKeyAsync(component.key) | |
| let instance = c.createInstance() | |
| } | |
| } | |
| insertAllComponentsFromFile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment