Skip to content

Instantly share code, notes, and snippets.

@seven-phases-max
Created November 19, 2013 14:27
Show Gist options
  • Save seven-phases-max/7546151 to your computer and use it in GitHub Desktop.
Save seven-phases-max/7546151 to your computer and use it in GitHub Desktop.
// "Arrays of Structures in LESS"
// see http://stackoverflow.com/questions/20071982
.product-colors(@index: 0) {
@list:
'white' #fff,
'green' #0f0,
'yellow' #ff0,
'black' #000,
'red' #f00;
@name: e(extract(@value, 1));
@color: extract(@value, 2);
@count: length(@list);
@value: extract(@list, @index);
}
.menu-template() {
&.menu-@{name} {
background-color: @color;
color: darken(@color, 20%);
&:hover {
background-color: darken(@color, 10%);
}
}
}
.make-menus() {
.product-colors();
.-(@count);
.-(@i) when (@i > 0) {
.-((@i - 1));
.product-colors(@i);
.menu-template();
}
}
li {
.make-menus();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment