HomePage.js 9.48 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
2
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
Kim, Subin's avatar
Home    
Kim, Subin committed
3
import styled from 'styled-components';
Kim, Subin's avatar
기간    
Kim, Subin committed
4
5
6
7
8
9
10
11
import moment from 'moment';
import "moment/locale/ko";

moment.locale("ko", {
    week: {
        dow: 1
    }
});
Kim, Subin's avatar
Home    
Kim, Subin committed
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

const Drop = styled.div`
    & button {
        border solid 1px;
    }
`

const Schedule = styled.div`
    & ul {
        list-style-type: none;
    }

    & .cd-schedule__events {
        width: 100%;

        > ul {
        display: flex;
        flex-wrap: nowrap;
        }
    }

    & .cd-schedule__group {
        flex-basis: 0;
        flex-grow: 1;
    }

    & .cd-schedule__event {
        position: absolute;
        z-index: 3;
        width: calc(100% + 2px); // top position and height will be set using js
        left: -1px;
    }
`
Kim, Subin's avatar
Kim, Subin committed
45
46

function Home() {
Kim, Subin's avatar
기간    
Kim, Subin committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    const [show, setShow] = useState(false);
    const [weeks, setWeeks] = useState([]);

    useEffect(() => {
        Dateform();
    }, []);

    function Dateform() {
        let today = moment();
        let dates = { start: null, end: null };
        for (let i = 0; i < 6; i++) {
            if (i !== 0) {
                today.add(7, 'd');
            }
            
            dates.start = today.startOf('week').format("MMM Do");
            dates.end = today.endOf('week').weekday(4).format("MMM Do");
            const week = dates.start + "  ~  " + dates.end;
            weeks.push(week);
        };
        setWeeks([...weeks])
    };
Kim, Subin's avatar
Home    
Kim, Subin committed
69

Kim, Subin's avatar
Kim, Subin committed
70
71
72
73
    return (
        <div>
            <Menu />
            <div className="container">
Kim, Subin's avatar
Kim, Subin committed
74
                <Drop className="row dropdown mt-5 mb-5">
Kim, Subin's avatar
Home    
Kim, Subin committed
75
                    <button className="btn btn-lg dropdown-toggle mx-auto col-5" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Kim, Subin's avatar
기간    
Kim, Subin committed
76
                        기간을 선택해주십시오.
Kim, Subin's avatar
Home    
Kim, Subin committed
77
78
                    </button>
                    <div className="dropdown-menu col-5" aria-labelledby="dropdownMenuButton">
Kim, Subin's avatar
기간    
Kim, Subin committed
79
80
81
                        {weeks.map((week, index) => (
                            <a className="dropdown-item" href="#" onClick={() => setShow(true)}>{week}</a>
                        ))}
Kim, Subin's avatar
Home    
Kim, Subin committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
                    </div>
                </Drop>
                <Schedule className="row cd-schedule cd-schedule--loading margin-top-lg margin-bottom-lg js-cd-schedule">
                    <div className="col-1 cd-schedule__timeline">
                        <ul>
                            <li><span>09:00</span></li>
                            <li><span>10:00</span></li>
                            <li><span>11:00</span></li>
                            <li><span>12:00</span></li>
                            <li><span>13:00</span></li>
                            <li><span>14:00</span></li>
                            <li><span>15:00</span></li>
                            <li><span>16:00</span></li>
                            <li><span>17:00</span></li>
                            <li><span>18:00</span></li>
                            <li><span>19:00</span></li>
                            <li><span>20:00</span></li>
                            <li><span>21:00</span></li>
                            <li><span>22:00</span></li>
                        </ul>
                    </div>
                    <div className="col-6 cd-schedule__events">
                        <ul>
                            <li className="cd-schedule__group">
                                <div className="cd-schedule__top-info"><span></span></div>
                                <ul>
                                    <li className="cd-schedule__event">
                                        <a data-start="10:00" data-end="12:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">확률론</em>
                                        </a>
                                    </li>
                                    <li className="cd-schedule__event">
                                        <a data-start="17:00" data-end="18:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">수치해석학</em>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <li className="cd-schedule__group">
                                <div className="cd-schedule__top-info"><span></span></div>
                                <ul>
                                    <li className="cd-schedule__event">
                                        <a data-start="11:00" data-end="12:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">해석학</em>
                                        </a>
                                    </li>
                                    <li className="cd-schedule__event">
                                        <a data-start="16:00" data-end="18:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">수치해석학</em>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <li className="cd-schedule__group">
                                <div className="cd-schedule__top-info"><span></span></div>
                                <ul>
                                    <li className="cd-schedule__event">
                                        <a data-start="9:00" data-end="10:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">산업수학</em>
                                        </a>
                                    </li>
                                    <li className="cd-schedule__event">
                                        <a data-start="18:00" data-end="19:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">해석학</em>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <li className="cd-schedule__group">
                                <div className="cd-schedule__top-info"><span></span></div>
                                <ul>
                                    <li className="cd-schedule__event">
                                        <a data-start="9:00" data-end="11:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">해석학</em>
                                        </a>
                                    </li>
                                    <li className="cd-schedule__event">
                                        <a data-start="11:00" data-end="12:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">확률론</em>
                                        </a>
                                    </li>
                                    <li className="cd-schedule__event">
                                        <a data-start="16:00" data-end="17:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">수치해석학</em>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                            <li className="cd-schedule__group">
                                <div className="cd-schedule__top-info"><span></span></div>
                                <ul>
                                    <li className="cd-schedule__event">
                                        <a data-start="13:00" data-end="15:00" data-content="event-abs-circuit" data-event="event-1" href="#0">
                                            <em className="cd-schedule__name">산업수학</em>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                    {/* <div class="cd-schedule-modal">
                        <header class="cd-schedule-modal__header">
                            <div class="cd-schedule-modal__content">
                                <span class="cd-schedule-modal__date"></span>
                                <h3 class="cd-schedule-modal__name"></h3>
                            </div>

                            <div class="cd-schedule-modal__header-bg"></div>
                        </header>

                        <div class="cd-schedule-modal__body">
                            <div class="cd-schedule-modal__event-info"></div>
                            <div class="cd-schedule-modal__body-bg"></div>
                        </div>

                        <a href="#0" class="cd-schedule-modal__close text-replace">Close</a>
                    </div> */}
                </Schedule>
Kim, Subin's avatar
Kim, Subin committed
200
201
202
203
204
205
            </div>
        </div>
    )
}

export default Home