-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add array variable support and loop function #1465
Comments
You can do all of this in less..
|
@lukeapage Can you give a simple example. I don't understand well. Thanks! |
this would make a good stackoverflow question.. ;-) |
Indeed, Let Me Google That For You(TM) ;) http://stackoverflow.com/questions/17695787/build-a-selector-within-a-less-loop |
Good. @grid_columns: 6;
@word_numbers: one two three four five six seven eight nine ten eleven twelve;
.row {
.column_loop (@index) when (@index = 1){
.one.column {
.column_width(@index);
}
}
.column_loop (@index) when(@index < @grid_columns + 1){
@word: extract(@word_numbers, @index);
.@{word}.columns {
.column_width(@index);
}
.column_loop(@index+1);
}
.column_loop(1);
.column_width(@index){
width: percentage(@index/@grid_columns);
}
} And it result .row .one.column {
width: 16.666666666666664%;
}
.row .one.columns {
width: 16.666666666666664%;
}
.row .two.columns {
width: 33.33333333333333%;
}
.row .three.columns {
width: 50%;
}
.row .four.columns {
width: 66.66666666666666%;
}
.row .five.columns {
width: 83.33333333333334%;
}
.row .six.columns {
width: 100%;
} I think you should update the usage of extract function to the documentation. Thanks for all the helps. |
I've created an issue in the less-docs repository for updating the |
@Soviut thanks. I would like close this issue. But i am still thinking it's necessary adding a foreach loop. For example. At the moment i have the code below: @devices: tablet mobile;
@breakpoints: 768px 480px;
@count: 2;
.grid-generator (@devices, @breakpoints, @count) {
.grid-generator (@devices, @breakpoints, @count, 1);
}
.grid-generator (@devices, @breakpoints, @count, @index) when (@index < @count + 1){
@device: extract(@devices, @index);
@breakpoint: extract(@breakpoints, @index);
.grid-device-generator (@device, @breakpoint);
.grid-generator (@devices, @breakpoints, @count, @index + 1);
} You can see the full code here. @devices: tablet mobile;
@breakpoints: 768px 480px;
.grid-generator (@devices, @breakpoints, @count) {
@devices.forEach(@device, @index) {
@breakpoint: extract(@breakpoints, @index);
.grid-device-generator (@device, @breakpoint);
}
} If this is not easy to achieve, i hope you can give a size function to get the size of a array variable: @devices: tablet mobile;
@breakpoints: 768px 480px;
.grid-generator (@devices, @breakpoints) {
.grid-generator (@devices, @breakpoints, 1);
}
.grid-generator (@devices, @breakpoints, @index) when (@index < size(@devices) + 1) {
@device: extract(@devices, @index);
@breakpoint: extract(@breakpoints, @index);
.grid-device-generator (@device, @breakpoint);
.grid-generator (@devices, @breakpoints, @index + 1);
} Thanks again. For your open mind and your hard work. |
see #1542 |
The foundataion grid function that write in sass
What i am thinking can you introduce array variable and for loop function so we can do the same things above?
The syntax may like:
This function is very helpful. If you can add it that will be awesome. Thanks.
The text was updated successfully, but these errors were encountered: