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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use leptos::prelude::*;
#[component]
pub fn ParticleAnimation() -> impl IntoView {
view! {
<div class="absolute inset-0 overflow-hidden">
<div class="particle-container">
// Create multiple particle elements
{(0..50)
.map(|i| {
let delay = format!("{}s", i as f32 * 0.1);
let duration = format!("{}s", 20.0 + (i as f32 * 0.5));
let start_x = format!("{}%", (i * 17) % 100);
let start_y = format!("{}%", (i * 23) % 100);
view! {
<div
class="particle"
style=format!(
"left: {}; top: {}; animation-delay: {}; animation-duration: {};",
start_x,
start_y,
delay,
duration,
)
/>
}
})
.collect::<Vec<_>>()}
</div>
// Add connecting lines as pseudo-elements via CSS
<style>
r#"
.particle-container {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.particle {
position: absolute;
width: 4px;
height: 4px;
background-color: rgba(23, 23, 23, 0.5);
border-radius: 50%;
animation: float-particle 20s infinite ease-in-out;
}
.dark .particle {
background-color: rgba(245, 245, 245, 0.5);
}
.particle::before {
content: '';
position: absolute;
width: 80px;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(23, 23, 23, 0.2), transparent);
transform-origin: 0 50%;
animation: connect-line 8s infinite ease-in-out;
}
.dark .particle::before {
background: linear-gradient(90deg, transparent, rgba(245, 245, 245, 0.2), transparent);
}
@keyframes float-particle {
0%, 100% {
transform: translate(0, 0) scale(1);
}
25% {
transform: translate(30px, -40px) scale(1.1);
}
50% {
transform: translate(-20px, 20px) scale(0.9);
}
75% {
transform: translate(40px, 30px) scale(1.05);
}
}
@keyframes connect-line {
0%, 100% {
transform: rotate(0deg) scaleX(0);
opacity: 0;
}
20% {
transform: rotate(45deg) scaleX(1);
opacity: 0.3;
}
40% {
transform: rotate(-30deg) scaleX(1.2);
opacity: 0.2;
}
60% {
transform: rotate(60deg) scaleX(0.8);
opacity: 0.3;
}
80% {
transform: rotate(-45deg) scaleX(1);
opacity: 0.1;
}
}
/* Add some particles with different animation timing */
.particle:nth-child(odd) {
animation-direction: reverse;
}
.particle:nth-child(3n) {
animation-duration: 25s;
}
.particle:nth-child(5n) {
width: 6px;
height: 6px;
}
.particle:nth-child(7n)::before {
width: 120px;
animation-duration: 10s;
}
"#
</style>
</div>
}
}