Created
October 30, 2015 12:10
-
-
Save gajus/4cf0265c5d0143a9e734 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
<div class='icon'></div> |
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
// ---- | |
// libsass (v3.2.5) | |
// ---- | |
$circle-icon-svg: '<svg xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="10" /></svg>'; | |
$icon-color: #f00; | |
$icon-color-hover: #00f; | |
@function str-replace($string, $search, $replace: '') { | |
$index: str-index($string, $search); | |
@if $index { | |
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); | |
} | |
@return $string; | |
} | |
@function svg-fill ($svg, $color) { | |
@return str-replace($svg, '<svg', '<svg fill="#{$color}"'); | |
} | |
@function svg-size ($svg, $width, $height) { | |
$svg: str-replace($svg, '<svg', '<svg width="#{$width}"'); | |
$svg: str-replace($svg, '<svg', '<svg height="#{$height}"'); | |
@return $svg; | |
} | |
.icon { | |
$icon-svg: svg-size($circle-icon-svg, 20, 20); | |
width: 20px; height: 20px; background: url('data:image/svg+xml;utf8,#{svg-fill($icon-svg, $icon-color)}'); | |
&:hover { | |
background: url('data:image/svg+xml;utf8,#{svg-fill($icon-svg, $icon-color-hover)}'); | |
} | |
} |
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
.icon { | |
width: 20px; | |
height: 20px; | |
background: url('data:image/svg+xml;utf8,<svg fill="#f00" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="10" /></svg>'); | |
} | |
.icon:hover { | |
background: url('data:image/svg+xml;utf8,<svg fill="#00f" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="10" /></svg>'); | |
} |
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
<div class='icon'></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment