Skip to content

Instantly share code, notes, and snippets.

@muecas
Created June 7, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muecas/ae9b45394e1425cc22c0cea4be8dcbbc to your computer and use it in GitHub Desktop.
Save muecas/ae9b45394e1425cc22c0cea4be8dcbbc to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="outcome">
OUTCOME
</div>
<div class="outcome">
OUTCOME
</div>
<div class="outcome">
OUTCOME
</div>
// ----
// Sass (v3.5.6)
// Compass (vundefined)
// ----
// Colors to use
$colors:(
red: red,
blue: blue
);
// Generated color lists
$generated: ();
// For each defined color
@each $name, $color in $colors {
// Current color map
$current : ();
// Generates the colors transformations (shades)
@for $i from 1 through 9 {
$current: append($current, lighten($color, (100 - ($i * 10))));
}
// Adds the current color
$current: append($current, $color);
// Generates the colors transformations (tints)
@for $i from 11 through 19 {
$current: append($current, darken($color, ($i * 10) - 100));
}
// If the map has not been created
@if map-has-key($generated, $name) == false {
$generated: map-merge($generated, ($color : $current));
}
}
// Create a function to get the desired color
@function get-color($color, $index: 10) { // Default to base color
// Get the desired color map
$list: map-get($generated, $color);
// Return the color index
@return nth($list, $index);
}
.foo {
color: get-color(blue, 19);
}
.foo {
color: black;
}
<div class="outcome">
OUTCOME
</div>
<div class="outcome">
OUTCOME
</div>
<div class="outcome">
OUTCOME
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment