Skip to content

Instantly share code, notes, and snippets.

@crazyrohila
Created January 12, 2015 06:49
Show Gist options
  • Save crazyrohila/8ece2cacf08a8302f056 to your computer and use it in GitHub Desktop.
Save crazyrohila/8ece2cacf08a8302f056 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
/**
* Color function.
*/
// Map to store color as key/values.
$colors: (
dark-gray: rgb(153, 153, 153),
hulk: rgb(119, 167, 109),
teal: #008080,
);
// Returns a color from $colors.
@function color($color) {
@if not not index("string" "color", $color) {
@error "#{$color} value is not valid, should be string or color.";
}
@else if not map-has-key($colors, $color) {
@if type-of($color) == "color" {
@return $color;
}
@else {
@error "#{$color} not found in $colors.";
}
}
@return map-get($colors, $color);
}
// Demo
.main {
background: color(hulk);
color: color(red);
}
/**
* Color function.
*/
.main {
background: #77a76d;
color: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment