-
-
Save jensgro/cf372084e8193c0e9bbdd44bc4c908e8 to your computer and use it in GitHub Desktop.
Utility SASS mixin to convert a map of property names and values to CSS
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
/** | |
* Converts a SASS map of css property names and values into CSS output. | |
* Properties named `description` will have their value inserted as comments. | |
* | |
* Nested maps will be processed recursively. | |
* | |
* @param {map} $map the map of properties to output | |
*/ | |
@mixin map-to-props($map){ | |
@if type-of($map) == map { | |
@each $prop, $value in $map { | |
@if type-of($value) != map { | |
@if inspect($prop) == 'description' { | |
/* #{inspect($value)} */ | |
} | |
@else { | |
#{inspect($prop)}: #{inspect($value)}; | |
} | |
} | |
@else { | |
@include map-to-props($value); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment