Skip to content

Instantly share code, notes, and snippets.

@blackfalcon
Last active December 11, 2015 11:09
Show Gist options
  • Save blackfalcon/4591925 to your computer and use it in GitHub Desktop.
Save blackfalcon/4591925 to your computer and use it in GitHub Desktop.
Remove repetitive code from your life. The problem I needed to solve was that I was writing too many lines of code that was the exact same pattern. This is where Sass shows real strength.
// Sass v3.2.5
// Stipe v0.0.5.5
// @import "stipe/manifest";
$color_names: shadow_color href_color form_field_border;
$color_var: $shadow_color $href_color $form_field_border;
@each $name in $color_names {
$i: index($color_names, $name);
%#{$name} {
background: nth($color_var, $i);
}
}
@each $name in $color_names {
$i: index($color_names, $name);
.#{$name} {
background: nth($color_var, $i);
}
}
.shadow_color {
background: rgba(51, 51, 51, 0.5);
}
.href_color {
background: #a45454;
}
.form_field_border {
background: #5c5c5c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment