r/css•
DGN1nja

LESS guarded expression problems

Hey, /r/css, I've been working with colours in LESS, and I've been wondering why the following code doesn't compile.

And wow, this following code won't format properly. The link above is to a better-formatted gist.

.background-color-shift (@color, @amount: 10%) when (lightness(@color) > 50%) {
	background-color: darken(@color, @amount);
}
.background-color-shift (@color, @amount: 10%) when (lightness(@color) <= 50%) {
	background-color: lighten(@color, @amount);
}
.text-color-shift (@color, @amount: 10%) when (lightness(@color) > 50%) {
	color: darken(@color, @amount);
}
.text-color-shift (@color, @amount: 10%) when (lightness(@color) <= 50%) {
	color: lighten(@color, @amount);
}

All I need to do is make this color shifting direction automatic, determined by the input @color. Any ideas?

Posted Mar 25, 2012, 1:06 AM UTC

54
Loading comments…