Spaces:
Running
Running
make sure you add the pre-requisites from https://github.com/nhn/tui.calendar
Browse files- components/calendar.js +44 -15
- index.html +9 -1
components/calendar.js
CHANGED
|
@@ -11,25 +11,54 @@ class CustomCalendar extends HTMLElement {
|
|
| 11 |
.tui-full-calendar-weekday-schedule {
|
| 12 |
cursor: pointer;
|
| 13 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</style>
|
| 15 |
<div id="calendar"></div>
|
| 16 |
`;
|
| 17 |
|
| 18 |
-
//
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
const
|
|
|
|
| 33 |
|
| 34 |
this.calendar = new Calendar(container, {
|
| 35 |
defaultView: 'month',
|
|
|
|
| 11 |
.tui-full-calendar-weekday-schedule {
|
| 12 |
cursor: pointer;
|
| 13 |
}
|
| 14 |
+
/* Override default styles to match our theme */
|
| 15 |
+
.tui-full-calendar-month-dayname-item {
|
| 16 |
+
color: #4a5568;
|
| 17 |
+
font-weight: 600;
|
| 18 |
+
}
|
| 19 |
+
.tui-full-calendar-month-day-item {
|
| 20 |
+
color: #2d3748;
|
| 21 |
+
}
|
| 22 |
+
.tui-full-calendar-month-day-item.tui-full-calendar-other-month {
|
| 23 |
+
color: #a0aec0;
|
| 24 |
+
}
|
| 25 |
+
.tui-full-calendar-month-day-item.tui-full-calendar-day-saturday {
|
| 26 |
+
color: #4299e1;
|
| 27 |
+
}
|
| 28 |
+
.tui-full-calendar-month-day-item.tui-full-calendar-day-sunday {
|
| 29 |
+
color: #f56565;
|
| 30 |
+
}
|
| 31 |
+
.tui-full-calendar-month-day-item.tui-full-calendar-today .tui-full-calendar-month-day-item-date {
|
| 32 |
+
background-color: #48bb78;
|
| 33 |
+
color: white;
|
| 34 |
+
}
|
| 35 |
+
.tui-full-calendar-schedule {
|
| 36 |
+
background-color: #4299e1;
|
| 37 |
+
color: white;
|
| 38 |
+
border-radius: 4px;
|
| 39 |
+
font-size: 12px;
|
| 40 |
+
padding: 2px 4px;
|
| 41 |
+
}
|
| 42 |
</style>
|
| 43 |
<div id="calendar"></div>
|
| 44 |
`;
|
| 45 |
|
| 46 |
+
// Check if dependencies are already loaded
|
| 47 |
+
if (window.tui && window.tui.Calendar) {
|
| 48 |
+
this.initCalendar();
|
| 49 |
+
} else {
|
| 50 |
+
// Wait for dependencies to be loaded from index.html
|
| 51 |
+
const checkDependencies = setInterval(() => {
|
| 52 |
+
if (window.tui && window.tui.Calendar) {
|
| 53 |
+
clearInterval(checkDependencies);
|
| 54 |
+
this.initCalendar();
|
| 55 |
+
}
|
| 56 |
+
}, 100);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
initCalendar() {
|
| 60 |
+
const Calendar = window.tui.Calendar;
|
| 61 |
+
const container = this.shadowRoot.getElementById('calendar');
|
| 62 |
|
| 63 |
this.calendar = new Calendar(container, {
|
| 64 |
defaultView: 'month',
|
index.html
CHANGED
|
@@ -8,7 +8,15 @@
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
<script src="components/footer.js"></script>
|
| 13 |
<script src="components/course-card.js"></script>
|
| 14 |
<script src="components/calendar.js"></script>
|
|
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<!-- Toast UI Calendar dependencies -->
|
| 12 |
+
<link rel="stylesheet" href="https://uicdn.toast.com/tui.time-picker/latest/tui-time-picker.css">
|
| 13 |
+
<link rel="stylesheet" href="https://uicdn.toast.com/tui.date-picker/latest/tui-date-picker.css">
|
| 14 |
+
<link rel="stylesheet" href="https://uicdn.toast.com/tui-calendar/latest/tui-calendar.css">
|
| 15 |
+
<script src="https://uicdn.toast.com/tui.code-snippet/v1.5.2/tui-code-snippet.min.js"></script>
|
| 16 |
+
<script src="https://uicdn.toast.com/tui.time-picker/latest/tui-time-picker.min.js"></script>
|
| 17 |
+
<script src="https://uicdn.toast.com/tui.date-picker/latest/tui-date-picker.min.js"></script>
|
| 18 |
+
<script src="https://uicdn.toast.com/tui-calendar/latest/tui-calendar.js"></script>
|
| 19 |
+
<script src="components/navbar.js"></script>
|
| 20 |
<script src="components/footer.js"></script>
|
| 21 |
<script src="components/course-card.js"></script>
|
| 22 |
<script src="components/calendar.js"></script>
|