-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
I often find myself needing to apply one style if an argument is x, and another style if y .
The addition of CSS Guards in 1.5.0 made it easy to wrap a group of styles like so:
.my-thing {
& when (@my-option = true) {
color: white;
background: black;
display: block
}
}
However, the syntax seem excessive when it's just one or two attributes in a style block. In PHP and JS, I am accustomed to the ternary operator syntax, and it seemed like it might easily fit into the Less language. Some examples:
@my-value: true;
.my-thing {
// if @my-value evaluates to true, then black. else, white.
color: (@my-value = true) ? black : white;
}
@my-other-value: false;
@my-color: (@my-other-value = true) ? black : white;
.my-other-thing {
color: @my-color;
}
// outputs
.my-thing {
color: black;
}
.my-other-thing {
color: white;
}
Any thoughts?
toastal