Last active
May 22, 2019 20:39
-
-
Save lucianobarauna/71a03180854c997d904e1184c02e4c88 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com. Function to get values in map objects
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
// ---- | |
// libsass (v3.5.4) | |
// ---- | |
// color variable map | |
$colors: ( | |
// non-nested values | |
text: #FFF, | |
background: #333, | |
// nested map inception | |
primary: ( | |
base: #FFBB00, | |
light: lighten(#FFBB00, 15%), | |
dark: darken(#FFBB00, 15%), | |
trans: transparentize(#FFBB00, 0.5) | |
), | |
secondary: ( | |
base: #0969A2, | |
light: lighten(#0969A2, 15%), | |
dark: darken(#0969A2, 15%), | |
trans: transparentize(#0969A2, 0.5) | |
) | |
); | |
@function get-props-map($prop-first, $prop-deep:null, $target-map-object: null){ | |
@if($target-map-object == null) { | |
@error "Declare as your last argument your target map."; | |
} | |
@if ($prop-deep != null) { | |
// Inception map | |
@return map-get(map-get($target-map-object, $prop-first), $prop-deep) | |
} @else { | |
// Get first level map | |
@return map-get($target-map-object, $prop-first); | |
} | |
} | |
.teste { | |
color: get-props-map(text, null, $colors); | |
} |
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
.teste { | |
color: #FFF; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment