Created
April 25, 2020 09:39
-
-
Save PavelLaptev/9bdccfc79b7e247c45e27bb8d4efe3de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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