Created
March 21, 2014 13:05
-
-
Save KittyGiraudel/9685761 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.3.3) | |
// Compass (v1.0.0.alpha.18) | |
// ---- | |
// A little function for your frameworks | |
// Allowing users to use a prefixer mixin | |
// With various aliases, and not necessarily official vendors | |
// List of aliases for each vendor | |
// Feel free to add the one you want | |
$vendors: ( | |
'webkit' : 'wk' 'chrome' 'ch' 'chr', | |
'moz' : 'mozilla' 'firefox' 'ff' 'fx' 'mf', | |
'ms' : 'microsoft' 'ie' 'internet explorer', | |
'o' : 'opera' 'op' 'ope' | |
); | |
// Retrieve a valid vendor from an alias | |
// e.g. "webkit" from "chrome" or "moz" from "firefox" | |
// 1. If `$prefix` doesn't exist as a key in `$vendors` | |
// 2. Loop through the `$vendors` map | |
// 3. Test if `$prefix` is a known alias | |
// 4. If it is a known alias | |
// 5. Return the vendor it matches to | |
// 6. If it's an unknown alias, warn the user | |
// 7. And return `$prefix` | |
@function get-vendor($prefix) { | |
@if map-get($vendors, $prefix) == null { // 1 | |
@each $vendor, $aliases in $vendors { // 2 | |
$index: index($aliases, to-lower-case($prefix)); // 3 | |
@if $index { // 4 | |
@return $vendor; // 5 | |
} | |
} | |
@warn "Unknown alias `#{$prefix}`."; // 6 | |
} | |
@return $prefix; // 7 | |
} | |
// Prefixer mixin | |
// 1. Loop through all declaractions | |
// 2. If `$prefixes` is defined | |
// 3. Loop through all prefixes | |
// 4. Display the prefixed rule | |
// 5. Display the standard rule | |
@mixin prefixr($declarations, $prefixes: webkit) { | |
@each $property, $value in $declarations { // 1 | |
@if $prefixes { // 2 | |
@each $prefix in $prefixes { // 3 | |
#{"-" + get-vendor($prefix) + '-' + $property}: $value; // 4 | |
} | |
} | |
#{$property}: $value; // 5 | |
} | |
} | |
// Example | |
.el { | |
@include prefixr(( | |
transform: rotate(60deg), | |
perspective: 1000 | |
), 'wk' 'FIREFOX' 'internet explorer' 'OP'); | |
} |
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
.el { | |
-webkit-transform: rotate(60deg); | |
-moz-transform: rotate(60deg); | |
-ms-transform: rotate(60deg); | |
-o-transform: rotate(60deg); | |
transform: rotate(60deg); | |
-webkit-perspective: 1000; | |
-moz-perspective: 1000; | |
-ms-perspective: 1000; | |
-o-perspective: 1000; | |
perspective: 1000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment