Created
January 31, 2017 19:54
-
-
Save averyvery/9a2b82f980435af13c8e248de6fb1211 to your computer and use it in GitHub Desktop.
lil trick
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
/* | |
example: | |
dimension(foo, bar, 2, 10px); | |
- gets the value bar inside foo map | |
- multiplies it by two | |
- adds 10px | |
*/ | |
$dimensions: ( | |
global: ( | |
gutter: 20px | |
), | |
); | |
@function dimension($keys...) { | |
$value: $dimensions; | |
@each $key in $keys { | |
@if (type-of($key) == number) { | |
@if (unitless($key) == true) { | |
$value: $value * $key; | |
} @else if (unitless($key) == false) { | |
$value: $value + $key; | |
} | |
} | |
@if (type-of($key) == string) { | |
$value: map-get($value, $key); | |
} | |
} | |
@return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment