-
-
Save chriseppstein/1241eee7fa6ccae7ec0c to your computer and use it in GitHub Desktop.
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
@function apply-fn($fn, $values) { | |
$new-values: (); | |
@each $v in $values { | |
$new-values: append($new-values, call($fn, $v), list-separator($values)); | |
} | |
@return $new-values; | |
} | |
@function rem2px($value) { | |
@if unit($value) == rem { | |
@return $value / 1rem * 16px; | |
} @else { | |
@return $value; | |
} | |
} | |
@mixin px-fallback($property, $values) { | |
$fallback: apply-fn(rem2px, $values); | |
@if $fallback != $values { | |
#{$property}: $fallback; | |
} | |
#{$property}: $values; | |
} | |
@mixin margin($value) { | |
@include px-fallback(margin, $value); | |
} | |
.with-fallback { | |
@include margin(2px 0.5rem 4px); | |
} | |
.no-fallback { | |
@include margin(2px 9em 4px); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment