Last active
December 11, 2015 18:38
-
-
Save buttjer/4643167 to your computer and use it in GitHub Desktop.
Simple universal Vendor SASS Mixin.
Example: @include vendor(-prefix- transition, -prefix- transform 0.2s ease-in-out );
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
@mixin vendor($name, $args...) { | |
$vendors: -webkit-, -ms-, -moz-, -o-; | |
$nextWithVendor: false; | |
$first: true; | |
$cleanValues: null; | |
$cleanName: $name; | |
@if nth( $name, 1 ) == -prefix- { | |
$cleanName: nth( $name, 2 ); | |
} | |
@each $vendor in $vendors { | |
$values: null; | |
@each $arg in $args { | |
@if nth( $arg, 1 ) == -prefix- { | |
$subValues: null; | |
@each $subValue in $arg { | |
@if $subValue != -prefix- { | |
$subValues: append( $subValues, $subValue ); | |
} | |
} | |
$values: append( $values, $vendor + $subValues, comma ); | |
@if $first { | |
$cleanValues: append( $cleanValues, $subValues, comma ); | |
} | |
} | |
@else { | |
$values: append( $values, $arg, comma ); | |
@if $first { | |
$cleanValues: append( $cleanValues, $arg, comma ); | |
} | |
} | |
} | |
$first: false; | |
@if $cleanName != $name { | |
#{$vendor + $cleanName}: $values; | |
} | |
@else { | |
#{$cleanName}: $values; | |
} | |
} | |
#{$cleanName}: $cleanValues; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment