Last active
May 23, 2022 02:35
-
-
Save hiloki/fd888d38137350a607ba09672f20c5e1 to your computer and use it in GitHub Desktop.
Figma Plugin scripts: Find main component in the frames
This file contains 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
// Select any nodes | |
const selection = figma.currentPage.selection; | |
const components = selection.map(node => { | |
if("children" in node) { | |
// Find “COMPONENT” type node | |
const nodes = node.findAllWithCriteria({ | |
types: ['COMPONENT'] | |
}) | |
return nodes; | |
} | |
}) | |
// Reselect Main Components | |
figma.currentPage.selection = components.flat(); | |
// Show result at the notification | |
figma.notify(`Find ${components.flat().length} components 🕵️♂️`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment