Skip to content

Commit 01dc168

Browse files
committed
feat: added calendar
1 parent c65e5cd commit 01dc168

2 files changed

Lines changed: 53 additions & 8 deletions

File tree

components/ClassesCalendar.vue

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
11
<template>
22
<v-row justify="center" align="center">
3-
<v-col cols="12" sm="12" md="10" lg="8">
4-
<!-- <v-card class="py-4 d-flex justify-center"> -->
5-
<v-calendar interval-count="10" type="week"></v-calendar>
6-
<!-- </v-card> -->
3+
<v-col cols="12" sm="12" md="12" lg="8">
4+
<v-calendar
5+
ref="calendar"
6+
:now="today"
7+
:value="today"
8+
first-interval="7"
9+
interval-count="16"
10+
type="week"
11+
:events="events"
12+
></v-calendar>
13+
<!-- TODO: dynamic interval count -->
714
</v-col>
815
</v-row>
916
</template>
1017

11-
<script lang="ts"></script>
18+
<script>
19+
export default {
20+
props: { classes: { type: Array, default: () => [] } },
21+
data() {
22+
return { today: '2022-05-0' }
23+
},
24+
computed: {
25+
events() {
26+
let today = this.today
27+
let a = this.classes.map((c) => {
28+
return c.days.map((d) => {
29+
return {
30+
//MAGIC!
31+
name: c.name,
32+
start: time(today + (1 + d), c.time, 0),
33+
end: time(today + (1 + d), c.time, 1),
34+
}
35+
})
36+
})
37+
return a.flat(1)
38+
},
39+
},
40+
}
41+
//MAGIC!
42+
// range = "1030-1430", i=0> start, i=1> end
43+
function time(today, range, i) {
44+
return (
45+
today +
46+
' ' +
47+
range.slice(0 + 5 * i, 2 + 5 * i) +
48+
':' +
49+
range.slice(2 + 5 * i, 4 + 5 * i)
50+
)
51+
}
52+
</script>
53+
<style>
54+
.v-calendar-daily__scroll-area {
55+
overflow-y: auto;
56+
}
57+
</style>

pages/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div>
33
<pre>
4-
{{ selectedClasses.map((c) => ({ name: c.name, crn: c.crn })) }}
4+
<!-- {{ selectedClasses.map((c) => ({ name: c.name, crn: c.crn })) }} -->
55
<!-- {{ selectedClasses }} -->
66
</pre>
7-
<!-- <ClassesCalendar /> -->
7+
<ClassesCalendar :classes="selectedClasses" />
88
<!-- <ClassesSelectedStats /> -->
99
<ClassesFilters
1010
@major:change="majorChange($event)"
@@ -106,7 +106,6 @@ export default {
106106
},
107107
// If the button was pressed
108108
classButtonAction(e) {
109-
console.log(e)
110109
if (this.selectedClasses.find((c) => c.crn == e.crn)) {
111110
this.snackbarActive = !this.snackbarActive
112111
this.snackbarText = `Removing ${e.name}`

0 commit comments

Comments
 (0)