I have a similar situation with user-created themes, and I came up with the following LESS mixin to help me manage color schemes created from several base colors:
//LESS 1.3.3 .color (@color, @amount: 100) { color: contrast(@color, darken(@color, lightness(@color) * (@amount / 100)), lighten(@color, (100 - lightness(@color)) * (@amount / 100)), 0.5); }
The above code was written for LESS 1.3.3, which has a different contrast function for the version of LESS that I usually use in Sublime Text 2! If this does not produce the expected result, try:
.color (@color, @amount: 100) { color: contrast(@color, lighten(@color, (100 - lightness(@color)) * (@amount / 100)), darken(@color, lightness(@color) * (@amount / 100)), 50%); }
This mixin works by creating a contrasting color based on the input color and the amount from 0 to 100 inclusive. 100 = full contrast (i.e. Black or White); 0 = no contrast (i.e. input color). For instance.
LESS
@c:
CSS
.c0 {color: #4f2634;} .c20 {color: #844057;} .c50 {color: #bf7a92;} .c80 {color: #e5cad3;} .c100 {color: #ffffff;}
This example obviously generates the color of the text, so it is useful for a given background color, but the same idea can be redefined for border colors, etc. Hope this helps.
source share