Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created June 17, 2011 14:43
Show Gist options
  • Save StanAngeloff/1031551 to your computer and use it in GitHub Desktop.
Save StanAngeloff/1031551 to your computer and use it in GitHub Desktop.
Re-usable logic
html {
@for $index from 1 through length($base-colors) {
$base-color: nth($base-colors, $index);
&.ui-theme-#{letter($index)} {
background-color: $base-color;
}
}
}
@mixin for-each($block) {
@for $index from 1 through length($base-colors) {
$base-color: nth($base-colors, $index);
@eval $block, $index: $index, $base-color: $base-color, $letter: letter($index)
}
}
html {
@include for-each({ | $index, $base-color, $letter |
&.ui-theme-#{$letter} {
background-color: $base-color;
}
});
}
// -- OR (preferred, functions are just objects) --
html {
@include for-each(@function($index, $base-color, $letter) {
&.ui-theme-#{$letter} {
background-color: $base-color;
}
});
}
// -- OR (implicit block, all arguments are available) --
html {
@include for-each({
&.ui-theme-#{$letter} {
background-color: $base-color;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment