Created
March 7, 2016 17:47
-
-
Save alexisg/dd1d6b45ceb8ba8926e9 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains 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.13) | |
// Compass (v1.0.3) | |
// ---- | |
// color variable map | |
$colors: ( | |
base: #FFBB00, | |
light: base (lighten: 15%), | |
dark: base (darken: 15%), | |
trans: base (transparentize: 0.5) | |
); | |
// retrieve color from $colors map ie. `color(primary, base)` | |
@function color($color-name) { | |
// Get value mapped to `$color` in map | |
$color: map-get($colors, $color-name); | |
// Get the first item from value (color or ref) | |
$base: nth($color, 1); | |
// Get the map of adjustments to perform (or an empty map) | |
$adjust: if(length($color) > 1, nth($color, 2), ()); | |
// If `$base` is a key from the map, then get it | |
$color: map-get($colors, $base) or $base; | |
// Apply the adjustments dynamically | |
@each $key, $value in $adjust { | |
$color: call($key, $color, $value...); | |
} | |
// Return the new color | |
@return $color; | |
} | |
.foo { | |
color: color('base'); | |
color: color('light'); | |
color: color('dark'); | |
color: color('trans'); | |
} |
This file contains 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
.foo { | |
color: #FFBB00; | |
color: #ffcf4d; | |
color: #b38300; | |
color: rgba(255, 187, 0, 0.5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment