@hyvor/design 2.1.10 → 2.1.12
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/dist/components/Confetti/confetti.d.ts +7 -0
- package/dist/components/Confetti/confetti.js +102 -0
- package/dist/components/Dark/DarkProvider.svelte +5 -2
- package/dist/components/NavLink/NavLinkGroup.svelte +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/marketing/Docs/Docs.svelte +9 -7
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export function confetti(options = {}) {
|
|
2
|
+
const { particleCount = 220, duration = 12000, zIndex = 20000000 } = options;
|
|
3
|
+
const gravity = 0.18;
|
|
4
|
+
const drag = 0.96;
|
|
5
|
+
const canvas = document.createElement('canvas');
|
|
6
|
+
canvas.style.position = 'fixed';
|
|
7
|
+
canvas.style.top = '0';
|
|
8
|
+
canvas.style.left = '0';
|
|
9
|
+
canvas.style.width = '100vw';
|
|
10
|
+
canvas.style.height = '100vh';
|
|
11
|
+
canvas.style.pointerEvents = 'none';
|
|
12
|
+
canvas.style.zIndex = String(zIndex);
|
|
13
|
+
document.body.appendChild(canvas);
|
|
14
|
+
const ctx = canvas.getContext('2d');
|
|
15
|
+
canvas.width = window.innerWidth;
|
|
16
|
+
canvas.height = window.innerHeight;
|
|
17
|
+
const colors = ['#ffba6b', '#8cdaff', '#b5ffb0', '#ff9090', '#ffbfff', '#d894ff', '#fff79b'];
|
|
18
|
+
const particles = [];
|
|
19
|
+
let animationFrameId;
|
|
20
|
+
let timeoutId = null;
|
|
21
|
+
let running = true;
|
|
22
|
+
const originX = canvas.width / 2;
|
|
23
|
+
const originY = canvas.height / 2;
|
|
24
|
+
const createParticle = () => {
|
|
25
|
+
const angle = Math.random() * Math.PI * 2;
|
|
26
|
+
const speed = Math.random() * 16 + 10;
|
|
27
|
+
return {
|
|
28
|
+
x: originX + (Math.random() - 0.5) * 40,
|
|
29
|
+
y: originY + (Math.random() - 0.5) * 40,
|
|
30
|
+
size: Math.random() * 9 + 5,
|
|
31
|
+
color: colors[Math.floor(Math.random() * colors.length)],
|
|
32
|
+
velocityX: Math.cos(angle) * speed,
|
|
33
|
+
velocityY: Math.sin(angle) * speed,
|
|
34
|
+
rotation: Math.random() * 360,
|
|
35
|
+
rotationSpeed: Math.random() * 12 - 6,
|
|
36
|
+
wobble: Math.random() * Math.PI * 2,
|
|
37
|
+
wobbleSpeed: Math.random() * 0.1 + 0.05
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const drawParticle = (particle) => {
|
|
41
|
+
ctx.save();
|
|
42
|
+
ctx.translate(particle.x, particle.y);
|
|
43
|
+
ctx.rotate((particle.rotation * Math.PI) / 180);
|
|
44
|
+
ctx.fillStyle = particle.color;
|
|
45
|
+
ctx.beginPath();
|
|
46
|
+
ctx.roundRect(-particle.size / 2, -particle.size / 2, particle.size, particle.size, 1);
|
|
47
|
+
ctx.fill();
|
|
48
|
+
ctx.restore();
|
|
49
|
+
};
|
|
50
|
+
const updateParticles = () => {
|
|
51
|
+
for (const particle of particles) {
|
|
52
|
+
particle.velocityX *= drag;
|
|
53
|
+
particle.velocityY = particle.velocityY * drag + gravity;
|
|
54
|
+
particle.wobble += particle.wobbleSpeed;
|
|
55
|
+
particle.x += particle.velocityX + Math.sin(particle.wobble) * 0.8;
|
|
56
|
+
particle.y += particle.velocityY;
|
|
57
|
+
particle.rotation += particle.rotationSpeed;
|
|
58
|
+
}
|
|
59
|
+
const remaining = particles.filter((particle) => particle.y - particle.size <= canvas.height);
|
|
60
|
+
particles.length = 0;
|
|
61
|
+
particles.push(...remaining);
|
|
62
|
+
};
|
|
63
|
+
const render = () => {
|
|
64
|
+
if (!running)
|
|
65
|
+
return;
|
|
66
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
67
|
+
for (const particle of particles)
|
|
68
|
+
drawParticle(particle);
|
|
69
|
+
updateParticles();
|
|
70
|
+
if (particles.length === 0) {
|
|
71
|
+
stopConfetti();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
animationFrameId = requestAnimationFrame(render);
|
|
75
|
+
};
|
|
76
|
+
let stopped = false;
|
|
77
|
+
const stopConfetti = () => {
|
|
78
|
+
if (stopped)
|
|
79
|
+
return;
|
|
80
|
+
stopped = true;
|
|
81
|
+
running = false;
|
|
82
|
+
cancelAnimationFrame(animationFrameId);
|
|
83
|
+
if (timeoutId !== null)
|
|
84
|
+
clearTimeout(timeoutId);
|
|
85
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
86
|
+
canvas.remove();
|
|
87
|
+
};
|
|
88
|
+
const startConfetti = () => {
|
|
89
|
+
particles.length = 0;
|
|
90
|
+
for (let i = 0; i < particleCount; i++)
|
|
91
|
+
particles.push(createParticle());
|
|
92
|
+
running = true;
|
|
93
|
+
render();
|
|
94
|
+
if (duration > 0) {
|
|
95
|
+
timeoutId = window.setTimeout(stopConfetti, duration);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
startConfetti();
|
|
99
|
+
return {
|
|
100
|
+
stop: stopConfetti
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
<script>
|
|
12
12
|
// to prevent white screen on page load
|
|
13
13
|
// until the dark mode is initialized from the store
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
var hdsStored = localStorage.getItem('hds-dark');
|
|
15
|
+
var hsdIsDarkMode = hdsStored
|
|
16
|
+
? !!hdsStored
|
|
17
|
+
: window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
18
|
+
if (hsdIsDarkMode) {
|
|
16
19
|
document.documentElement.classList.add('dark');
|
|
17
20
|
}
|
|
18
21
|
</script>
|
|
@@ -16,6 +16,7 @@ export { highlightCode } from './CodeBlock/getCode.js';
|
|
|
16
16
|
export { default as TabbedCodeBlock } from './CodeBlock/TabbedCodeBlock.svelte';
|
|
17
17
|
export { default as ColorPicker } from './ColorPicker/ColorPicker.svelte';
|
|
18
18
|
export { default as ConsoleLoader } from './ConsoleLoader/ConsoleLoader.svelte';
|
|
19
|
+
export { confetti } from './Confetti/confetti.js';
|
|
19
20
|
export { default as DarkProvider } from './Dark/DarkProvider.svelte';
|
|
20
21
|
export { default as DarkToggle } from './Dark/DarkToggle.svelte';
|
|
21
22
|
export { default as DetailCard } from './DetailCard/DetailCard.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { highlightCode } from './CodeBlock/getCode.js';
|
|
|
16
16
|
export { default as TabbedCodeBlock } from './CodeBlock/TabbedCodeBlock.svelte';
|
|
17
17
|
export { default as ColorPicker } from './ColorPicker/ColorPicker.svelte';
|
|
18
18
|
export { default as ConsoleLoader } from './ConsoleLoader/ConsoleLoader.svelte';
|
|
19
|
+
export { confetti } from './Confetti/confetti.js';
|
|
19
20
|
export { default as DarkProvider } from './Dark/DarkProvider.svelte';
|
|
20
21
|
export { default as DarkToggle } from './Dark/DarkToggle.svelte';
|
|
21
22
|
export { default as DetailCard } from './DetailCard/DetailCard.svelte';
|
|
@@ -38,19 +38,21 @@
|
|
|
38
38
|
|
|
39
39
|
const headings = contentEl.querySelectorAll<HTMLElement>('h2[id], h3[id], h4[id]');
|
|
40
40
|
for (const h of headings) {
|
|
41
|
+
if (h.querySelector(':scope > a.heading-anchor')) continue;
|
|
42
|
+
|
|
43
|
+
const id = h.getAttribute('id');
|
|
44
|
+
const link = document.createElement('a');
|
|
45
|
+
link.className = 'heading-anchor';
|
|
46
|
+
link.setAttribute('href', '#' + id);
|
|
47
|
+
link.append(...h.childNodes);
|
|
48
|
+
|
|
41
49
|
const icon = document.createElement('a');
|
|
42
50
|
icon.className = 'heading-anchor-link';
|
|
43
51
|
icon.innerHTML =
|
|
44
52
|
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-link-45deg" viewBox="0 0 16 16"><path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1.002 1.002 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4.018 4.018 0 0 1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243L6.586 4.672z"/></svg>';
|
|
45
53
|
icon.tabIndex = -1;
|
|
46
|
-
h.appendChild(icon);
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
const link = document.createElement('a');
|
|
50
|
-
link.className = 'heading-anchor';
|
|
51
|
-
link.setAttribute('href', '#' + id);
|
|
52
|
-
link.innerHTML = h.innerHTML;
|
|
53
|
-
h.innerHTML = link.outerHTML;
|
|
55
|
+
h.replaceChildren(link, icon);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|