Showing
6 changed files
with
93 additions
and
16 deletions
src/assets/zoom Symbol.png
deleted
100644 → 0
6.35 KB
src/assets/zoom.png
0 → 100644
6.58 KB
| 1 | import { useContext } from "react"; | 1 | import { useContext } from "react"; |
| 2 | import { CalendarStateContext } from "../pages/Calendar"; | 2 | import { CalendarStateContext } from "../pages/Calendar"; |
| 3 | import { toYMD } from "../utils/Dates"; | 3 | import { toYMD } from "../utils/Dates"; |
| 4 | +import ScheduleItem from "./ScheduleItem"; | ||
| 4 | 5 | ||
| 5 | const GridItem = ({ targetDate }) => { | 6 | const GridItem = ({ targetDate }) => { |
| 6 | const { state } = useContext(CalendarStateContext); | 7 | const { state } = useContext(CalendarStateContext); |
| 7 | const { month } = toYMD(state.date); | 8 | const { month } = toYMD(state.date); |
| 8 | const { month: tmonth, date: tdate } = toYMD(targetDate); | 9 | const { month: tmonth, date: tdate } = toYMD(targetDate); |
| 9 | 10 | ||
| 10 | - const displayDate = () => { | 11 | + const tempSchedules = [ |
| 11 | - if (month !== tmonth) return tmonth + "/" + tdate; | 12 | + { type: "zoom", category: "오픈소스", label: "", start: [9, 30] }, |
| 12 | - else return tdate; | 13 | + { type: "ecampus", category: "논리회로", label: "요약", end: [23, 59] }, |
| 14 | + ]; | ||
| 15 | + const renderScheduleItems = () => { | ||
| 16 | + if (targetDate.getDay() === 5) | ||
| 17 | + return ( | ||
| 18 | + <> | ||
| 19 | + <ScheduleItem schedule={tempSchedules[0]}></ScheduleItem> | ||
| 20 | + <ScheduleItem schedule={tempSchedules[1]}></ScheduleItem> | ||
| 21 | + </> | ||
| 22 | + ); | ||
| 13 | }; | 23 | }; |
| 24 | + | ||
| 14 | return ( | 25 | return ( |
| 15 | <div className="GridItem" relative={tmonth - month || null}> | 26 | <div className="GridItem" relative={tmonth - month || null}> |
| 16 | - <span>{displayDate()}</span> | 27 | + <span className="date"> |
| 28 | + {month !== tmonth ? tmonth + "/" + tdate : tdate} | ||
| 29 | + </span> | ||
| 30 | + {renderScheduleItems()} | ||
| 17 | </div> | 31 | </div> |
| 18 | ); | 32 | ); |
| 19 | }; | 33 | }; | ... | ... |
src/components/ScheduleItem.js
0 → 100644
| 1 | +import zoomSymbol from "../assets/zoom.png"; | ||
| 2 | +import ecampusSymbol from "../assets/e-Campus.png"; | ||
| 3 | + | ||
| 4 | +const ScheduleItem = ({ schedule }) => { | ||
| 5 | + const { type, category, label, start, end } = schedule; | ||
| 6 | + const selectSymbol = () => { | ||
| 7 | + let symbol; | ||
| 8 | + switch (type) { | ||
| 9 | + case "zoom": | ||
| 10 | + symbol = zoomSymbol; | ||
| 11 | + break; | ||
| 12 | + case "ecampus": | ||
| 13 | + symbol = ecampusSymbol; | ||
| 14 | + break; | ||
| 15 | + default: | ||
| 16 | + } | ||
| 17 | + return symbol; | ||
| 18 | + }; | ||
| 19 | + | ||
| 20 | + return ( | ||
| 21 | + <div className="ScheduleItem"> | ||
| 22 | + <img className="s_symbol" src={selectSymbol()} alt="404" /> | ||
| 23 | + {start && <span className="s_start">{start[0] + ":" + start[1]}</span>} | ||
| 24 | + {end && <span className="s_end">{end[0] + ":" + end[1]}</span>} | ||
| 25 | + <span className="s_category">{category}</span> | ||
| 26 | + <span className="s_slabel">{label}</span> | ||
| 27 | + </div> | ||
| 28 | + ); | ||
| 29 | +}; | ||
| 30 | + | ||
| 31 | +export default ScheduleItem; |
| ... | @@ -7,18 +7,6 @@ h2 { | ... | @@ -7,18 +7,6 @@ h2 { |
| 7 | margin: 12px; | 7 | margin: 12px; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | -/* Calendar */ | ||
| 11 | - | ||
| 12 | -.Calendar { | ||
| 13 | - display: flex; | ||
| 14 | - flex-direction: column; | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | -.content { | ||
| 18 | - flex: 1; | ||
| 19 | - display: flex; | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | button { | 10 | button { |
| 23 | cursor: pointer; | 11 | cursor: pointer; |
| 24 | background-color: white; | 12 | background-color: white; |
| ... | @@ -46,3 +34,47 @@ button:disabled { | ... | @@ -46,3 +34,47 @@ button:disabled { |
| 46 | cursor: auto; | 34 | cursor: auto; |
| 47 | color: rgb(209, 209, 209); | 35 | color: rgb(209, 209, 209); |
| 48 | } | 36 | } |
| 37 | + | ||
| 38 | +/* Calendar */ | ||
| 39 | + | ||
| 40 | +.Calendar { | ||
| 41 | + display: flex; | ||
| 42 | + flex-direction: column; | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +.content { | ||
| 46 | + flex: 1; | ||
| 47 | + display: flex; | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +.ScheduleItem { | ||
| 51 | + height: 23px; | ||
| 52 | + display: flex; | ||
| 53 | + margin: 1px 0 1px 0; | ||
| 54 | + border: solid 3px bisque; | ||
| 55 | + border-radius: 3px; | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +.ScheduleItem > span { | ||
| 59 | + line-height: 23px; | ||
| 60 | + vertical-align: middle; | ||
| 61 | + margin-right: 3px; | ||
| 62 | + font-size: small; | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +.s_start { | ||
| 66 | + color: deepskyblue; | ||
| 67 | + /* text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white; */ | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +.s_end { | ||
| 71 | + color: crimson; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +.s_symbol { | ||
| 75 | + width: 21px; | ||
| 76 | + height: 21px; | ||
| 77 | + margin: 1px 3px 1px 1px; | ||
| 78 | + border-radius: 3px; | ||
| 79 | + padding: 0; | ||
| 80 | +} | ... | ... |
-
Please register or login to post a comment