I am trying to create a Less mixin for vendor properties that allows somebody to specify what CSS property they want to use, the value of the property, and what vendor(s) they want it for (Opera, Mozilla, Firefox, Webkit, IE, none).
I originally wrote the code in SASS here but am having a hard time porting it to Less.
Here is what I currently have:
.vendor(@property, @value, @vendors...) {
.vendor-detect() when (@vendors = webkit) {
-webkit-@{property}: @value;
}
.vendor-detect() when (@vendors = moz) {
-moz-@{property}: @value;
}
.vendor-detect() when (@vendors = ms) {
-ms-@{property}: @value;
}
.vendor-detect() when (@vendors = o) {
-o-@{property}: @value;
}
.vendor-detect() when (@vendors = official) {
@{property}: @value;
}
.vendor-detect();
}
Right now, the when you use the code as such:
.button {
.vendor(border-radius, 4px, official);
}
You get:
.button {
border-radius: 4px;
}
But I want to be able to declare multiple vendors with the mixin, so using:
.button {
.vendor(border-radius, 4px, webkit moz official);
}
Should provide me with:
.button {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
But right now it doesn't.
So how do I go about looping through the vendors
parameter in this mixin, or can I even do that in Less?