forked from iconic/SVGInjector
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathspritesheet-classbased.html
executable file
·62 lines (54 loc) · 1.54 KB
/
spritesheet-classbased.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>SVGInjector Example: SVG Sprites</title>
<style>
.external-styling {
color: #666;
}
.external-styling .green {
color: #0f0;
}
.external-styling .icon--styled {
color: #900;
stroke: #f00;
}
</style>
</head>
<body>
<h1>Spritesheet Classbased</h1>
<section>
<!-- single svg -->
<svg data-src="./assets/svg/circle.svg" />
</section>
<section>
<!-- inject from spriteeet -->
<svg class="sprite--logo-gradients" />
<svg class="sprite--triangle" />
</section>
<section class="external-styling">
<p class="green">
<svg class="sprite--triangle icon" />
</p>
<svg class="sprite--triangle icon icon--styled" />
</section>
<script src="../dist/svg-injector.min.js"></script>
<script>
(function(window, document){
// Options
var injectorOptions = {
evalScripts: 'once',
// reference fragments via views - generated with grunt-svg-sprite
spritesheetURL: './assets/svg/views.svg'
};
// Setup the injector
var injector = new SVGInjector(injectorOptions);
// inject single svg
injector.inject(document.querySelectorAll('svg[data-src]'));
// inject svgs from spritesheets
injector.inject(document.querySelectorAll('svg[class^=sprite-]'));
})(window, document);
</script>
</body>
</html>