Last active
December 14, 2021 19:23
-
-
Save 9ete/941ba60134cb5313a615b08bc8331f4d to your computer and use it in GitHub Desktop.
Dynamic Sass/SCSS Mixin
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
// Why: reduce lines by grouping related styles (flexbox, background, etc) | |
// Creates short powerful style mixins see https://gist.github.com/hawkeye126/8328945e412fda9617d9a6a165632dd3 | |
@mixin dynamicMixin($mixin-args: ()){ | |
@each $rule, $value in $mixin-args { | |
#{$rule}: #{$value}; | |
} | |
} | |
// use directly | |
// @include dynamicMixin(("background-size":"contain", "background-position":"center")); | |
// | |
// or extend to mixin | |
// @mixin set-z-index($position: 1) { | |
// dynamicMixin(("position":"relative", "z-index":$position)) | |
// } | |
// elementOne { | |
// @include set-z-index(); | |
// } | |
// elementTwo { | |
// @include set-z-index(2); | |
// } | |
// elementThree { | |
// @include set-z-index(3); | |
// } | |
// and so on... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment