inline-svg-template.mustache 827 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
${{{name}}}: "{{{inline}}}" {{width}} {{height}};
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{{/svgs}}

@mixin inline-svg($name, $color: null) {
	@if ($color) {
		$color: str-replace($color + '', '#', '');
		background: transparent url(str-replace(nth($name, 1), '%23FFF', '%23' + $color)) no-repeat 50% 50%;
	} @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);
}