Skip to content

Commit 8af7cd9

Browse files
committed
Simplify the markup and CSS/SCSS so I don't need to use the external calendar component at all
1 parent a4716e6 commit 8af7cd9

File tree

4 files changed

+64
-19
lines changed

4 files changed

+64
-19
lines changed

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"lodash.uniq": "^4.5.0",
1919
"moment": "^2.22.2",
2020
"popper.js": "^1.12.9",
21-
"vue": "^2.5.3",
22-
"vue2-slot-calendar": "^2.1.4"
21+
"vue": "^2.5.3"
2322
},
2423
"devDependencies": {
2524
"babel-core": "^6.26.0",

src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ import _uniq from 'lodash.uniq';
143143
import isWeekend from 'date-fns/is_weekend';
144144
import moment from 'moment';
145145
146-
import 'vue2-slot-calendar/lib/calendar.min.css';
147146
import calendar from './calendar/index.vue';
148147
149148
export default {

src/calendar/index.vue

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
22
<div>
3-
<div class="datepicker-inner" v-for="month, i in text.months">
4-
<div class="datepicker-body">
3+
<div class="month-container" v-for="month, i in text.months">
4+
<div class="month-body">
55
<p>{{month}}</p>
6-
<div class="datepicker-weekRange">
6+
<div class="dayOfWeekLabels">
77
<span v-for="w in text.daysOfWeek">{{w}}</span>
88
</div>
9-
<div class="datepicker-dateRange">
9+
<div>
1010
<span v-for="d in dateRange[i]" class="day-cell" :class="getItemClasses(d)" @click="daySelect(d, $event)">
1111
<div>
1212
{{d.text}}
@@ -54,14 +54,23 @@ export default {
5454
methods: {
5555
getItemClasses (d) {
5656
const dateStr = d.date.toJSON().substring(0,10);
57-
let classes = [];
57+
let classes = ['datepicker-item'];
5858
if (!d.isCurrentMonth) {
59-
classes.push('datepicker-item-gray');
59+
classes.push('gray');
60+
} else if (this.selectedDays[dateStr]) {
61+
classes.push('active');
6062
}
61-
// debugger;
62-
// TODO: set 'datepicker-dateRange-item-active' class on selected days
63-
else if (this.selectedDays[dateStr]) {
64-
classes.push('datepicker-dateRange-item-active');
63+
64+
if ('isWeekend') {
65+
classes.push('datepicker-weekend');
66+
}
67+
if ('isSelected') {
68+
// classes.push('datepicker-dateRange-item-active');
69+
}
70+
if ('isYomTov') {
71+
classes.push('datepicker-yomtov');
72+
} else if ('isChag') {
73+
classes.push('datepicker-holiday')
6574
}
6675
6776
return classes.join(' ');
@@ -140,4 +149,47 @@ export default {
140149
}
141150
}
142151
}
143-
</script>
152+
</script>
153+
<style lang="scss" scoped>
154+
/*!
155+
* Based on vue2-calendar v2.1.4
156+
* (c) 2018 Terry <[email protected]>
157+
* https://github.com/icai/vue2-calendar#readme
158+
*/
159+
.month-container {
160+
width: 218px;
161+
float: left;
162+
}
163+
.month-body {
164+
padding: 10px 10px;
165+
text-align: center;
166+
167+
span {
168+
display: inline-block;
169+
width: 28px;
170+
line-height: 28px;
171+
height: 28px;
172+
text-align: center;
173+
174+
.dayOfWeekLabels & {
175+
font-weight: bold;
176+
}
177+
&.day-cell {
178+
cursor: pointer;
179+
180+
&:hover {
181+
background-color: #eeeeee;
182+
}
183+
184+
&.gray {
185+
color: #999;
186+
}
187+
&.active:hover,
188+
&.active {
189+
background: #3276b1;
190+
color: white;
191+
}
192+
}
193+
}
194+
}
195+
</style>

0 commit comments

Comments
 (0)