Skip to content

Instantly share code, notes, and snippets.

@GitSquared
Created September 30, 2017 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitSquared/c09709787c136ffa024ef9a6d97d3b62 to your computer and use it in GitHub Desktop.
Save GitSquared/c09709787c136ffa024ef9a6d97d3b62 to your computer and use it in GitHub Desktop.
Colorify a whole CSS theme using color.js
const Color = require('color');
const colorifyTarget = Color("#bee6c1");
let original = require('fs').readFileSync("original.css", {encoding: "utf-8"});
console.log(original);
let colorified = original.replace(/(#{1}[0-g]{6})+/ig, (match) => {
console.log(match);
return Color(match).grayscale().mix(colorifyTarget, 0.3).hex(); // Edit colorify options here
});
console.log(colorified);
require('fs').writeFileSync("new.css", colorified);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment