Skip to content

Instantly share code, notes, and snippets.

@micahgodbolt
Created September 12, 2013 18:49
Show Gist options
  • Save micahgodbolt/6542163 to your computer and use it in GitHub Desktop.
Save micahgodbolt/6542163 to your computer and use it in GitHub Desktop.
SassBites#7 Code
$foo: 1;
$bar: 6;
@while $foo < $bar {
h#{$foo} { // do something
font-size: ($bar - $foo)+em;
}
$foo: $foo + 1; // advance a counter
}
-----------------------------------------------
@mixin color-family($color, $steps, $amount) {
$var: 0;
@while $var < $steps {
.class-#{$var} {
color: darken($color, ($var * $amount));
}
$var: $var + 1;
}
}
@include color-family(blue, 5, 10%);
--------------------------------------
@import "compass";
@function sort($list) {
$sortedlist: ();
@while length($list) > 0 {
$value: nth($list,1);
@each $item in $list {
@if $item < $value {
$value: $item;
}
}
$sortedlist: append($sortedlist, $value, 'space');
$list: reject($list, $value);
}
@return $sortedlist;
}
$vars: 12 10 13 9;
div {
original: $vars;
sorted: sort($vars);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment