Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save NoWorries/e2107d83f67d29a6d81b355e3edfe714 to your computer and use it in GitHub Desktop.
Save NoWorries/e2107d83f67d29a6d81b355e3edfe714 to your computer and use it in GitHub Desktop.
const doc = figma.currentPage.parent as DocumentNode;
const CountIndividual = [];
const CountSet = [];
const CountVariant = [];
const PublishedNames = [];
const HiddenNames = [];
for (let p = 0; p < doc.children.length; p++) {
const page = doc.children[p];
const Components = page.findAllWithCriteria({
types: ['COMPONENT', 'COMPONENT_SET']
})
for (let i = 0; i < Components.length; i++) {
const component = Components[i] as any;
const status = await component.getPublishStatusAsync();
if (component.type === "COMPONENT_SET"){
CountSet.push(component);
} else if (component.parent.type === "COMPONENT_SET"){
CountVariant.push(component);
} else if(component.type === "COMPONENT" && component.parent.type != "COMPONENT_SET"){
CountIndividual.push(component);
};
if (component.name.startsWith("_") || component.name.startsWith(".")) {
HiddenNames.push(component.name);
} else {
PublishedNames.push(component.name);
}
}
}
console.log(`COMPONENT_SET count: ${CountSet.length}`);
console.log(`VARIANT count: ${CountVariant.length}`);
console.log(`COMPONENT count: ${CountIndividual.length}`);
console.log(`Published count: ${PublishedNames.length}`);
console.log(`Hidden count: ${HiddenNames.length}`);
// Hiding names arrays
//console.log(`Published names: ${PublishedNames}`);
//console.log(`Hidden names: ${HiddenNames}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment