SASS/SCSS and Grunt are fantastic tools to organize and automatize css development. With some easy adjustments you can even make grunt to compile your css for multiple color schemes.
Build your base SASS color scheme
The easiest way to prepare your files for auto-compiling SASS color schemes is to create a color variable for every color you want to change in your schemes. You should do that in a separate section of your code, so you can easily copy all color variables and create a new color scheme. The only thing you have to think of is to add the default-attribute to the variables, so they can be overridden. I usually and up wit a section like that in my styles:
/* * Default colors */ $light: #fafaf9 !default; $dark: #111111 !default; $color-1: #ef4f47 !default; $color-2: #75d9c6 !default; $color-3: #ffe851 !default;
Preparing additional SASS color schemes
The next step is to create all color scheme files. Create a folder called schemes or something like that put a file with the name color-scheme-1.scss in it. This file should define your color variables again (without the default-attribute) and include all other styles after the variables.
/* * Color scheme 1 */ $light: #efefef; $dark: #222; $color-1: red; $color-2: green; $color-3: blue; @import "../style";
Now you can create as much SASS color scheme files as you want, just repeat this pattern in every scheme.
Automated SASS color scheme Grunt task
Finally its time to setup your Grunt tasks. I assume you know how to compile SASS/SCSS via grunt, so the only thing to do is to add a sass-task for every scheme in you grunt-file:
sass: { dev: { src: 'scss/style.scss', dest: 'style.css' }, 'color-scheme-1': { src: 'scss/schemes/color-scheme-1.scss', dest: 'css/color-scheme-1.css' }, 'color-scheme-2': { src: 'scss/schemes/color-scheme-2.scss', dest: 'css/color-scheme-2.css' } },
Now run
grunt sass:color-scheme-1
and you get a color-scheme-1.css file in your css-directory. If you include this file instead of your default style.css, you will get your layout in the schemes colors. Auto generate all schemes with
grunt sass
Thanks a lot. It really helped me in creating multiple themes for my angular app.