inline-svg-template.mustache 844 Bytes
Newer Older
1
@function str-replace($string, $search, $replace: '') {
Philipp Nowinski's avatar
Philipp Nowinski committed
2
	$index: str-index($string, $search);
3

Philipp Nowinski's avatar
Philipp Nowinski committed
4 5 6
	@if $index {
		@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
	}
7

Philipp Nowinski's avatar
Philipp Nowinski committed
8
	@return $string;
9 10 11
}

{{#svgs}}
12
${{prefix}}{{{variableName}}}: "{{{inline}}}" {{width}} {{height}};
13 14 15 16 17
{{/svgs}}

@mixin inline-svg($name, $color: null) {
	@if ($color) {
		$color: str-replace($color + '', '#', '');
18
		background: transparent url(str-replace(nth($name, 1), 'white', '%23' + $color)) no-repeat 50% 50%;
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
	} @else {
		background: transparent url(nth($name, 1)) no-repeat 50% 50%;
	}
	background-size: 100%;
	width: nth($name, 2);
	height: nth($name, 3);
}

@function inline-svg-width($name) {
	@return nth($name, 2);
}

@function inline-svg-height($name) {
	@return nth($name, 3);
}