UPDATE I am just re-reading your comment and better understanding the problem. This should work:
.secColor (@bgc, @prop) when (lightness(@bgc) >= 50%) and (@prop = color){ color: black; } .secColor (@bgc, @prop) when (lightness(@bgc) >= 50%) and (@prop = background){ background-color: black; } .secColor (@bgc, @prop) when (lightness(@bgc) >= 50%) and (@prop = border){ border-color: black; } .secColor (@bgc, @prop) when (lightness(@bgc) >= 50%) and (@prop = all){ color: black; background-color: black; border-color: black; } .secColor (@bgc, @prop) when (lightness(@bgc) < 50%) and (@prop = color){ color: white } .secColor (@bgc, @prop) when (lightness(@bgc) < 50%) and (@prop = background){ background-color: white; } .secColor (@bgc, @prop) when (lightness(@bgc) < 50%) and (@prop = border){ border-color: white; } .secColor (@bgc, @prop) when (lightness(@bgc) < 50%) and (@prop = all){ color: white; background-color: white; border-color: white; }
Then use mixin:
.class1 { .secColor (
ADDED ADDITIONAL VERSION
.propSwitch (@prop, @clr) when (@prop = color) { color: @clr; } .propSwitch (@prop, @clr) when (@prop = background) { background-color: @clr; } .propSwitch (@prop, @clr) when (@prop = border) { border-color: @clr; } .propSwitch (@prop, @clr) when (@prop = all) { color: @clr; background-color: @clr; border-color: @clr; } .secColor (@bgc, @prop) when (lightness(@bgc) >= 50%) { .propSwitch (@prop, #000); } .secColor (@bgc, @prop) when (lightness(@bgc) < 50%) { .propSwitch (@prop, #fff); }
source share