ScheduleItem.js
1.9 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import zoomSymbol from "../assets/zoom.png";
import ecampusSymbol from "../assets/e-Campus.png";
const ScheduleItem = ({ schedule }) => {
const {
name: subjectName,
nickname: subjectNickname,
uid: scheID,
color: subjectColor,
url,
type,
label,
description,
detail,
startTime = null, //HHMMSS문자열
endTime = null,
} = schedule;
const selectSymbol = () => {
let symbol;
switch (type) {
case "zoom":
symbol = zoomSymbol;
break;
case "assignment":
symbol = ecampusSymbol;
break;
default:
}
return symbol;
};
const click = (e) => {
let target;
if (e.target.className === "ScheduleItem") target = e.target;
else if (e.target.classList.contains("ss")) target = e.target.offsetParent;
else {
if (e.target.className === "spc")
e.target.offsetParent.style.display = "none";
return;
}
target.lastChild.style.display = "grid";
};
return (
<div
className="ScheduleItem"
style={{ borderColor: "#" + subjectColor }}
onClick={click}
>
<img className="s_symbol ss" src={selectSymbol()} alt="404" />
{startTime && (
<span className="s_start ss">{startTime.substring(0, 5)}</span>
)}
{endTime && <span className="s_end ss">{endTime.substring(0, 5)}</span>}
<span className="s_slabel ss">{label}</span>
<div className="s_popup">
<div className="spl">
<span>{subjectName}</span>
{url ? (
<a href={url} target="_blank">
{label}
</a>
) : (
<span>{label}</span>
)}
{description && <span>{description}</span>}
{detail && <div dangerouslySetInnerHTML={{ __html: detail }}></div>}
</div>
<button className="spc">닫기</button>
</div>
</div>
);
};
export default ScheduleItem;