Skip to content

Commit c107e33

Browse files
committed
_grid-framework – use each(range(... to replace for-ish loops; require Less 3.9
1 parent 8c4dcb2 commit c107e33

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

less/mixins/_grid-framework.less

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@
8282
@infix: breakpoint-infix(@breakpoint, @breakpoints);
8383

8484
// Allow columns to stretch full width below their breakpoints
85-
#each-column(@i: 1) when (@i <= @columns) {
85+
each(range(@columns), #(@i) {
8686
.col@{infix}-@{i} {
8787
&:extend(.grid-column);
8888
}
89+
});
8990

90-
#each-column((@i + 1));
91-
} #each-column();
9291
.col@{infix},
9392
.col@{infix}-auto {
9493
&:extend(.grid-column);
@@ -107,35 +106,29 @@
107106
max-width: none; // Reset earlier grid tiers
108107
}
109108

110-
#each-column-col(@ii: 1) when (@ii <= @columns) {
111-
.col@{infix}-@{ii} {
112-
#make-col(@ii, @columns);
109+
each(range(@columns), #(@i) {
110+
.col@{infix}-@{i} {
111+
#make-col(@i, @columns);
113112
}
114-
115-
#each-column-col((@ii + 1));
116-
} #each-column-col();
113+
});
117114

118115
.order@{infix}-first { order: -1; }
119116

120117
.order@{infix}-last { order: (@columns + 1); }
121118

122-
#each-column-order(@ii: 0) when (@ii <= @columns) {
123-
.order@{infix}-@{ii} { order: @ii; }
119+
each(range(0, @columns), #(@i) {
120+
.order@{infix}-@{i} { order: @i; }
121+
});
124122

125-
#each-column-order((@ii + 1));
126-
} #each-column-order();
127-
128-
// `@ii < @columns` because offsetting by the width of an entire row isn't possible
129-
#each-column-offset(@ii: 0) when (@ii < @columns) {
130-
& when not (@ii = 0),
131-
(@ii = 0) and not (@infix = ~"") {
132-
.offset@{infix}-@{ii} {
133-
#make-col-offset(@ii, @columns);
123+
// `@columns - 1` because offsetting by the width of an entire row isn't possible
124+
each(range(0, (@columns - 1)), #(@i) {
125+
& when not (@i = 0),
126+
(@i = 0) and not (@infix = ~"") {
127+
.offset@{infix}-@{i} {
128+
#make-col-offset(@i, @columns);
134129
}
135130
}
136-
137-
#each-column-offset((@ii + 1));
138-
} #each-column-offset();
131+
});
139132
});
140133
});
141134
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"lint": "eslint ."
3636
},
3737
"peerDependencies": {
38-
"less": "^3.8.1"
38+
"less": "^3.9.0"
3939
},
4040
"devDependencies": {
4141
"autoprefixer": "^8.6.5",

0 commit comments

Comments
 (0)