Skip to content

Instantly share code, notes, and snippets.

@hiloki
Last active May 23, 2022 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiloki/fd888d38137350a607ba09672f20c5e1 to your computer and use it in GitHub Desktop.
Save hiloki/fd888d38137350a607ba09672f20c5e1 to your computer and use it in GitHub Desktop.
Figma Plugin scripts: Find main component in the frames
// 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