Skip to content

Commit

Permalink
Update calendar height
Browse files Browse the repository at this point in the history
  • Loading branch information
novanai committed Sep 12, 2024
1 parent 6ddd25b commit 661c197
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

.fc-event {
box-shadow: none !important;
overflow: hidden;
}

.fc-event:hover {
Expand Down
24 changes: 22 additions & 2 deletions frontend/src/routes/timetable/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
function initCalendar() {
calendar = new Calendar(calendarEl, {
plugins: [timeGridPlugin, listPlugin, momentTimezonePlugin],
initialView:
window.innerWidth > 768 ? "timeGridWeek" : "timeGridDay",
initialView: getDefaultView(),
headerToolbar: {
left: "prev,next today",
center: "title",
Expand All @@ -60,6 +59,10 @@
nowIndicator: true,
slotDuration: "01:00:00",
expandRows: true,
height: calcHeight(getDefaultView()),
windowResize: function (info) {
calendar.setOption("height", calcHeight(info.view.type));
},
eventContent: function (info) {
return { html: info.event.title };
},
Expand All @@ -79,6 +82,23 @@
};
});
function getDefaultView() {
return window.innerWidth > 768 ? "timeGridWeek" : "timeGridDay";
}
function calcHeight(viewType) {
if (viewType == "timeGridDay") {
return 1050;
}
let height = 2850 - (225 * window.innerWidth) / 128;
if (height > 1500) {
height = 1500;
} else if (height < 1050) {
height = 1050;
}
return height;
}
async function fetchEvents(info = null) {
let events_data;
if (
Expand Down

0 comments on commit 661c197

Please sign in to comment.