Home.js 1.73 KB
Newer Older
baesangjune's avatar
home    
baesangjune committed
1
import bg from './img_study.jpg'
baesangjune's avatar
baesangjune committed
2
3
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom';
Jiwon Yoon's avatar
Jiwon Yoon committed
4
5


baesangjune's avatar
baesangjune committed
6
function Home() {
baesangjune's avatar
baesangjune committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    const [name, setName] = useState('')
    const [done, setDone] = useState(false)

    const handleChange = (event) => {
        setName(event.target.value)
    }

    function checking(event) {
        if (!name) {
            alert('이름을 입력하세요')
        }
        else {
            alert('입력하신 이름은' + name + '입니다.')
            localStorage.setItem('name', name)
            setDone(true)
        }
    }

Jiwon Yoon's avatar
Jiwon Yoon committed
25
    return (
baesangjune's avatar
baesangjune committed
26
        <>
baesangjune's avatar
baesangjune committed
27
28
            {done ? <Redirect to='/quiz' /> : ''}
            <div style={{ backgroundImage: 'url(' + bg + ')', backgroundColor: "grey", backgroundSize: "100%", width: "100%", height: "880px", backgroundRepeat: 'no-repeat' }}>
baesangjune's avatar
0    
baesangjune committed
29
                {/* <div className="Main"></div> */}
baesangjune's avatar
home    
baesangjune committed
30
31

                <div className="Box">
baesangjune's avatar
baesangjune committed
32
                    <div className="Name" style={{ fontSize: '30px', position: "absolute", top: "330px", left: "38%" }}>
baesangjune's avatar
home    
baesangjune committed
33
                        이름을 입력하세요
baesangjune's avatar
baesangjune committed
34
                        <input style={{ marginLeft: '30px', inlineSize: '200px', blockSize: '40px', fontSize: '40px' }} onChange={handleChange} />
baesangjune's avatar
0    
baesangjune committed
35
                        <div className='Box2'>
baesangjune's avatar
baesangjune committed
36
                            <button style={{ marginTop: '35%', blockSize: '100px', inlineSize: '200px', fontSize: '35px' }} className="QuizStart" onClick={checking}>Quiz Start !</button>
baesangjune's avatar
0    
baesangjune committed
37
                        </div>
baesangjune's avatar
home    
baesangjune committed
38
                    </div>
baesangjune's avatar
0805    
baesangjune committed
39
                    {/* localStorage를 사용해야는지 localstorage를 사용해야하는지 */}
baesangjune's avatar
baesangjune committed
40
                </div>
baesangjune's avatar
home    
baesangjune committed
41

baesangjune's avatar
0    
baesangjune committed
42
43
44
                <div>계산수학</div>


Jiwon Yoon's avatar
Jiwon Yoon committed
45
            </div>
baesangjune's avatar
baesangjune committed
46
        </>
baesangjune's avatar
home    
baesangjune committed
47

Jiwon Yoon's avatar
Jiwon Yoon committed
48
49
    )
}
baesangjune's avatar
baesangjune committed
50

baesangjune's avatar
baesangjune committed
51
export default Home;
Jiwon Yoon's avatar
Jiwon Yoon committed
52