Skip to content

Instantly share code, notes, and snippets.

@PavelLaptev
Last active June 11, 2019 22:54
Show Gist options
  • Save PavelLaptev/e9005d8e9d3c3239aefe6dea2e6a0d75 to your computer and use it in GitHub Desktop.
Save PavelLaptev/e9005d8e9d3c3239aefe6dea2e6a0d75 to your computer and use it in GitHub Desktop.
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