How to make a colour darker if light, or lighter if dark in LESS

Viewed 1586

Given a colour as input, how do you transform it in LESS so that it becomes darker if it's a light colour, or lighter if it's a dark colour?

For example:

  • when the colour is dark, the result is something like darken(@color-input, 10%)
  • when the colour is light, the result is something like lighten(@color-input, 10%)

Is there any conditional test that can be applied or any color operation that would give this result?

2 Answers
Related