The problem: I want to create a LESS mixin for 'notched' corners for boxes that have padding.
Image example: https://i.stack.imgur.com/XBcKo.png
This box has its top right and bottom left corners notched out, with :before/:after content squares.
I want to create a mixin, so I don't have to make a class for every possibility of options.
Something like .boxed-corners(top right, bottom left);
My feeble attempt was this:
@box-padding: 10px;
.boxed-corners(@pos1 @pos2, @pos3 @pos4) {
position: relative;
&:before {
position: absolute;
display: block;
content: "";
.bg-body();
width: @box-padding;
height: @box-padding;
@pos1: 0;
@pos2: 0;
}
&:after {
position: absolute;
display: block;
content: "";
.bg-body();
width: @box-padding;
height: @box-padding;
@pos3: 0;
@pos4: 0;
}
}
But that is invalid because between the sets of vars. Even when added, @pos1 or @pos2 won't use the string you've inputted (top, left, right, bottom).
I know I'm way off, but there's probably a way to accomplish this. Any ideas?
EDIT: Thanks seven-phases-max, that's what I was looking for:
Thank you! That was it, I just didn't know what to search for. My working code is now:
.boxed-corners(@pos1; @pos2; @pos3; @pos4) {
position: relative;
&:before {
position: absolute;
display: block;
content: "";
.bg-body();
width: @box-padding;
height: @box-padding;
@{pos1}: 0;
@{pos2}: 0;
}
&:after {
position: absolute;
display: block;
content: "";
.bg-body();
width: @box-padding;
height: @box-padding;
@{pos3}: 0;
@{pos4}: 0;
}
}
The only bad thing is that all four values have to be separated by commas (bottom, left, top, right), instead of (bottom left, top right), but I'll take it.