-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (47 loc) · 1.49 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
</head>
<body>
<script type="module">
import "https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/shoelace.js";
import { registerIconLibrary } from "https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/utilities/icon-library.js";
registerIconLibrary("sprite", {
resolver: (name) => `#${name}`,
// mutator: svg => svg.setAttribute('fill', 'currentColor'),
spriteSheet: true,
});
</script>
<script>
(async () => {
const resp = await (
await fetch("https://shoelace.style/assets/images/sprite.svg")
).text();
const docFrag = new DocumentFragment();
const div = document.createElement("div");
div.innerHTML = resp;
docFrag.append(div.firstElementChild);
console.log(resp);
document.body.append(docFrag);
})();
</script>
<svg xmlns="http://www.w3.org/2000/svg">
<use href="#gear" />
</svg>
<div>
<template shadowrootmode="open">
<svg xmlns="http://www.w3.org/2000/svg">
<use href="#gear" />
</svg>
</template>
</div>
<div style="font-size: 24px">
<sl-icon library="sprite" name="gear"></sl-icon>
<sl-icon library="sprite" name="speedometer"></sl-icon>
</div>
<div>Hello World</div>
</body>
</html>