-
-
Save HelgaZhizhka/d485a760def0fcca6c20 to your computer and use it in GitHub Desktop.
Stylus `calc()` mixin
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
// Adds the vendor prefixes for calc. | |
// | |
// Usage: | |
// width: calc('30% - 10px'); | |
// If variables are needed they need to be specified this way. | |
// width: calc('40% \- %s' % (10px)); | |
calc() { | |
// vendors to be used by this function | |
calc-vendors = webkit moz; | |
if current-property { | |
// arguments get unquoted | |
arguments = unquote(arguments); | |
// iterates over the vendor prefixes | |
for prefix in calc-vendors { | |
add-property(current-property[0], s('-%s-calc(%s)', prefix, arguments)); | |
} | |
s('calc(%s)', arguments); | |
} else { | |
error('calc() must be used within a property'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment