I created small Less @mixin for lightness value conditional. I was using Sass for my applications UI's and I'm realy confused how to create good conditionals in Less. Can anybody answer me that, is it good pice of code for Less conditionals?
Less source:
.lightness (@conditionalValue, @lightnessPercentage, @propertyName, @truePropertyValue, @falsePropertyValue) when (lightness(@conditionalValue) >= @lightnessPercentage) {
@{propertyName}: @truePropertyValue;
}
.lightness (@conditionalValue, @lightnessPercentage, @propertyName, @truePropertyValue, @falsePropertyValue) when (lightness(@conditionalValue) < @lightnessPercentage) {
@{propertyName}: @falsePropertyValue;
}
.class1 { .lightness(white,65%,background,black,white) }
.class2 { .lightness(black,65%,background,black,white) }
Css output:
.class1 {
background: black;
}
.class2 {
background: white;
}