Skip to content

Commit b5c43ed

Browse files
committed
renamed timetable-barrier to timetable-content and replaced all instances of barrier in code with content for more clarity about the purpose of the timetable-content element
1 parent 4bfa490 commit b5c43ed

3 files changed

Lines changed: 58 additions & 58 deletions

File tree

client/src/components/time_indicator.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export function resizeAndPositionTimeIndicator() {
1919
?.getBoundingClientRect();
2020
if (separator_rect == undefined) return;
2121

22-
const barrier_rect = document
23-
.getElementById("timetable-barrier")
22+
const content_rect = document
23+
.getElementById("timetable-content")
2424
?.getBoundingClientRect();
25-
if (barrier_rect == undefined) return;
25+
if (content_rect == undefined) return;
2626

2727
const visible = getVisibleTimetableRect();
2828
if (visible == undefined) return;
@@ -35,8 +35,8 @@ export function resizeAndPositionTimeIndicator() {
3535
if (time_top == undefined) return;
3636

3737
time_indicator.style.left =
38-
visible.left - separator_rect.width - barrier_rect.left + "px";
39-
time_indicator.style.top = time_top - barrier_rect.top + "px";
38+
visible.left - separator_rect.width - content_rect.left + "px";
39+
time_indicator.style.top = time_top - content_rect.top + "px";
4040
time_indicator.style.width = visible.width + separator_rect.width + "px";
4141

4242
const now_label_rect = now_label.getBoundingClientRect();
@@ -46,8 +46,8 @@ export function resizeAndPositionTimeIndicator() {
4646
visible.left - now_label_rect.width - separator_rect.width;
4747
const now_label_top = time_top - now_label_rect.height / 2;
4848

49-
now_label.style.left = now_label_left - barrier_rect.left + "px";
50-
now_label.style.top = now_label_top - barrier_rect.top + "px";
49+
now_label.style.left = now_label_left - content_rect.left + "px";
50+
now_label.style.top = now_label_top - content_rect.top + "px";
5151
}
5252

5353
/*
@@ -61,13 +61,13 @@ function TimeIndicator() {
6161
<>
6262
<div
6363
id="time-indicator-label"
64-
className="absolute z-[75] h-fit w-fit rounded-full bg-slate-400 p-1 pl-2 pr-2"
64+
className="absolute z-[100] h-fit w-fit rounded-full bg-slate-400 p-1 pl-2 pr-2"
6565
>
6666
<p className="text-slate-100">Now</p>
6767
</div>
6868
<div
6969
id="time-indicator"
70-
className="absolute z-[75] min-h-[2px] bg-slate-200 opacity-75"
70+
className="absolute z-[100] min-h-[2px] bg-slate-200 opacity-75"
7171
></div>
7272
</>
7373
);

client/src/components/timetable.tsx

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TimetableTask, {
1414

1515
/*
1616
NOTES:
17-
- Should rename timetable-barrier to timetable-content to be more descriptive.
17+
- Should rename timetable-content to timetable-content to be more descriptive.
1818
- Should use element.parentElement for position adjusting for more clarity.
1919
*/
2020

@@ -23,13 +23,13 @@ Returns a rect {left, right, top, bottom, width, height} of the visible area of
2323
the timetable where timetable tasks are to be rendered.
2424
2525
Visible area is the area:
26-
- Within timetable-barrier's bounding client rect
26+
- Within timetable-content's bounding client rect
2727
- Right of timetable-separator (right of time labels)
2828
- Below time-header(s))
2929
3030
Returns nothing if any of the required elements are not found (that is, elements
31-
with id: time-header, timetable-barrier, timetable-separator, and
32-
timetable-barrier).
31+
with id: time-header, timetable-content, timetable-separator, and
32+
timetable-content).
3333
*/
3434
export function getVisibleTimetableRect() {
3535
const time_header = document.getElementById("Time-Header");
@@ -40,19 +40,19 @@ export function getVisibleTimetableRect() {
4040
if (time_labels == null) return;
4141
const time_labels_rect = time_labels.getBoundingClientRect();
4242

43-
const timetable_barrier = document.getElementById("timetable-barrier");
44-
if (timetable_barrier == null) return;
45-
const timetable_barrier_rect = timetable_barrier.getBoundingClientRect();
43+
const timetable_content = document.getElementById("timetable-content");
44+
if (timetable_content == null) return;
45+
const timetable_content_rect = timetable_content.getBoundingClientRect();
4646

4747
const timetable_separator = document.getElementById("timetable-separator");
4848
if (timetable_separator == null) return;
4949
const timetable_separator_rect = timetable_separator.getBoundingClientRect();
5050

5151
const rect = {
5252
left: time_labels_rect.right + timetable_separator_rect.width,
53-
right: timetable_barrier_rect.left + timetable_barrier.clientWidth,
53+
right: timetable_content_rect.left + timetable_content.clientWidth,
5454
top: time_header_rect.bottom,
55-
bottom: timetable_barrier_rect.top + timetable_barrier.clientHeight,
55+
bottom: timetable_content_rect.top + timetable_content.clientHeight,
5656
width: 0,
5757
height: 0,
5858
};
@@ -104,21 +104,21 @@ export function getDayLeftPosition(day: string) {
104104

105105
/*
106106
Sync the timetable-foreground element's position and size with the
107-
timetable-barrier element. Ensures foreground elements inhabit the same area
107+
timetable-content element. Ensures foreground elements inhabit the same area
108108
as the background elements.
109109
*/
110110
function resizeAndPositionTimetableForeground() {
111111
const foreground = document.getElementById("timetable-foreground");
112112
if (foreground == null) return;
113113

114-
const barrier = document.getElementById("timetable-barrier");
115-
if (barrier == null) return;
116-
const barrier_rect = barrier.getBoundingClientRect();
114+
const content = document.getElementById("timetable-content");
115+
if (content == null) return;
116+
const content_rect = content.getBoundingClientRect();
117117

118-
foreground.style.top = barrier_rect.top + "px";
119-
foreground.style.left = barrier_rect.left + "px";
120-
foreground.style.width = barrier.clientWidth + "px";
121-
foreground.style.height = barrier.clientHeight + "px";
118+
foreground.style.top = content_rect.top + "px";
119+
foreground.style.left = content_rect.left + "px";
120+
foreground.style.width = content.clientWidth + "px";
121+
foreground.style.height = content.clientHeight + "px";
122122
}
123123

124124
/*
@@ -130,9 +130,9 @@ function resizeAndPositionTimetableHeaders() {
130130
if (timetable_headers == null) return;
131131
const headers = timetable_headers.children;
132132

133-
const barrier = document.getElementById("timetable-barrier");
134-
if (barrier == null) return;
135-
const barrier_rect = barrier.getBoundingClientRect();
133+
const content = document.getElementById("timetable-content");
134+
if (content == null) return;
135+
const content_rect = content.getBoundingClientRect();
136136

137137
for (let i = 0; i < headers.length; i++) {
138138
const header_id = headers[i].id;
@@ -145,7 +145,7 @@ function resizeAndPositionTimetableHeaders() {
145145
const col_rect = col.getBoundingClientRect();
146146

147147
header.style.top = "0px";
148-
header.style.left = col_rect.left - barrier_rect.left + "px";
148+
header.style.left = col_rect.left - content_rect.left + "px";
149149
header.style.width = col_rect.width + "px";
150150
}
151151

@@ -167,11 +167,11 @@ function resizeAndPositionTimetableTimeLabels() {
167167
if (time_col == null) return;
168168
const time_col_rect = time_col.getBoundingClientRect();
169169

170-
const timetable_barrier = document.getElementById("timetable-barrier");
171-
if (timetable_barrier == null) return;
172-
const barrier_rect = timetable_barrier.getBoundingClientRect();
170+
const timetable_content = document.getElementById("timetable-content");
171+
if (timetable_content == null) return;
172+
const content_rect = timetable_content.getBoundingClientRect();
173173

174-
time_labels.style.top = time_col_rect.top - barrier_rect.top + "px";
174+
time_labels.style.top = time_col_rect.top - content_rect.top + "px";
175175
time_labels.style.left = "0px";
176176

177177
time_labels.style.width = time_col_rect.width + "px";
@@ -196,13 +196,13 @@ function resizeAndPositionTimetableSeparator() {
196196
if (time_header == null) return;
197197
const header_rect = time_header.getBoundingClientRect();
198198

199-
const barrier_rect = document
200-
.getElementById("timetable-barrier")
199+
const content_rect = document
200+
.getElementById("timetable-content")
201201
?.getBoundingClientRect();
202-
if (barrier_rect == undefined) return;
202+
if (content_rect == undefined) return;
203203

204-
separator.style.top = header_rect.top - barrier_rect.top + "px";
205-
separator.style.left = col_rect.right - barrier_rect.left + "px";
204+
separator.style.top = header_rect.top - content_rect.top + "px";
205+
separator.style.left = col_rect.right - content_rect.left + "px";
206206
separator.style.height = col_rect.height + "px";
207207
}
208208

@@ -215,16 +215,16 @@ function resizeAndPositionTimetableTaskArea() {
215215
const task_container = document.getElementById("timetable-tasks");
216216
if (task_container == null) return;
217217

218-
const barrier_rect = document
219-
.getElementById("timetable-barrier")
218+
const content_rect = document
219+
.getElementById("timetable-content")
220220
?.getBoundingClientRect();
221-
if (barrier_rect == undefined) return;
221+
if (content_rect == undefined) return;
222222

223223
const visible = getVisibleTimetableRect();
224224
if (visible == undefined) return;
225225

226-
task_container.style.top = visible.top - barrier_rect.top + "px";
227-
task_container.style.left = visible.left - barrier_rect.left + "px";
226+
task_container.style.top = visible.top - content_rect.top + "px";
227+
task_container.style.left = visible.left - content_rect.left + "px";
228228
task_container.style.width = visible.width + "px";
229229
task_container.style.height = visible.height + "px";
230230
}
@@ -244,7 +244,7 @@ export function resizeAndPositionTimetableElements() {
244244
}
245245

246246
/*
247-
Sets the vertical scroll of the timetable-barrier to make the current time
247+
Sets the vertical scroll of the timetable-content to make the current time
248248
visible.
249249
250250
@param align: An optional string argument indicating where the now position
@@ -253,9 +253,9 @@ sets the now position to the center of the visible area, can additionally be
253253
specified "top" or "bottom".
254254
*/
255255
export function scrollToCurrentTime(align?: string) {
256-
const timetable_barrier = document.getElementById("timetable-barrier");
257-
if (timetable_barrier == null) return;
258-
const barrier_rect = timetable_barrier.getBoundingClientRect();
256+
const timetable_content = document.getElementById("timetable-content");
257+
if (timetable_content == null) return;
258+
const content_rect = timetable_content.getBoundingClientRect();
259259

260260
const visible = getVisibleTimetableRect();
261261
if (visible == undefined) return;
@@ -270,14 +270,14 @@ export function scrollToCurrentTime(align?: string) {
270270
let target_top;
271271
if (align === "top") target_top = visible.top;
272272
else if (align === "bottom") target_top = visible.bottom;
273-
else target_top = barrier_rect.top + barrier_rect.height / 2;
273+
else target_top = content_rect.top + content_rect.height / 2;
274274

275275
const scroll_amount = now_top - target_top;
276-
timetable_barrier.scrollTop += scroll_amount;
276+
timetable_content.scrollTop += scroll_amount;
277277
}
278278

279279
/*
280-
Sets the horizontal scroll position of the timetable-barrier to display the
280+
Sets the horizontal scroll position of the timetable-content to display the
281281
column of the current day positioned in the center/left/right specified by
282282
align argument.
283283
@@ -287,8 +287,8 @@ of the visible timetable area. By default center, otherwise can be specified
287287
"left" or "right".
288288
*/
289289
export function scrollToCurrentDay(align?: string) {
290-
const timetable_barrier = document.getElementById("timetable-barrier");
291-
if (timetable_barrier == null) return;
290+
const timetable_content = document.getElementById("timetable-content");
291+
if (timetable_content == null) return;
292292

293293
const visible = getVisibleTimetableRect();
294294
if (visible == undefined) return;
@@ -322,11 +322,11 @@ export function scrollToCurrentDay(align?: string) {
322322
else target_left = visible.left + visible.width / 2 - row_width / 2;
323323

324324
const scroll_amount = today_left - target_left;
325-
timetable_barrier.scrollLeft += scroll_amount;
325+
timetable_content.scrollLeft += scroll_amount;
326326
}
327327

328328
/*
329-
Scrolls the vertical and horizonal scroll of timetable-barrier to position
329+
Scrolls the vertical and horizonal scroll of timetable-content to position
330330
the current time and current day within the visible area of the timetable.
331331
332332
Calls scrollToCurrentTime and scrollToCurrentDay.
@@ -369,7 +369,7 @@ function Timetable({ timetable_tasks_props }: TimetableProps) {
369369
className="h-full w-full rounded-lg bg-slate-900 p-3"
370370
>
371371
<div
372-
id="timetable-barrier"
372+
id="timetable-content"
373373
className="h-full w-full overflow-auto overscroll-none"
374374
onScroll={resizeAndPositionTimetableElements}
375375
>

client/src/pages/[id]/schedule.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ function Schedule() {
274274
to run in an infinite loop. */
275275

276276
return (
277-
<div className="content-container min-w-screen z-[50] flex h-[85vh] w-full flex-row bg-slate-950">
278-
<div className="timetable-container w-5/5 flex h-[85vh] flex-col items-center justify-center overflow-hidden p-3">
277+
<div className="content-container min-w-screen flex h-[85vh] w-full flex-row bg-slate-950">
278+
<div className="timetable-container h-[85vh] w-full p-3">
279279
<Timetable timetable_tasks_props={timetableTasksProps} />
280280
</div>
281281
</div>

0 commit comments

Comments
 (0)