-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
svg-utilities.scss
19 lines (17 loc) · 1021 Bytes
/
svg-utilities.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$svg-icon-vertical-align: bottom !default;
// credit goes to UnoCSS https://antfu.me/posts/icons-in-pure-css
@mixin generateSvgClass($cssVarName, $svgPath) {
.#{$cssVarName} {
@include generateSvgStyle(#{$cssVarName + '-icon-svg'}, $svgPath); // all icon will create css variable named "[icon name]-icon-svg"
}
}
// create SVG as a url() and the url string must be html escaped,
// we will also use the name to create a CSS variable so that user could override any of the icon
// by providing the full url string without needing else since it was already created
@mixin generateSvgStyle($cssVarName, $svgPath) {
--#{$cssVarName}: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 24 24" display="inline-block" height="1em" width="1em" vertical-align="text-bottom" xmlns="http://www.w3.org/2000/svg" %3E%3Cpath fill="currentColor" d="#{$svgPath}"/%3E%3C/svg%3E');
-webkit-mask: var(--#{$cssVarName}) no-repeat;
mask: var(--#{$cssVarName}) no-repeat;
mask-size: 100% 100%;
-webkit-mask-size: 100% 100%;
}