Skip to content

Commit

Permalink
feat: save info file and move icons to files folder
Browse files Browse the repository at this point in the history
  • Loading branch information
feerglas committed Sep 7, 2020
1 parent a02b701 commit 659048c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion figmaExtractor/figmaIconsExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const config = {
},
frameIgnorePattern: '***ignore***',
output: {
folder: 'icons'
folder: 'icons',
subfolder: 'files',
infoFile: 'info'
}
};

Expand Down
15 changes: 13 additions & 2 deletions figmaExtractor/figmaWriteSvgData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@ const fs = require('fs');

module.exports = (iconData, config) => {

// make sure directory is there
// make sure folder is there
const outputFolder = `./${config.output.folder}`;

if (!fs.existsSync(outputFolder)) {
fs.mkdirSync(outputFolder);
}

// make sure subFolder exists
const subFolder = `${outputFolder}/${config.output.subfolder}`;

if (!fs.existsSync(subFolder)) {
fs.mkdirSync(subFolder);
}

// save icons
iconData.forEach((icon) => {
fs.writeFileSync(`${outputFolder}/${icon.name}.svg`, icon.svg);
fs.writeFileSync(`${subFolder}/${icon.name}.svg`, icon.svg);
});

// save info file
fs.writeFileSync(`${outputFolder}/${config.output.infoFile}.json`, JSON.stringify(iconData));

console.log('SVG INFO: saved svg\'s');

}
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions icons/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":"4:9","name":"SBB_03_plus","svg":"<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M20 12.5H12.5V20H11.5V12.5H4V11.5H11.5V4H12.5V11.5H20V12.5Z\" fill=\"black\"/>\n</svg>\n"},{"id":"9:3","name":"SBB_01_home 1","svg":"<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M19.8694 11.273L16.2306 7.8351V5.49096C16.2306 5.24694 16.021 5.05849 15.7611 5.05849C15.5178 5.05849 15.3166 5.24697 15.3166 5.49096V6.9752L12.3149 4.13464C12.223 4.04714 12.1137 4 12.0048 4C11.8791 4 11.77 4.0488 11.6778 4.13464L4.14015 11.2259C3.95932 11.3959 3.94735 11.6685 4.14015 11.825C4.30779 12.0067 4.5965 11.995 4.77731 11.825L12.0048 5.04165L19.2155 11.8889C19.2906 11.9596 19.3999 12 19.5425 12C19.6682 12 19.7771 11.9596 19.8694 11.8889C20.0372 11.7307 20.0497 11.4447 19.8694 11.273\" fill=\"black\"/>\n<path d=\"M17.5412 11C17.2728 11 17.065 11.2089 17.065 11.4812V18.0543H13.6884V15.3702C13.6884 15.1184 13.4806 14.8983 13.2294 14.8983H10.7879C10.5194 14.8983 10.3031 15.1184 10.3031 15.3702V18.0543H6.93497V11.6994C6.93497 11.4457 6.72737 11.235 6.4588 11.235C6.2078 11.235 6 11.4457 6 11.6994V18.5355C6 18.7892 6.2078 19 6.4588 19H10.7879C11.039 19 11.2467 18.7892 11.2467 18.5356V15.8515H12.7532V18.5356C12.7532 18.7892 12.961 19 13.2294 19H17.5412C17.7922 19 18 18.7892 18 18.5356V11.4812C18 11.2089 17.7922 11 17.5412 11Z\" fill=\"black\"/>\n</svg>\n"}]

0 comments on commit 659048c

Please sign in to comment.