I am trying to develop a 'theming engine' in LESS CSS to allow clients to update the colour scheme for their site with the least number of variables. At present we have a variables file where we are assigning the default set, and to shorthand the number of user inputs we utilise the lighten and darken functions a lot e.g.
// snippet 1
@grayLight: #999999;
@grayLighter: darken(@grayLight, 10%);
Is there a way in which the lighten/darken functions can be assigned as a variable? This way we only need to specify the tone contrast (dark/light or light/dark):
// snippet 2 (does not work)
@contrastVerb: darken;
@linkColorHover: @contrastVerb(@linkColor, 10%);//#FFA500;
I have tried using Javascript bracket notation to call the function request e.g.
// snippet 3 (does not work)
@linkColorHover: `window[@contrastVerb]`(@linkColor, 10%);//#FFA500;
An option is pattern-matching:
// snippet 4
@tone: light;
.linkColor(light, @color){
color: lighten(@color, 10%);
}
.linkColor(dark, @color){
color: darken(@color, 10%);
}
.linkColor(@tone, #f17900);
However snippet 4 will is much more verbose than snippets 2 or 3, and will result in a lot of extra code being generated.
Thanks in advance!