Created
March 19, 2024 18:15
-
-
Save alexismo/7a1d974f2dd1fadcf865870d5a2a5f95 to your computer and use it in GitHub Desktop.
Find consumers of an Effect style in a Figma file.
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
// 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