Skip to content

Instantly share code, notes, and snippets.

@PavelLaptev
Created April 25, 2020 09:39
Show Gist options
  • Save PavelLaptev/9bdccfc79b7e247c45e27bb8d4efe3de to your computer and use it in GitHub Desktop.
Save PavelLaptev/9bdccfc79b7e247c45e27bb8d4efe3de to your computer and use it in GitHub Desktop.
export default function populateByName(selectedLayers, JSONobj, btnName) {
let newItem = 0;
const loopSelected = arr => {
arr.map(item => {
if (item.name.toUpperCase() === btnName.toUpperCase() && item.type === 'TEXT') {
figma.loadFontAsync(item.fontName).then(() => {
item.characters = JSONobj[newItem][btnName].toString();
newItem = ++newItem;
});
}
if (item.children) {
loopSelected(item.children);
}
});
};
loopSelected(selectedLayers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment