Skip to content

Commit a637498

Browse files
committed
update styles of letters flying
1 parent 2b302ab commit a637498

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

src/components/TypingGame.tsx

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Container, Group, Space, Title } from "@mantine/core";
1+
import { Box, Container, Group, Space, Title } from "@mantine/core";
22
import { Stack } from "@mantine/core";
3-
import { useCallback, useEffect, useState } from "react";
3+
import { useCallback, useEffect, useMemo, useState } from "react";
44
import { ActionBar } from "./ActionBar";
55
import { KeyCode } from "../KeyCode";
66
import { WordsCard } from "./WordsCard";
@@ -122,7 +122,6 @@ const Circles = styled.ul`
122122
123123
li {
124124
position: absolute;
125-
display: block;
126125
list-style: none;
127126
width: 20px;
128127
height: 20px;
@@ -135,6 +134,7 @@ const Circles = styled.ul`
135134
left: 25%;
136135
width: 80px;
137136
height: 80px;
137+
font-size: 40px;
138138
animation-delay: 0s;
139139
}
140140
@@ -144,13 +144,15 @@ const Circles = styled.ul`
144144
height: 20px;
145145
animation-delay: 2s;
146146
animation-duration: 12s;
147+
font-size: 10px;
147148
}
148149
149150
li:nth-child(3) {
150151
left: 70%;
151152
width: 20px;
152153
height: 20px;
153154
animation-delay: 4s;
155+
font-size: 10px;
154156
}
155157
156158
li:nth-child(4) {
@@ -159,27 +161,31 @@ const Circles = styled.ul`
159161
height: 60px;
160162
animation-delay: 0s;
161163
animation-duration: 18s;
164+
font-size: 30px;
162165
}
163166
164167
li:nth-child(5) {
165168
left: 65%;
166169
width: 20px;
167170
height: 20px;
168171
animation-delay: 0s;
172+
font-size: 10px;
169173
}
170174
171175
li:nth-child(6) {
172176
left: 75%;
173177
width: 110px;
174178
height: 110px;
175179
animation-delay: 3s;
180+
font-size: 55px;
176181
}
177182
178183
li:nth-child(7) {
179184
left: 35%;
180185
width: 150px;
181186
height: 150px;
182187
animation-delay: 7s;
188+
font-size: 75px;
183189
}
184190
185191
li:nth-child(8) {
@@ -188,6 +194,7 @@ const Circles = styled.ul`
188194
height: 25px;
189195
animation-delay: 15s;
190196
animation-duration: 45s;
197+
font-size: 12px;
191198
}
192199
193200
li:nth-child(9) {
@@ -196,6 +203,7 @@ const Circles = styled.ul`
196203
height: 15px;
197204
animation-delay: 2s;
198205
animation-duration: 35s;
206+
font-size: 7px;
199207
}
200208
201209
li:nth-child(10) {
@@ -204,6 +212,7 @@ const Circles = styled.ul`
204212
height: 150px;
205213
animation-delay: 0s;
206214
animation-duration: 11s;
215+
font-size: 75px;
207216
}
208217
209218
@keyframes animate {
@@ -225,17 +234,39 @@ function Back() {
225234
return (
226235
<Area>
227236
<Circles>
228-
<li></li>
229-
<li></li>
230-
<li></li>
231-
<li></li>
232-
<li></li>
233-
<li></li>
234-
<li></li>
235-
<li></li>
236-
<li></li>
237-
<li></li>
237+
{Array(10)
238+
.fill(null)
239+
.map((_a, index) => (
240+
<Circle key={index} />
241+
))}
238242
</Circles>
239243
</Area>
240244
);
241245
}
246+
247+
const letters = Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
248+
249+
const CircleMain = styled.li`
250+
height: 100%;
251+
width: 100%;
252+
display: flex;
253+
justify-content: center;
254+
align-items: center;
255+
`;
256+
257+
const LetterLayout = styled.div`
258+
align-self: last baseline;
259+
`;
260+
261+
function Circle() {
262+
const letter = useMemo(() => {
263+
const index = Math.floor(Math.random() * 26);
264+
return letters[index];
265+
}, []);
266+
267+
return (
268+
<CircleMain>
269+
<LetterLayout>{letter}</LetterLayout>
270+
</CircleMain>
271+
);
272+
}

0 commit comments

Comments
 (0)