-
-
Save mattborn/6ae8f30f046b542b356e6551de51ec32 to your computer and use it in GitHub Desktop.
Sketch color palette generator
This file contains 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
node_modules | |
*.sketchpalette |
This file contains 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
var fs = require('fs'); | |
var request = require('request'); | |
var colorsArr = []; | |
function formatPaletteString(arr) { | |
return '{"compatibleVersion":"1.0","pluginVersion":"1.3","colors":['+ arr.join(',') +']}'; | |
} | |
request('https://assets.brand.ai/sprout-social/sprout-social/style-data.json?key=SJnrgI_r', function (err, res, body) { | |
var colorsObj = JSON.parse(body).colors; | |
var colorKeys = Object.keys(colorsObj); | |
colorKeys.forEach(function (color) { | |
var index = colorKeys.indexOf(color) + 1; | |
if (index % 6) { | |
colorsArr.push('"'+ colorsObj[color] +'"'); | |
} else { | |
colorsArr.push('"'+ colorsObj[color] +'","#ffffff","#ffffff"'); | |
} | |
if (index === colorKeys.length - 1) { | |
fs.writeFile('sketchpal-'+ Date.now() +'.sketchpalette', formatPaletteString(colorsArr)); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment