-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathAnimatedStars.astro
More file actions
175 lines (167 loc) · 4.08 KB
/
AnimatedStars.astro
File metadata and controls
175 lines (167 loc) · 4.08 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
// Animated starfield background component
// Creates a twinkling star effect with two layers of stars
// that move, scale, rotate, and change opacity
---
<div class="animated-stars">
<slot />
</div>
<style>
.animated-stars {
position: relative;
width: 100%;
min-height: 100vh;
}
.animated-stars::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image:
radial-gradient(1px 1px at 10% 20%, white, transparent),
radial-gradient(1px 1px at 30% 40%, white, transparent),
radial-gradient(1px 1px at 50% 60%, white, transparent),
radial-gradient(1px 1px at 70% 30%, white, transparent),
radial-gradient(1px 1px at 90% 80%, white, transparent),
radial-gradient(1px 1px at 15% 70%, white, transparent),
radial-gradient(1px 1px at 40% 15%, white, transparent),
radial-gradient(1px 1px at 60% 85%, white, transparent),
radial-gradient(1px 1px at 85% 50%, white, transparent),
radial-gradient(1px 1px at 25% 90%, white, transparent);
background-size:
200px 200px,
250px 250px,
300px 300px,
180px 180px,
220px 220px,
280px 280px,
240px 240px,
260px 260px,
290px 290px,
210px 210px;
background-position:
0 0,
40px 60px,
130px 270px,
70px 100px,
220px 180px,
300px 320px,
150px 80px,
280px 380px,
100px 200px,
350px 250px;
background-repeat: repeat;
animation: twinkle1 45s ease-in-out infinite;
pointer-events: none;
z-index: 0;
}
.animated-stars::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image:
radial-gradient(2px 2px at 20% 15%, rgba(255,255,255,0.8), transparent),
radial-gradient(1px 1px at 45% 35%, white, transparent),
radial-gradient(1px 1px at 65% 55%, rgba(255,255,255,0.7), transparent),
radial-gradient(2px 2px at 80% 25%, white, transparent),
radial-gradient(1px 1px at 35% 75%, rgba(255,255,255,0.9), transparent),
radial-gradient(1px 1px at 55% 45%, white, transparent);
background-size:
300px 300px,
200px 200px,
250px 250px,
280px 280px,
220px 220px,
240px 240px;
background-position:
0 0,
50px 80px,
100px 150px,
200px 50px,
150px 200px,
250px 100px;
background-repeat: repeat;
animation: twinkle2 60s ease-in-out infinite;
pointer-events: none;
z-index: 0;
}
.animated-stars > :global(*) {
position: relative;
z-index: 1;
}
@keyframes twinkle1 {
0% {
opacity: 1;
transform: translate(0, 0) scale(1);
}
15% {
opacity: 0.4;
transform: translate(25px, -15px) scale(1.1);
}
30% {
opacity: 0.8;
transform: translate(-20px, 30px) scale(0.9);
}
45% {
opacity: 0.3;
transform: translate(30px, 20px) scale(1.05);
}
60% {
opacity: 0.9;
transform: translate(-25px, -25px) scale(0.95);
}
75% {
opacity: 0.5;
transform: translate(15px, 35px) scale(1.08);
}
90% {
opacity: 0.7;
transform: translate(-30px, -10px) scale(0.92);
}
100% {
opacity: 1;
transform: translate(0, 0) scale(1);
}
}
@keyframes twinkle2 {
0% {
opacity: 0.8;
transform: translate(0, 0) rotate(0deg);
}
20% {
opacity: 0.3;
transform: translate(-30px, 20px) rotate(5deg);
}
35% {
opacity: 0.9;
transform: translate(25px, -25px) rotate(-3deg);
}
50% {
opacity: 0.4;
transform: translate(-15px, -30px) rotate(7deg);
}
65% {
opacity: 0.7;
transform: translate(35px, 15px) rotate(-5deg);
}
80% {
opacity: 0.5;
transform: translate(-20px, 28px) rotate(4deg);
}
100% {
opacity: 0.8;
transform: translate(0, 0) rotate(0deg);
}
}
@media (prefers-reduced-motion: reduce) {
.animated-stars::before,
.animated-stars::after {
animation: none;
}
}
</style>