So my code is having a major issue with types and I can't seem to solve it.
Whenever I subtract 1
from line 8
there are issues.
How can I resolve this?
@max-columns: 2;
@column-1-width-min: 30;
@column-2-width-min: 40;
.loop-column(@index) when (@index > 0) {
@max-minus-1a: "@{column-@{index}-width-min}";
@max-minus-1b: @max-minus-1a - 1; // problem child
@min: ~"min-width: @{column-@{index}-width-min}";
@max: ~"max-width: @{max-minus-1b}";
@media (@min) and (@max) {
[data-deckgrid="card"]::before {
content: "@{index} .column.card-column-@{index}";
}
}
.loop-column(@index - 1);
}
.loop-column(@max-columns);
In addition to the method you can find in this SO answer (as I have already mentioned in my comment above), I think the whole snippet can be simplified to something like (Less 1.5.x or higher):
with the following CSS result:
I.e. you don't need to emulate arrays via "indexing variable names" since you can use arrays directly (Less array is just a comma or space separated value list, e.g.
@padding: 1 2 3 4;
).