@tsparticles/template-confetti 4.1.3 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +3 -0
- package/package.json +4 -3
- package/template/angular/package.json +34 -0
- package/template/angular/src/app/app.component.css +54 -0
- package/template/angular/src/app/app.component.html +11 -0
- package/template/angular/src/app/app.component.ts +44 -0
- package/template/angular/src/app/app.module.ts +13 -0
- package/template/angular-confetti/package.json +35 -0
- package/template/angular-confetti/src/app/app.component.css +47 -0
- package/template/angular-confetti/src/app/app.component.html +11 -0
- package/template/angular-confetti/src/app/app.component.ts +44 -0
- package/template/angular-fireworks/package.json +35 -0
- package/template/angular-fireworks/src/app/app.component.css +47 -0
- package/template/angular-fireworks/src/app/app.component.html +11 -0
- package/template/angular-fireworks/src/app/app.component.ts +44 -0
- package/template/astro/package.json +21 -0
- package/template/astro/src/pages/index.astro +77 -0
- package/template/ember/app/templates/application.hbs +26 -0
- package/template/ember/package.json +41 -0
- package/template/inferno/package.json +23 -0
- package/template/inferno/src/App.css +54 -0
- package/template/inferno/src/App.tsx +69 -0
- package/template/jquery/package.json +21 -0
- package/template/jquery/src/main.ts +49 -0
- package/template/jquery/src/style.css +54 -0
- package/template/lit/package.json +21 -0
- package/template/lit/src/my-app.ts +68 -0
- package/template/nextjs/package.json +24 -0
- package/template/nextjs/src/app/page.tsx +59 -0
- package/template/nuxt2/package.json +16 -0
- package/template/nuxt2/pages/index.vue +72 -0
- package/template/nuxt3/app.vue +65 -0
- package/template/nuxt3/package.json +20 -0
- package/template/nuxt4/app.vue +65 -0
- package/template/nuxt4/package.json +20 -0
- package/template/preact/package.json +22 -0
- package/template/preact/src/App.css +54 -0
- package/template/preact/src/App.tsx +62 -0
- package/template/qwik/package.json +21 -0
- package/template/qwik/src/App.tsx +61 -0
- package/template/react/package.json +19 -0
- package/template/react/src/App.css +54 -0
- package/template/react/src/App.tsx +60 -0
- package/template/riot/package.json +23 -0
- package/template/riot/src/app.riot +111 -0
- package/template/solid/package.json +18 -0
- package/template/solid/src/App.tsx +66 -0
- package/template/solid/src/index.css +54 -0
- package/template/solid/src/main.tsx +9 -0
- package/template/stencil/package.json +19 -0
- package/template/stencil/src/components/app-home/app-home.tsx +73 -0
- package/template/svelte/package.json +20 -0
- package/template/svelte/src/App.svelte +119 -0
- package/template/svelte/src/main.ts +6 -0
- package/template/vanilla/LICENSE +21 -0
- package/template/vue2/package.json +23 -0
- package/template/vue2/src/App.vue +121 -0
- package/template/vue3/package.json +19 -0
- package/template/vue3/src/App.vue +110 -0
- package/template/vue3/src/main.ts +9 -0
- package/template/webcomponents/package.json +20 -0
- package/template/webcomponents/src/main.ts +48 -0
- package/template/webcomponents/src/style.css +54 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"preact": "^10.19.3",
|
|
13
|
+
"@tsparticles/preact": "^4.1.3",
|
|
14
|
+
"@tsparticles/confetti": "^4.1.3",
|
|
15
|
+
"@tsparticles/engine": "^4.1.3"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@preact/preset-vite": "^2.8.1",
|
|
19
|
+
"typescript": "^5.7.2",
|
|
20
|
+
"vite": "^6.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
background: #1a1a2e;
|
|
5
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
#app {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 50%;
|
|
11
|
+
left: 50%;
|
|
12
|
+
transform: translate(-50%, -50%);
|
|
13
|
+
z-index: 10;
|
|
14
|
+
text-align: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
h1 {
|
|
18
|
+
font-size: 3.2em;
|
|
19
|
+
color: #fff;
|
|
20
|
+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.controls {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 1rem;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-top: 2rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button {
|
|
32
|
+
padding: 0.8em 2em;
|
|
33
|
+
font-size: 1.1em;
|
|
34
|
+
border: none;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
background: #e94560;
|
|
37
|
+
color: #fff;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: background 0.2s;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
button:hover {
|
|
43
|
+
background: #ff6b81;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
select {
|
|
47
|
+
padding: 0.8em 1em;
|
|
48
|
+
font-size: 1em;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
border: 1px solid #444;
|
|
51
|
+
background: #16213e;
|
|
52
|
+
color: #fff;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useState, useEffect } from "preact/hooks";
|
|
2
|
+
import Particles, { initParticlesEngine } from "@tsparticles/preact";
|
|
3
|
+
import { confetti } from "@tsparticles/confetti";
|
|
4
|
+
import "./App.css";
|
|
5
|
+
|
|
6
|
+
function randomInRange(min: number, max: number): number {
|
|
7
|
+
return Math.random() * (max - min) + min;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function App() {
|
|
11
|
+
const [mode, setMode] = useState("cannon");
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
void initParticlesEngine(() => Promise.resolve());
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
function fireConfetti() {
|
|
18
|
+
switch (mode) {
|
|
19
|
+
case "cannon":
|
|
20
|
+
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
21
|
+
break;
|
|
22
|
+
case "waterfall": {
|
|
23
|
+
const duration = 3000;
|
|
24
|
+
const end = Date.now() + duration;
|
|
25
|
+
const interval = setInterval(() => {
|
|
26
|
+
if (Date.now() > end) {
|
|
27
|
+
clearInterval(interval);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
confetti({ particleCount: 10, angle: 60, spread: 55, origin: { x: 0, y: 0.6 } });
|
|
31
|
+
confetti({ particleCount: 10, angle: 120, spread: 55, origin: { x: 1, y: 0.6 } });
|
|
32
|
+
}, 100);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case "random":
|
|
36
|
+
confetti({
|
|
37
|
+
angle: randomInRange(55, 125),
|
|
38
|
+
spread: randomInRange(50, 70),
|
|
39
|
+
particleCount: randomInRange(50, 100),
|
|
40
|
+
origin: { y: 0.6 },
|
|
41
|
+
});
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div>
|
|
48
|
+
<div id="app">
|
|
49
|
+
<h1>Confetti!</h1>
|
|
50
|
+
<div class="controls">
|
|
51
|
+
<button onClick={fireConfetti}>Fire Confetti</button>
|
|
52
|
+
<select value={mode} onChange={(e) => setMode((e.target as HTMLSelectElement).value)}>
|
|
53
|
+
<option value="cannon">Cannon</option>
|
|
54
|
+
<option value="waterfall">Waterfall</option>
|
|
55
|
+
<option value="random">Random</option>
|
|
56
|
+
</select>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<Particles id="tsparticles" options={{}} />
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@builder.io/qwik": "^1.12.0",
|
|
13
|
+
"@tsparticles/qwik": "^4.1.3",
|
|
14
|
+
"@tsparticles/confetti": "^4.1.3",
|
|
15
|
+
"@tsparticles/engine": "^4.1.3"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.2",
|
|
19
|
+
"vite": "^6.0.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { component$, useVisibleTask$, useSignal } from "@builder.io/qwik";
|
|
2
|
+
import { Particles, initParticlesEngine } from "@tsparticles/qwik";
|
|
3
|
+
import { confetti } from "@tsparticles/confetti";
|
|
4
|
+
|
|
5
|
+
function randomInRange(min: number, max: number): number {
|
|
6
|
+
return Math.random() * (max - min) + min;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default component$(() => {
|
|
10
|
+
const mode = useSignal("cannon");
|
|
11
|
+
|
|
12
|
+
useVisibleTask$(() => {
|
|
13
|
+
void initParticlesEngine(() => Promise.resolve());
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const fireConfetti = () => {
|
|
17
|
+
switch (mode.value) {
|
|
18
|
+
case "cannon":
|
|
19
|
+
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
20
|
+
break;
|
|
21
|
+
case "waterfall": {
|
|
22
|
+
const duration = 3000;
|
|
23
|
+
const end = Date.now() + duration;
|
|
24
|
+
const interval = setInterval(() => {
|
|
25
|
+
if (Date.now() > end) {
|
|
26
|
+
clearInterval(interval);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
confetti({ particleCount: 10, angle: 60, spread: 55, origin: { x: 0, y: 0.6 } });
|
|
30
|
+
confetti({ particleCount: 10, angle: 120, spread: 55, origin: { x: 1, y: 0.6 } });
|
|
31
|
+
}, 100);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case "random":
|
|
35
|
+
confetti({
|
|
36
|
+
angle: randomInRange(55, 125),
|
|
37
|
+
spread: randomInRange(50, 70),
|
|
38
|
+
particleCount: randomInRange(50, 100),
|
|
39
|
+
origin: { y: 0.6 },
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div>
|
|
47
|
+
<div id="app">
|
|
48
|
+
<h1>Confetti!</h1>
|
|
49
|
+
<div class="controls">
|
|
50
|
+
<button onClick$={fireConfetti}>Fire Confetti</button>
|
|
51
|
+
<select value={mode.value} onChange$={(_, el) => (mode.value = el.value)}>
|
|
52
|
+
<option value="cannon">Cannon</option>
|
|
53
|
+
<option value="waterfall">Waterfall</option>
|
|
54
|
+
<option value="random">Random</option>
|
|
55
|
+
</select>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<Particles id="tsparticles" options={{}} />
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"react": "^19.2.5",
|
|
13
|
+
"react-dom": "^19.2.5",
|
|
14
|
+
"@tsparticles/react": "^4.1.3"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@vitejs/plugin-react": "^6.0.1"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
background: #1a1a2e;
|
|
5
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
#app {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 50%;
|
|
11
|
+
left: 50%;
|
|
12
|
+
transform: translate(-50%, -50%);
|
|
13
|
+
z-index: 10;
|
|
14
|
+
text-align: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
h1 {
|
|
18
|
+
font-size: 3.2em;
|
|
19
|
+
color: #fff;
|
|
20
|
+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.controls {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 1rem;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-top: 2rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button {
|
|
32
|
+
padding: 0.8em 2em;
|
|
33
|
+
font-size: 1.1em;
|
|
34
|
+
border: none;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
background: #e94560;
|
|
37
|
+
color: #fff;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: background 0.2s;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
button:hover {
|
|
43
|
+
background: #ff6b81;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
select {
|
|
47
|
+
padding: 0.8em 1em;
|
|
48
|
+
font-size: 1em;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
border: 1px solid #444;
|
|
51
|
+
background: #16213e;
|
|
52
|
+
color: #fff;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import Particles, { ParticlesProvider } from "@tsparticles/react";
|
|
3
|
+
import { confetti } from "@tsparticles/confetti";
|
|
4
|
+
import type { Engine } from "@tsparticles/engine";
|
|
5
|
+
import "./App.css";
|
|
6
|
+
|
|
7
|
+
function randomInRange(min: number, max: number): number {
|
|
8
|
+
return Math.random() * (max - min) + min;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function init(engine: Engine): Promise<void> {}
|
|
12
|
+
|
|
13
|
+
export default function App() {
|
|
14
|
+
const [mode, setMode] = useState("cannon");
|
|
15
|
+
|
|
16
|
+
function fireConfetti() {
|
|
17
|
+
switch (mode) {
|
|
18
|
+
case "cannon":
|
|
19
|
+
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
20
|
+
break;
|
|
21
|
+
case "waterfall": {
|
|
22
|
+
const duration = 3000;
|
|
23
|
+
const end = Date.now() + duration;
|
|
24
|
+
const interval = setInterval(() => {
|
|
25
|
+
if (Date.now() > end) {
|
|
26
|
+
clearInterval(interval);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
confetti({ particleCount: 10, angle: 60, spread: 55, origin: { x: 0, y: 0.6 } });
|
|
30
|
+
confetti({ particleCount: 10, angle: 120, spread: 55, origin: { x: 1, y: 0.6 } });
|
|
31
|
+
}, 100);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case "random":
|
|
35
|
+
confetti({
|
|
36
|
+
angle: randomInRange(55, 125),
|
|
37
|
+
spread: randomInRange(50, 70),
|
|
38
|
+
particleCount: randomInRange(50, 100),
|
|
39
|
+
origin: { y: 0.6 },
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<ParticlesProvider init={init}>
|
|
47
|
+
<div id="app">
|
|
48
|
+
<h1>Confetti!</h1>
|
|
49
|
+
<div className="controls">
|
|
50
|
+
<button onClick={fireConfetti}>Fire Confetti</button>
|
|
51
|
+
<select value={mode} onChange={(e) => setMode(e.target.value)}>
|
|
52
|
+
<option value="cannon">Cannon</option>
|
|
53
|
+
<option value="waterfall">Waterfall</option>
|
|
54
|
+
<option value="random">Random</option>
|
|
55
|
+
</select>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</ParticlesProvider>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"riot": "^10.0.0",
|
|
13
|
+
"@tsparticles/riot": "^4.1.3",
|
|
14
|
+
"@tsparticles/confetti": "^4.1.3",
|
|
15
|
+
"@tsparticles/engine": "^4.1.3"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@riotjs/compiler": "^10.0.0",
|
|
19
|
+
"rollup-plugin-riot": "^10.0.0",
|
|
20
|
+
"typescript": "^5.7.2",
|
|
21
|
+
"vite": "^6.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<app>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<h1>Confetti!</h1>
|
|
4
|
+
<div class="controls">
|
|
5
|
+
<button onclick={ fireConfetti }>Fire Confetti</button>
|
|
6
|
+
<select onchange={ handleModeChange }>
|
|
7
|
+
<option value="cannon" selected={ state.mode === "cannon" }>Cannon</option>
|
|
8
|
+
<option value="waterfall" selected={ state.mode === "waterfall" }>Waterfall</option>
|
|
9
|
+
<option value="random" selected={ state.mode === "random" }>Random</option>
|
|
10
|
+
</select>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<riot-particles id="tsparticles" options={ state.options }></riot-particles>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { confetti } from "@tsparticles/confetti"
|
|
17
|
+
|
|
18
|
+
function randomInRange(min, max) {
|
|
19
|
+
return Math.random() * (max - min) + min
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
state: {
|
|
24
|
+
mode: "cannon",
|
|
25
|
+
options: {}
|
|
26
|
+
},
|
|
27
|
+
handleModeChange(e) {
|
|
28
|
+
this.update({ mode: e.target.value })
|
|
29
|
+
},
|
|
30
|
+
fireConfetti() {
|
|
31
|
+
switch (this.state.mode) {
|
|
32
|
+
case "cannon":
|
|
33
|
+
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } })
|
|
34
|
+
break
|
|
35
|
+
case "waterfall": {
|
|
36
|
+
const duration = 3000
|
|
37
|
+
const end = Date.now() + duration
|
|
38
|
+
const interval = setInterval(() => {
|
|
39
|
+
if (Date.now() > end) {
|
|
40
|
+
clearInterval(interval)
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
confetti({ particleCount: 10, angle: 60, spread: 55, origin: { x: 0, y: 0.6 } })
|
|
44
|
+
confetti({ particleCount: 10, angle: 120, spread: 55, origin: { x: 1, y: 0.6 } })
|
|
45
|
+
}, 100)
|
|
46
|
+
break
|
|
47
|
+
}
|
|
48
|
+
case "random":
|
|
49
|
+
confetti({
|
|
50
|
+
angle: randomInRange(55, 125),
|
|
51
|
+
spread: randomInRange(50, 70),
|
|
52
|
+
particleCount: randomInRange(50, 100),
|
|
53
|
+
origin: { y: 0.6 }
|
|
54
|
+
})
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
body {
|
|
63
|
+
margin: 0;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
background: #1a1a2e;
|
|
66
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
67
|
+
}
|
|
68
|
+
#app {
|
|
69
|
+
position: absolute;
|
|
70
|
+
top: 50%;
|
|
71
|
+
left: 50%;
|
|
72
|
+
transform: translate(-50%, -50%);
|
|
73
|
+
z-index: 10;
|
|
74
|
+
text-align: center;
|
|
75
|
+
}
|
|
76
|
+
h1 {
|
|
77
|
+
font-size: 3.2em;
|
|
78
|
+
color: #fff;
|
|
79
|
+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
|
|
80
|
+
}
|
|
81
|
+
.controls {
|
|
82
|
+
display: flex;
|
|
83
|
+
gap: 1rem;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
align-items: center;
|
|
86
|
+
margin-top: 2rem;
|
|
87
|
+
}
|
|
88
|
+
button {
|
|
89
|
+
padding: 0.8em 2em;
|
|
90
|
+
font-size: 1.1em;
|
|
91
|
+
border: none;
|
|
92
|
+
border-radius: 8px;
|
|
93
|
+
background: #e94560;
|
|
94
|
+
color: #fff;
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
transition: background 0.2s;
|
|
97
|
+
}
|
|
98
|
+
button:hover {
|
|
99
|
+
background: #ff6b81;
|
|
100
|
+
}
|
|
101
|
+
select {
|
|
102
|
+
padding: 0.8em 1em;
|
|
103
|
+
font-size: 1em;
|
|
104
|
+
border-radius: 8px;
|
|
105
|
+
border: 1px solid #444;
|
|
106
|
+
background: #16213e;
|
|
107
|
+
color: #fff;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
111
|
+
</app>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"solid-js": "^1.8.11",
|
|
13
|
+
"@tsparticles/solid": "^4.1.3"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"vite-plugin-solid": "^2.8.2"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createSignal } from "solid-js";
|
|
2
|
+
import { confetti } from "@tsparticles/confetti";
|
|
3
|
+
|
|
4
|
+
function randomInRange(min: number, max: number): number {
|
|
5
|
+
return Math.random() * (max - min) + min;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function App() {
|
|
9
|
+
const [mode, setMode] = createSignal("cannon");
|
|
10
|
+
|
|
11
|
+
function handleFire() {
|
|
12
|
+
switch (mode()) {
|
|
13
|
+
case "cannon":
|
|
14
|
+
confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
|
|
15
|
+
break;
|
|
16
|
+
|
|
17
|
+
case "waterfall": {
|
|
18
|
+
const duration = 3000;
|
|
19
|
+
const end = Date.now() + duration;
|
|
20
|
+
|
|
21
|
+
const interval = setInterval(() => {
|
|
22
|
+
if (Date.now() > end) {
|
|
23
|
+
clearInterval(interval);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
confetti({
|
|
27
|
+
particleCount: 10,
|
|
28
|
+
angle: 60,
|
|
29
|
+
spread: 55,
|
|
30
|
+
origin: { x: 0, y: 0.6 },
|
|
31
|
+
});
|
|
32
|
+
confetti({
|
|
33
|
+
particleCount: 10,
|
|
34
|
+
angle: 120,
|
|
35
|
+
spread: 55,
|
|
36
|
+
origin: { x: 1, y: 0.6 },
|
|
37
|
+
});
|
|
38
|
+
}, 100);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
case "random":
|
|
43
|
+
confetti({
|
|
44
|
+
angle: randomInRange(55, 125),
|
|
45
|
+
spread: randomInRange(50, 70),
|
|
46
|
+
particleCount: randomInRange(50, 100),
|
|
47
|
+
origin: { y: 0.6 },
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div id="app">
|
|
55
|
+
<h1>Confetti!</h1>
|
|
56
|
+
<div class="controls">
|
|
57
|
+
<button onClick={handleFire}>Fire Confetti</button>
|
|
58
|
+
<select value={mode()} onChange={(e) => setMode(e.currentTarget.value)}>
|
|
59
|
+
<option value="cannon">Cannon</option>
|
|
60
|
+
<option value="waterfall">Waterfall</option>
|
|
61
|
+
<option value="random">Random</option>
|
|
62
|
+
</select>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
background: #1a1a2e;
|
|
5
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
#app {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 50%;
|
|
11
|
+
left: 50%;
|
|
12
|
+
transform: translate(-50%, -50%);
|
|
13
|
+
z-index: 10;
|
|
14
|
+
text-align: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
h1 {
|
|
18
|
+
font-size: 3.2em;
|
|
19
|
+
color: #fff;
|
|
20
|
+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.controls {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 1rem;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-top: 2rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button {
|
|
32
|
+
padding: 0.8em 2em;
|
|
33
|
+
font-size: 1.1em;
|
|
34
|
+
border: none;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
background: #e94560;
|
|
37
|
+
color: #fff;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: background 0.2s;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
button:hover {
|
|
43
|
+
background: #ff6b81;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
select {
|
|
47
|
+
padding: 0.8em 1em;
|
|
48
|
+
font-size: 1em;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
border: 1px solid #444;
|
|
51
|
+
background: #16213e;
|
|
52
|
+
color: #fff;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "stencil build --dev --watch --serve",
|
|
7
|
+
"build": "stencil build",
|
|
8
|
+
"preview": "stencil build --serve"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@stencil/core": "^4.43.5",
|
|
12
|
+
"@tsparticles/stencil": "^4.1.3",
|
|
13
|
+
"@tsparticles/confetti": "^4.1.3",
|
|
14
|
+
"@tsparticles/engine": "^4.1.3"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^6.0.3"
|
|
18
|
+
}
|
|
19
|
+
}
|