-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTimeTable.tsx
More file actions
204 lines (185 loc) · 7.32 KB
/
TimeTable.tsx
File metadata and controls
204 lines (185 loc) · 7.32 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
79
80
81
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
200
201
202
203
204
"use client";
import React from "react";
import { slot } from "@/lib/type";
import { getSlot, getAllSlots } from "@/lib/slots";
import Image from "next/image";
export type tableFacingSlot = {
slotName: string;
showName: boolean;
};
export default function TimeTable({
slotNames,
}: {
slotNames: tableFacingSlot[];
}) {
const slots: slot[] = slotNames
.map((slotNames) => getSlot(slotNames.slotName, slotNames.showName))
.flat();
const ROWS = 17;
const COLUMNS = 69;
const ROW_WEIGHTS = [5, 5, 2, 5, 5, 2, 5, 5, 2, 5, 5, 2, 5, 5, 2, 5, 5];
const COLUMN_WEIGHTS = Array(69)
.fill(1)
.map((v, i) => (i === 0 ? 5 : 1));
const LAB_ROWS = [5, 8, 11, 14, 17];
const totalRowWeight = ROW_WEIGHTS.reduce((a, b) => a + b, 0);
const gridTemplateRows = ROW_WEIGHTS.map(
(w) => `${(w / totalRowWeight) * 100}%`
).join(" ");
const totalColWeight = COLUMN_WEIGHTS.reduce((a, b) => a + b, 0);
const gridTemplateColumns = COLUMN_WEIGHTS.map(
(w) => `${(w / totalColWeight) * 100}%`
).join(" ");
const MERGE_CELLS_BOLD_TEXT: slot[] = [
{ colStart: 1, colEnd: 2, rowStart: 4, rowEnd: 6, slotName: "Mon" },
{ colStart: 1, colEnd: 2, rowStart: 7, rowEnd: 9, slotName: "Tue" },
{ colStart: 1, colEnd: 2, rowStart: 10, rowEnd: 12, slotName: "Wed" },
{ colStart: 1, colEnd: 2, rowStart: 13, rowEnd: 15, slotName: "Thu" },
{ colStart: 1, colEnd: 2, rowStart: 16, rowEnd: 18, slotName: "Fri" },
{ colStart: 2, colEnd: 3, rowStart: 1, rowEnd: 2, slotName: "8" },
{ colStart: 8, colEnd: 9, rowStart: 1, rowEnd: 2, slotName: "9" },
{ colStart: 14, colEnd: 15, rowStart: 1, rowEnd: 2, slotName: "10" },
{ colStart: 20, colEnd: 21, rowStart: 1, rowEnd: 2, slotName: "11" },
{ colStart: 26, colEnd: 27, rowStart: 1, rowEnd: 2, slotName: "12" },
{ colStart: 32, colEnd: 33, rowStart: 1, rowEnd: 2, slotName: "1" },
{ colStart: 38, colEnd: 39, rowStart: 1, rowEnd: 2, slotName: "2" },
{ colStart: 44, colEnd: 45, rowStart: 1, rowEnd: 2, slotName: "3" },
{ colStart: 50, colEnd: 51, rowStart: 1, rowEnd: 2, slotName: "4" },
{ colStart: 56, colEnd: 57, rowStart: 1, rowEnd: 2, slotName: "5" },
{ colStart: 62, colEnd: 63, rowStart: 1, rowEnd: 2, slotName: "6" },
{ colStart: 68, colEnd: 69, rowStart: 1, rowEnd: 2, slotName: "7" },
{
colStart: 2,
colEnd: 32,
rowStart: 2,
rowEnd: 3,
slotName: "Morning Theory",
},
{ colStart: 32, colEnd: 38, rowStart: 2, rowEnd: 3, slotName: "Break" },
{
colStart: 38,
colEnd: 70,
rowStart: 2,
rowEnd: 3,
slotName: "Evening Theory",
},
{ colStart: 2, colEnd: 70, rowStart: 3, rowEnd: 4, slotName: "" },
{ colStart: 2, colEnd: 70, rowStart: 6, rowEnd: 7, slotName: "" },
{ colStart: 2, colEnd: 70, rowStart: 9, rowEnd: 10, slotName: "" },
{ colStart: 2, colEnd: 70, rowStart: 12, rowEnd: 13, slotName: "" },
{ colStart: 2, colEnd: 70, rowStart: 15, rowEnd: 16, slotName: "" },
{ colStart: 31, colEnd: 38, rowStart: 4, rowEnd: 5, slotName: "" },
{ colStart: 31, colEnd: 38, rowStart: 7, rowEnd: 8, slotName: "" },
{ colStart: 19, colEnd: 38, rowStart: 10, rowEnd: 11, slotName: "" },
{ colStart: 31, colEnd: 38, rowStart: 13, rowEnd: 14, slotName: "" },
{ colStart: 31, colEnd: 38, rowStart: 16, rowEnd: 17, slotName: "" },
{ colStart: 34, colEnd: 38, rowStart: 5, rowEnd: 6, slotName: "" },
{ colStart: 34, colEnd: 38, rowStart: 8, rowEnd: 9, slotName: "" },
{ colStart: 34, colEnd: 38, rowStart: 11, rowEnd: 12, slotName: "" },
{ colStart: 34, colEnd: 38, rowStart: 14, rowEnd: 15, slotName: "" },
{ colStart: 34, colEnd: 38, rowStart: 17, rowEnd: 18, slotName: "" },
{ colStart: 67, colEnd: 70, rowStart: 4, rowEnd: 5, slotName: "" },
{ colStart: 67, colEnd: 70, rowStart: 7, rowEnd: 8, slotName: "" },
{ colStart: 67, colEnd: 70, rowStart: 10, rowEnd: 11, slotName: "" },
{ colStart: 67, colEnd: 70, rowStart: 13, rowEnd: 14, slotName: "" },
{ colStart: 67, colEnd: 70, rowStart: 16, rowEnd: 17, slotName: "" },
];
const MERGE_CELLS_SLOTS: slot[] = [];
const allSlotsWithoutName: slot[] = getAllSlots()
.map((slotName) => getSlot(slotName, true))
.flat();
MERGE_CELLS_SLOTS.push(
...allSlotsWithoutName.map((slot) => ({
colStart: slot.colStart,
colEnd: slot.colEnd,
rowStart: slot.rowStart,
rowEnd: slot.rowEnd,
slotName: slot.slotName,
}))
);
const cells = [];
for (let row = 1; row <= ROWS; row++) {
for (let col = 1; col <= COLUMNS; col++) {
cells.push(
<div
key={`cell-${row}-${col}`}
className="border-black border-[0.5px] w-full h-full box-border bg-white"
style={{ gridColumn: col, gridRow: row }}
/>
);
}
}
return (
<div
className="grid bg-black relative w-full h-full p-[1px] font-inter"
style={{ gridTemplateColumns, gridTemplateRows }}
>
{cells}
<div
key="image-cell"
className="col-[1] row-start-[1] row-end-[3] bg-white border-black border-[0.5px] box-border flex items-center justify-center"
>
<Image
src="/logo_ffcs.svg"
alt="logo of FFCS Platform by CodeChef-VIT"
width={120}
height={80}
className="w-auto h-2/3 block opacity-90 pointer-events-none"
draggable={false}
unselectable="on"
priority
/>
</div>
{MERGE_CELLS_BOLD_TEXT.map((cell, i) => (
<div
key={`merge-cell-${i}`}
className="bg-white border-black border-[0.5px] box-border flex items-center justify-center w-full h-full overflow-hidden"
style={{
gridColumnStart: cell.colStart,
gridColumnEnd: cell.colEnd,
gridRowStart: cell.rowStart,
gridRowEnd: cell.rowEnd,
}}
>
<span className="w-full h-full flex items-center justify-center font-bold whitespace-nowrap overflow-hidden text-ellipsis text-xs">
{cell.slotName}
</span>
</div>
))}
{MERGE_CELLS_SLOTS.map((cell, i) => (
<div
key={`slot-${i}`}
className="bg-white border-black border-[0.5px] box-border flex items-center justify-center w-full h-full overflow-hidden"
style={{
gridColumnStart: cell.colStart,
gridColumnEnd: cell.colEnd,
gridRowStart: cell.rowStart,
gridRowEnd: cell.rowEnd,
}}
>
<span className="w-full h-full flex items-center justify-center whitespace-nowrap overflow-hidden text-ellipsis text-xs">
{cell.slotName}
</span>
</div>
))}
{slots.map((slot, i) => (
<div
key={`slot-${i}`}
className={`border-black border-[0.5px] box-border flex items-center justify-center w-full h-full overflow-hidden ${
LAB_ROWS.includes(slot.rowStart) ? "bg-[#96FFCA]" : "bg-[#86d7FF]"
}`}
style={{
gridColumnStart: slot.colStart,
gridColumnEnd: slot.colEnd,
gridRowStart: slot.rowStart,
gridRowEnd: slot.rowEnd,
}}
>
<span className="w-full h-full flex items-center justify-center whitespace-nowrap overflow-hidden text-ellipsis text-xs">
{slot.slotName}
</span>
</div>
))}
</div>
);
}