Last active
February 14, 2017 08:52
-
-
Save bhubr/426d74793f71d9b0c8d1d8c5745ee0aa to your computer and use it in GitHub Desktop.
Extract colors from flatuicolors.com
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
/* | |
I needed to get a quick flat color palette for a project of mine. | |
The one at https://flatuicolors.com/ is great. | |
Just go to the site, open your console and paste this. | |
It will generate a JSON array with each color and associated name. | |
*/ | |
output = '['; | |
const $divs = $('.color'); | |
const lastIndex = $divs.length - 1 | |
$('.color').each((index, div) => { | |
const $div = $(div); | |
const name = $div.find('span.color-name').html(); | |
output += '{"color":"' + $div.data('bg-color') + | |
'","name":"' + name + | |
'"}'; | |
if( index < lastIndex ) output += ','; | |
}); | |
output += ']'; | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment