Skip to content

Instantly share code, notes, and snippets.

@albinekb
Created October 21, 2014 10:14
Show Gist options
  • Save albinekb/4702cee2f5c46a22d3d5 to your computer and use it in GitHub Desktop.
Save albinekb/4702cee2f5c46a22d3d5 to your computer and use it in GitHub Desktop.
// run at http://www.google.com/design/spec/style/color.html#color-ui-color-palette
var hex = "";
var rgb = "";
var g = document.getElementsByClassName('color-group');
for (var i = 0; i < g.length; i++){
var c = g[i].getElementsByClassName('color');
var title = c[0].textContent.split('\n')[1].replace(/\s+/g, '');
title = title.charAt(0).toLowerCase() + title.substring(1);
for (var a = 1; a < c.length; a++){
hex += ('@' + title + '--' + c[a].textContent.split('#')[0] + ': #' + c[a].textContent.split('#')[1] + ';\n')
rgb += ('@' + title + '--' + c[a].textContent.split('#')[0] + ': ' + c[a].style.backgroundColor + ';\n')
}
}
console.log(hex);
console.log(rgb);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment