Last active
August 29, 2015 14:02
-
-
Save webinista/ca6f732ba6fd18bebc78 to your computer and use it in GitHub Desktop.
removeHash.scss: Removes the # from hexRGB colors
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
// Removes the # from hexRGB colors for use in SVG data URIs | |
@function removeHash($hexColor){ | |
$hexColor: $hexColor + ''; // Convert to a string | |
$colorNum: str-slice($hexColor,2); | |
@return $colorNum; | |
} | |
// Sample usage | |
@mixin check($fillColor) { | |
$noHashColor: removeHash($fillColor); | |
background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20120%20126%22%3E%3Crect%20x%3D%229.1%22%20y%3D%221.8%22%20fill%3D%22%23#{$noHashColor}%22%20width%3D%2265.7%22%20height%3D%2265.7%22%2F%3E%3C%2Fsvg%3E"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment