-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
31 lines (25 loc) · 979 Bytes
/
index.js
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
import scenes from './scenes/index.js';
window.addEventListener('load', () => {
const canvasDiv = document.getElementById('canvasDiv');
const sceneDiv = document.getElementById('sceneDiv');
const infoDiv = document.getElementById('infoDiv');
for (const scene of scenes) {
const sceneButton = document.createElement('button');
sceneButton.textContent = scene.name;
sceneButton.addEventListener('click', async () => {
const svg = await scene.default();
const downloadA = document.createElement('a');
downloadA.href = 'data:application/svg,' + encodeURIComponent(svg.outerHTML);
downloadA.download = `${scene.name}.svg`;
downloadA.textContent = 'Download';
infoDiv.innerHTML = '';
infoDiv.append(downloadA);
canvasDiv.innerHTML = '';
canvasDiv.append(svg);
});
sceneDiv.append(sceneButton);
if (scene.name === 'Me') {
sceneButton.click();
}
}
});