forked from ClickerMonkey/dayspan-vuetify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeeksView.vue
124 lines (97 loc) · 1.83 KB
/
WeeksView.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<div class="ds-month">
<div class="ds-week-header">
<div class="ds-week-header-day"
v-for="(weekday, i) in weekdays"
:key="weekday"
:class="weekdayClasses(i)">
{{ weekday }}
</div>
</div>
<ds-day-row
v-for="i in rows"
v-bind="{$scopedSlots}"
v-on="$listeners"
:key="i"
:days="daysAtRow( i, 7 )"
:calendar="calendar"
:placeholder="placeholder"
:placeholder-for-create="placeholderForCreate"
></ds-day-row>
</div>
</template>
<script>
import { Calendar, CalendarEvent } from 'dayspan';
export default {
name: 'dsWeeksView',
props:
{
calendar:
{
required: true,
type: Calendar
},
placeholder:
{
type: CalendarEvent
},
placeholderForCreate:
{
type: Boolean,
default: false
},
weekdays:
{
type: Array,
default() {
return this.$dsDefaults().weekdays;
}
}
},
computed:
{
rows()
{
return Math.floor( this.calendar.days.length / 7 );
}
},
methods:
{
daysAtRow(row, rowSize)
{
var start = (row - 1) * rowSize;
return this.calendar.days.slice( start, start + rowSize );
},
weekdayClasses(weekday)
{
return {
'ds-week-header-today': this.$dayspan.today.dayOfWeek === weekday
};
}
}
}
</script>
<style scoped lang="scss">
.ds-month {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
background-color: white;
.ds-week-header {
display: flex;
user-select: none;
}
.ds-week-header-day {
flex: 1 0 20px;
border-right: #e0e0e0 1px solid;
color: #757575;
padding: 4px;
padding-bottom: 0px;
&.ds-week-header-today {
color: #4285f4;
font-weight: 500;
}
}
}
</style>