Last active
June 11, 2019 22:54
-
-
Save PavelLaptev/e9005d8e9d3c3239aefe6dea2e6a0d75 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
async function getStylesArtboard(figmaApiKey, figmaId) { | |
const result = await fetch("https://api.figma.com/v1/files/" + figmaId, { | |
method: "GET", | |
headers: { | |
"X-Figma-Token": figmaApiKey | |
} | |
}); | |
const figmaTreeStructure = await result.json(); | |
const stylesArtboard = figmaTreeStructure.document.children.filter(item => { | |
return item.name === "styles"; | |
})[0].children; | |
baseTokeensJSON = { | |
token: { | |
grids: {}, | |
spacers: {}, | |
colors: {}, | |
fonts: {} | |
} | |
}; | |
Object.assign(baseTokeensJSON.token.grids, getGrids(stylesArtboard)); | |
Object.assign(baseTokeensJSON.token.spacers, getSpacers(stylesArtboard)); | |
Object.assign(baseTokeensJSON.token.colors, getPalette(stylesArtboard)); | |
Object.assign(baseTokeensJSON.token.fonts, getFontStyles(stylesArtboard)); | |
return baseTokeensJSON; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment