Home.js 1.69 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
    const [name, setName] = useState('')
    const [done, setDone] = useState(false)

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

baesangjune's avatar
baesangjune committed
14
    function checking() {
baesangjune's avatar
baesangjune committed
15
16
17
18
19
20
21
22
23
24
        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
        
baesangjune's avatar
baesangjune committed
28
29
            {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
30
                {/* <div className="Main"></div> */}
baesangjune's avatar
home    
baesangjune committed
31
32

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

baesangjune's avatar
0    
baesangjune committed
43

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

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

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