Skip to content

Instantly share code, notes, and snippets.

@alexismo
Created March 19, 2024 18:15
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 alexismo/7a1d974f2dd1fadcf865870d5a2a5f95 to your computer and use it in GitHub Desktop.
Save alexismo/7a1d974f2dd1fadcf865870d5a2a5f95 to your computer and use it in GitHub Desktop.
Find consumers of an Effect style in a Figma file.
// based on https://gist.github.com/thomas-lowry/4d2d890ae5dfd4ab4eccebc4da99d52d with added return safety
const getPage = (node) => {
let item = node;
while (item && item.type !== "PAGE") {
item = item.parent;
}
// Return item if it's a PAGE node, otherwise return an empty string
return item?.type === "PAGE" ? item : "";
};
// pages without a parent are in a different document.
figma
.getLocalEffectStyles()
.filter((s) => s.name === "effect-name")[0]
.consumers.filter((p) => getPage(p.node) !== "");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment