-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.jsx
More file actions
48 lines (43 loc) · 1.08 KB
/
Home.jsx
File metadata and controls
48 lines (43 loc) · 1.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
import styled from "@emotion/styled";
import { useState } from 'react';
import Header from './components/Header';
import Game from './components/Game';
import Rank from './components/Rank'
const Home = () =>{
const [menu, setMenu] = useState("game");
const [level, setLevel] = useState(1);
const [timer, setTimer] = useState(0);
const handleMenuChange = (menu) => {
setMenu(menu);
}
const handleLevelSelect = (level) => {
setLevel(level);
};
const handleTimerChange = (timer) => {
setTimer(timer);
};
return (
<>
<Header
menu={menu}
timer={timer}
handleMenuChange={handleMenuChange}
handleLevelSelect={handleLevelSelect}
/>
<Main>
{menu === "game" ? (
<Game level={level} timer={timer} handleTimerChange={handleTimerChange}/>
):(
<Rank/>
)}
</Main>
</>
);
};
const Main = styled.main`
width: 100%;
height: 100%;
margin: 0 auto;
padding-top: 2rem;
`;
export default Home;