Created
February 28, 2015 14:36
-
-
Save crazyrohila/c039cba5fdd3d8f6e9ed 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.12) | |
// Compass (v1.0.3) | |
// ---- | |
// @crazyrohila | |
// Global colors. | |
$colors: ( | |
dark-gray: rgb(153, 153, 153), | |
hulk: rgb(119, 167, 109), | |
teal: #008080, | |
) !global; | |
/** | |
* Helper function to get color from $colors map. | |
* @params $color color to get. | |
* @params $colors map of colors. | |
* @return value of $color. | |
*/ | |
@function color($color, $colors: $colors) { | |
@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); | |
} | |
.footer { | |
// Override global color. | |
$bgs: ( | |
'fav': #008080, | |
); | |
background: color('fav', $bgs); | |
} |
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
/** | |
* Helper function to get color from $colors map. | |
* @params $color color to get. | |
* @params $colors map of colors. | |
* @return value of $color. | |
*/ | |
.main { | |
background: #77a76d; | |
color: red; | |
} | |
.footer { | |
background: #008080; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment