Created
January 12, 2015 06:49
-
-
Save crazyrohila/8ece2cacf08a8302f056 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// 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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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