Skip to content

Commit

Permalink
fix: switch frames and texts to figma components
Browse files Browse the repository at this point in the history
  • Loading branch information
feerglas committed Aug 20, 2020
1 parent 1060dbf commit 3f7d93d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion figmaExtractor/figmaExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const config = {
frame: 'FRAME',
group: 'GROUP',
text: 'TEXT',
rectangle: 'RECTANGLE'
rectangle: 'RECTANGLE',
component: 'COMPONENT'
},
styleTypes: {
color: 'color',
Expand All @@ -41,6 +42,7 @@ const config = {

const figmaData = await figmaApi(apiConfig);
const figmaFrames = getFigmaFrames(figmaData, config);

const figmaJson = getFigmaJson(figmaFrames, config);

writeJson(figmaJson, config);
Expand Down
10 changes: 6 additions & 4 deletions figmaExtractor/figmaJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ const buildFinalJson = (children, finalJson, figmaType, styleProperty, config) =
while (children.length > 0) {
const child = children.pop();

if (child.type === figmaType) {
if (child.type === config.figma.childTypes.component) {
const realChild = child.children[0];
let value;

if (styleProperty === config.figma.styleTypes.color) {
value = rgbaToHex(child.fills[0].color);
value = rgbaToHex(realChild.fills[0].color);
} else if (styleProperty === config.figma.styleTypes.fontSize) {
value = child.style.fontSize;
value = realChild.style.fontSize;
}

finalJson[child.name] = {
finalJson[realChild.name] = {
value: value
};
} else if (child.type === config.figma.childTypes.group) {
Expand Down Expand Up @@ -77,4 +78,5 @@ module.exports = (frames, config) => {
}
}
};

};

0 comments on commit 3f7d93d

Please sign in to comment.