LauraMDB commited on
Commit
2b39df6
·
verified ·
1 Parent(s): f08b1c1

for the course calendar use https://ui.toast.com/tui-calendar

Browse files
Files changed (3) hide show
  1. components/calendar.js +77 -0
  2. index.html +2 -26
  3. style.css +0 -26
components/calendar.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomCalendar extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ #calendar {
7
+ width: 100%;
8
+ height: 800px;
9
+ margin: 0 auto;
10
+ }
11
+ .tui-full-calendar-weekday-schedule {
12
+ cursor: pointer;
13
+ }
14
+ </style>
15
+ <div id="calendar"></div>
16
+ `;
17
+
18
+ // Load Toast UI Calendar CSS and JS
19
+ const link = document.createElement('link');
20
+ link.rel = 'stylesheet';
21
+ link.href = 'https://uicdn.toast.com/tui-calendar/latest/tui-calendar.min.css';
22
+ document.head.appendChild(link);
23
+
24
+ const script = document.createElement('script');
25
+ script.src = 'https://uicdn.toast.com/tui-calendar/latest/tui-calendar.min.js';
26
+ script.onload = () => this.initCalendar();
27
+ document.body.appendChild(script);
28
+ }
29
+
30
+ initCalendar() {
31
+ const Calendar = tui.Calendar;
32
+ const container = this.shadowRoot.getElementById('calendar');
33
+
34
+ this.calendar = new Calendar(container, {
35
+ defaultView: 'month',
36
+ taskView: false,
37
+ scheduleView: ['time'],
38
+ useCreationPopup: false,
39
+ useDetailPopup: true,
40
+ template: {
41
+ monthDayname: function(dayname) {
42
+ return '<span class="calendar-week-dayname-name">' + dayname.label + '</span>';
43
+ }
44
+ }
45
+ });
46
+
47
+ // Add courses as schedules
48
+ const schedules = window.coursesData.map(course => {
49
+ const [day, month, year] = course['Start Date'].split('-');
50
+ const monthNum = new Date(`${month} 1, 2000`).getMonth();
51
+ const start = new Date(2000 + parseInt(year), monthNum, parseInt(day), 9);
52
+ const end = new Date(2000 + parseInt(year), monthNum, parseInt(day), 17);
53
+
54
+ return {
55
+ id: String(Math.random()),
56
+ calendarId: '1',
57
+ title: course.Course,
58
+ category: 'time',
59
+ dueDateClass: '',
60
+ start: start,
61
+ end: end,
62
+ location: course.Location,
63
+ instructor: course.Instructor,
64
+ raw: {
65
+ time: course.Time
66
+ }
67
+ };
68
+ });
69
+
70
+ this.calendar.createSchedules(schedules);
71
+
72
+ // Set today as default date
73
+ this.calendar.setDate(new Date());
74
+ }
75
+ }
76
+
77
+ customElements.define('custom-calendar', CustomCalendar);
index.html CHANGED
@@ -11,6 +11,7 @@
11
  <script src="components/navbar.js"></script>
12
  <script src="components/footer.js"></script>
13
  <script src="components/course-card.js"></script>
 
14
  </head>
15
  <body class="bg-gray-50">
16
  <custom-navbar></custom-navbar>
@@ -186,32 +187,7 @@
186
  <!-- Calendar View Section -->
187
  <section class="mb-20">
188
  <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">Course Calendar</h2>
189
- <div class="flex justify-center mb-6">
190
- <div class="inline-flex rounded-md shadow-sm">
191
- <button id="prev-month" class="px-4 py-2 text-sm font-medium rounded-l-lg border border-gray-300 hover:bg-gray-50">
192
- <i data-feather="chevron-left"></i>
193
- </button>
194
- <div id="current-month-display" class="px-4 py-2 text-sm font-medium border-t border-b border-gray-300 bg-gray-100">
195
- November 2025
196
- </div>
197
- <button id="next-month" class="px-4 py-2 text-sm font-medium rounded-r-lg border border-gray-300 hover:bg-gray-50">
198
- <i data-feather="chevron-right"></i>
199
- </button>
200
- </div>
201
- </div>
202
-
203
- <div class="bg-white rounded-lg shadow overflow-hidden">
204
- <div class="grid grid-cols-7 gap-px bg-gray-200">
205
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Sun</div>
206
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Mon</div>
207
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Tue</div>
208
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Wed</div>
209
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Thu</div>
210
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Fri</div>
211
- <div class="bg-gray-100 p-2 text-center font-medium text-gray-700">Sat</div>
212
- </div>
213
- <div id="calendar-days" class="grid grid-cols-7 gap-px bg-gray-200"></div>
214
- </div>
215
 
216
  <!-- Upcoming Dates Section -->
217
  <div class="mt-8 bg-white rounded-lg shadow p-6">
 
11
  <script src="components/navbar.js"></script>
12
  <script src="components/footer.js"></script>
13
  <script src="components/course-card.js"></script>
14
+ <script src="components/calendar.js"></script>
15
  </head>
16
  <body class="bg-gray-50">
17
  <custom-navbar></custom-navbar>
 
187
  <!-- Calendar View Section -->
188
  <section class="mb-20">
189
  <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">Course Calendar</h2>
190
+ <custom-calendar></custom-calendar>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
  <!-- Upcoming Dates Section -->
193
  <div class="mt-8 bg-white rounded-lg shadow p-6">
style.css CHANGED
@@ -9,32 +9,6 @@ body {
9
  .course-path-card:hover {
10
  transform: translateY(-2px);
11
  }
12
- /* Calendar styling */
13
- #calendar-days > div {
14
- min-height: 6rem;
15
- position: relative;
16
- }
17
-
18
- #calendar-days > div:hover {
19
- background-color: #f8fafc;
20
- }
21
-
22
- .calendar-course {
23
- cursor: pointer;
24
- transition: all 0.2s;
25
- padding: 2px 4px;
26
- margin-bottom: 2px;
27
- border-radius: 3px;
28
- font-size: 0.75rem;
29
- white-space: nowrap;
30
- overflow: hidden;
31
- text-overflow: ellipsis;
32
- }
33
-
34
- .calendar-course:hover {
35
- background-color: #dbeafe;
36
- }
37
-
38
  /* Upcoming dates styling */
39
  #upcoming-dates-list {
40
  max-height: 500px;
 
9
  .course-path-card:hover {
10
  transform: translateY(-2px);
11
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /* Upcoming dates styling */
13
  #upcoming-dates-list {
14
  max-height: 500px;