Skip to content

Commit 48a19ed

Browse files
committed
add background to game
1 parent 98a5c4a commit 48a19ed

File tree

1 file changed

+144
-2
lines changed

1 file changed

+144
-2
lines changed

src/components/TypingGame.tsx

Lines changed: 144 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useCountdown } from "../utils/useCountdown";
99
import { useTypingCapture } from "../utils/useTypingCapture";
1010
import { useMeasureWpm } from "../utils/useMeasureWpm";
1111
import { StatsBar } from "./StatsBar";
12+
import styled from "@emotion/styled";
1213

1314
export function TypingGame() {
1415
const { wpm, timeLeft, board, restart } = useTypingGame();
@@ -20,13 +21,19 @@ export function TypingGame() {
2021
fluid={true}
2122
>
2223
<Stack align="stretch" sx={{ height: "100%" }}>
24+
<Back />
2325
<Stack sx={{ width: "800px", alignSelf: "center" }}>
2426
<Group position="center">
25-
<Title order={1} sx={{
27+
<Title
28+
order={1}
29+
sx={{
2630
textTransform: "uppercase",
2731
textShadow: "-2px 3px 3px #f28822",
2832
whiteSpace: "pre",
29-
}}>Typing Test</Title>
33+
}}
34+
>
35+
Typing Test
36+
</Title>
3037
</Group>
3138
<ActionBar wpm={wpm} timeLeft={timeLeft} onRestart={restart} />
3239
<Space h="xl" />
@@ -97,3 +104,138 @@ function useTypingGame() {
97104
onTyping,
98105
};
99106
}
107+
108+
const Area = styled.div`
109+
background: -webkit-linear-gradient(to left, #8f94fb, #4e54c8);
110+
width: 100%;
111+
height: 100vh;
112+
position: absolute;
113+
`;
114+
115+
const Circles = styled.ul`
116+
position: absolute;
117+
top: 0;
118+
left: 0;
119+
width: 100%;
120+
height: 100%;
121+
overflow: hidden;
122+
123+
li {
124+
position: absolute;
125+
display: block;
126+
list-style: none;
127+
width: 20px;
128+
height: 20px;
129+
background: rgba(255, 255, 255, 0.2);
130+
animation: animate 25s linear infinite;
131+
bottom: -150px;
132+
}
133+
134+
li:nth-child(1) {
135+
left: 25%;
136+
width: 80px;
137+
height: 80px;
138+
animation-delay: 0s;
139+
}
140+
141+
li:nth-child(2) {
142+
left: 10%;
143+
width: 20px;
144+
height: 20px;
145+
animation-delay: 2s;
146+
animation-duration: 12s;
147+
}
148+
149+
li:nth-child(3) {
150+
left: 70%;
151+
width: 20px;
152+
height: 20px;
153+
animation-delay: 4s;
154+
}
155+
156+
li:nth-child(4) {
157+
left: 40%;
158+
width: 60px;
159+
height: 60px;
160+
animation-delay: 0s;
161+
animation-duration: 18s;
162+
}
163+
164+
li:nth-child(5) {
165+
left: 65%;
166+
width: 20px;
167+
height: 20px;
168+
animation-delay: 0s;
169+
}
170+
171+
li:nth-child(6) {
172+
left: 75%;
173+
width: 110px;
174+
height: 110px;
175+
animation-delay: 3s;
176+
}
177+
178+
li:nth-child(7) {
179+
left: 35%;
180+
width: 150px;
181+
height: 150px;
182+
animation-delay: 7s;
183+
}
184+
185+
li:nth-child(8) {
186+
left: 50%;
187+
width: 25px;
188+
height: 25px;
189+
animation-delay: 15s;
190+
animation-duration: 45s;
191+
}
192+
193+
li:nth-child(9) {
194+
left: 20%;
195+
width: 15px;
196+
height: 15px;
197+
animation-delay: 2s;
198+
animation-duration: 35s;
199+
}
200+
201+
li:nth-child(10) {
202+
left: 85%;
203+
width: 150px;
204+
height: 150px;
205+
animation-delay: 0s;
206+
animation-duration: 11s;
207+
}
208+
209+
@keyframes animate {
210+
0% {
211+
transform: translateY(0) rotate(0deg);
212+
opacity: 1;
213+
border-radius: 0;
214+
}
215+
216+
100% {
217+
transform: translateY(-1000px) rotate(720deg);
218+
opacity: 0;
219+
border-radius: 50%;
220+
}
221+
}
222+
`;
223+
224+
function Back() {
225+
return (
226+
<Area>
227+
<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>
238+
</Circles>
239+
</Area>
240+
);
241+
}

0 commit comments

Comments
 (0)