-
Notifications
You must be signed in to change notification settings - Fork 4
/
devPlayground.html
115 lines (99 loc) · 3 KB
/
devPlayground.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>DomParticles Dev Playground</title>
<style>
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
body {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
}
body div {
height: 100%;
}
.particle-code {
background-color: #191a1d;
color: #fff;
font-family: monospace;
padding: 20px;
white-space: pre-wrap;
}
.particle-result {
display: grid;
justify-items: center;
align-items: center;
background-color: #32333B;
}
.particle-button {
width: 180px;
max-width: 320px;
height: 64px;
background-color: transparent;
border: 3px solid #c5c8d4;
outline: none;
border-radius: 5px;
cursor: pointer;
display: block;
color: #fff;
font-size: 18px;
font-weight: bold;
user-select: none;
outline: none;
}
.particle-button:hover {
background-color: white;
border-color: white;
color: black;
}
.particle-button:active {
transform: translateY(1px);
}
</style>
</head>
<body>
<script type='text/javascript' src='lib/dom-particles.umd.js'></script>
<script type='text/javascript'>
const t = new DomParticles();
</script>
<div class='particle-code' contenteditable spellcheck=false>
particleButton.addEventListener('click', (e) => {
t.addParticle({
position: {
x: e.clientX,
y: particleButton.getBoundingClientRect().y
},
contents: '+1',
velocity: { x: 0, y: -40 },
style: { fontSize: '24px', fontFamily: 'monospace' }
});
});
</div>
<div class='particle-result'>
<button class='particle-button'>Go</button>
</div>
<script type='text/javascript'>
const particleCode = document.querySelector('.particle-code');
let particleButton = document.querySelector('.particle-button');
particleCode.addEventListener('input', () => {
t.reset();
const newButton = particleButton.cloneNode(true);
particleButton.parentElement.appendChild(newButton);
particleButton.parentElement.removeChild(particleButton);
particleButton = newButton;
eval(particleCode.innerText);
});
eval(particleCode.innerText);
</script>
</body>
</html>