Skip to content

Commit 0931306

Browse files
author
Nathan Reyes
committed
Merge branch 'dev'
2 parents 4e9dbf3 + ca5e896 commit 0931306

25 files changed

+1089
-692
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = {
4343
'import/no-duplicates': 'off',
4444
'import/no-webpack-loader-syntax': 'off',
4545
'import/first': 'off',
46+
'import/prefer-default-export': 'off',
4647
'no-console': 'off',
4748
}
4849
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
dist/
44
lib/
5+
working/
56
npm-debug.log*
67
yarn-debug.log*
78
yarn-error.log*

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.4.0
2+
* Fix weekday labels not always having same exact width
3+
* Add support for complex attribute dates. Closes #7 and #12.
4+
* Add support for attribute `excludeDates`, date picker `availableDates`. Closes #19.
5+
* Add support for endless date ranges using null for start/end dates. Closes #20.
6+
* Add support for attaching custom data to attributes via `customData` property. Closes #21.
7+
8+
## 0.3.3
9+
* Fix duplicate input event for inline date picker
10+
111
## 0.3.2
212
* Fix styling bug introduced by v0.3.1.
313

README.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,158 @@ Visit https://vcalendar.netlify.com for demos and API reference. This plug-in is
2222
* Handles taps for date selection
2323
* Handles swipes for month navigation
2424

25+
# Usage
26+
27+
## Calendar
28+
29+
All attributes for a calendar are supplied within an array.
30+
31+
A single attribute may consist of one of each of the following objects: higlights, dots, bars, content style, content hover style. Supply the attributes as an array for the `v-calendar` component.
32+
33+
Here is an example of a simple highlight with a content style.
34+
35+
```html
36+
<v-calendar :attributes='attrs'>
37+
</v-calendar>
38+
```
39+
40+
```javascript
41+
export const {
42+
data() {
43+
return {
44+
attrs: [
45+
{
46+
highlight: {
47+
backgroundColor: 'red',
48+
borderRadius: '5px' // Only applied on highlighted end caps
49+
},
50+
contentStyle: {
51+
color: 'white' // Contrasts well with the red background
52+
},
53+
dates: [
54+
new Date(), // Use dates
55+
{ // ...or date ranges
56+
start: new Date('1/21/83'), // ...that start on my birthday :)
57+
end: new Date()
58+
}
59+
]
60+
customData: myData // Custom data to reference later
61+
}
62+
]
63+
}
64+
}
65+
};
66+
```
67+
68+
The `dates` array specifies dates for which all components of the attribute appear. As you can see, both date objects and date range objects are allowed, where the latter requires start and end dates when needed. For date ranges, null values are allowed for infinite start and end dates, in which case those properties can be ommitted entirely.
69+
70+
### Date Patterns
71+
72+
One really neat feature is that you can target specific dates from within a parent range. This allows for creating complex date patterns that would be difficult to achieve otherwise.
73+
74+
For a simple example, let's say we want to display an attribute on the weekends. To do that, we configure the date like this:
75+
76+
```javascript
77+
...
78+
attrs: [
79+
{
80+
highlight: {...},
81+
contentStyle: {...},
82+
dates: [
83+
{
84+
start: null, // From the beginning of time...
85+
end: null, // ...to the end of time...
86+
weekdays: [1, 7] // ...on Sundays and Saturdays
87+
}
88+
]
89+
}
90+
]
91+
...
92+
```
93+
94+
We can also target other specific day properties, like `days: [6, 15]` for the 6th and 15th of the month, `weeks: [-1]` for the last week of the month and even `ordinalWeekdays: { -1: [1] }` for the last Sunday of the month.
95+
96+
If supplying only a single numerical argument, like `weeks: [-1]`, we can nix the array and simplify to `weeks: -1`.
97+
98+
Additionally, if the date is applied over an infinite time scale (`start` and `end` dates are `null`) like the example before, we can remove `start` and `end` completely. And since our date object is the only one in the array, we can nix the array again like before.
99+
100+
```javascript
101+
...
102+
attrs: [
103+
{
104+
highlight: {...},
105+
contentStyle: {...},
106+
dates: { weekdays: [1, 7] } // Nice and tidy
107+
}
108+
],
109+
```
110+
111+
Let's consider another simple example of displaying dot indicators on the last Friday of every other month, starting on January 1st of 2018. We could do so like this.
112+
113+
```javascript
114+
...
115+
attrs: [
116+
{
117+
dot: { backgroundColor: 'red' },
118+
dates: {
119+
start: new Date('1/1/2018'),
120+
monthlyInterval: 2, // Every other month
121+
ordinalWeekdays: { [-1]: 6 } // ...on the last Friday
122+
}
123+
}
124+
]
125+
...
126+
```
127+
128+
Now, for some reason, we also want to display them on the 15th of every other month, so our first attempt might be to modify the dates to this:
129+
130+
```javascript
131+
...
132+
dates: {
133+
start: new Date('1/1/2018'),
134+
monthlyInterval: 2, // Every other month
135+
ordinalWeekdays: { [-1]: 6 }, // ...on the last Friday
136+
days: 15 // ...and on the 15th? (WRONG!)
137+
},
138+
...
139+
```
140+
141+
But this would be **wrong**, because all component specifiers are conditionally *anded* with each other.
142+
143+
To evaluate a set of conditions *or* another set, we can break the sets of conditions out into an array assigned to the `on` property.
144+
145+
```javascript
146+
...
147+
dates: {
148+
start: new Date('1/1/2018'),
149+
monthlyInterval: 2, // Every other month
150+
on: [ // ...on...
151+
{ ordinalWeekdays: { [-1]: 6 } }, // ...the last Friday
152+
{ days: 15 } // ...or the 15th of the month
153+
]
154+
}
155+
...
156+
```
157+
158+
Note how we kept the `monthlyInterval` condition outside of the others. Any conditions that should be **anded** with all the others can be extracted out of the array. This prevents unnecessary duplication of conditions within **or** subsets.
159+
160+
Here is a complete reference of date component specifiers available.
161+
162+
| Property | Type | Description | Range |
163+
| --- | --- | --- | --- |
164+
| `days` | Number, Array | Day number from the start or end of the month. | 1 to 31, -1 to -31 |
165+
| `weekdays` | Number, Array | Day of the week. | 1: Sun to 7: Sat |
166+
| `ordinalWeekdays` | Object (key: Number / value: Number, Array) | Weekday ordinal position from the start or end of the month. | key: 1 to 6, -1 to -6 / value: 1: Sun to 7: Sat |
167+
| `weeks` | Number, Array | Week number from the start or end of the month. | 1 to 6, -1 to -6 |
168+
| `months` | Number, Array | Months of the year. | 1 to 12 |
169+
| `years` | Number, Array | Year numbers. | 4-digit integer |
170+
| `dailyInterval` | Number | Interval number of days from the start date (or today when no start date provided). | n > 0 |
171+
| `weeklyInterval` | Number | Interval number of weeks from the start date (or today). | n > 0 |
172+
| `monthlyInterval` | Number | Interval number of months from the start date (or today). | n > 0 |
173+
| `yearlyInterval` | Number | Interval number of years from the start date (or today). | n > 0 |
174+
175+
176+
25177
## Quick Start
26178

27179
[Vue.js](https://vuejs.org) version 2.4+ is required.

_todos.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
- Add day-height back as a prop
2-
- Code copy button does not work
1+
- Add ordinalWeekday and ordinalWeekdayFromEnd props to dayInfo
32

43
CALENDAR
54

@@ -20,3 +19,9 @@ Day cell overflow problem:
2019
For c-day classes, there is catch with setting overflow: hidden.
2120
If it is set, then sometimes a blank line can appear between day cell highlights.
2221
If it is not set, then transparent backgrounds can interfere with each other during animations.
22+
23+
THOUGHTS:
24+
25+
An attribute date specified as a range may also specify a filter function that slices up that range.
26+
If a filter function is specified, then a new scanEnd date will need to be calculated using a maxLength
27+
parameter on the date in order to know when to stop testing for a date match on that attribute.

docs/components/home/examples/ExDatePicker.vue

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,25 @@
2121
</template>
2222

2323
<script>
24-
import { getExampleMonthComps } from '@/utils/helpers';
25-
26-
const { thisMonth, thisMonthYear, nextMonth, nextMonthYear } = getExampleMonthComps();
27-
2824
export default {
2925
props: {
30-
mode: { type: String, default: 'range' },
26+
mode: { type: String, default: 'single' },
3127
selectColor: { type: String, default: '#66b3cc' },
3228
dragColor: { type: String, default: '#9fcfdf' },
3329
showDisabledDates: Boolean,
3430
isInline: Boolean,
3531
isExpanded: Boolean,
3632
popoverExpanded: Boolean,
37-
popoverVisibility: { type: String, default: 'hover' },
33+
popoverVisibility: { type: String, default: 'visible' },
3834
popoverDirection: { type: String, default: 'bottom' },
3935
popoverAlign: { type: String, default: 'left' },
4036
},
4137
data() {
4238
return {
4339
fromPage: null,
4440
toPage: null,
45-
selectedValue: {
46-
start: new Date(thisMonthYear, thisMonth, 6),
47-
end: new Date(nextMonthYear, nextMonth, 25),
48-
},
49-
disabledDates: [
50-
{
51-
start: new Date(nextMonthYear, nextMonth, 26),
52-
end: new Date(nextMonthYear, nextMonth, 28),
53-
},
54-
],
41+
selectedValue: new Date(),
42+
disabledDates: { weekdays: [1, 7] },
5543
todayAttribute: {
5644
contentStyle: {
5745
color: '#ffffff',

docs/components/home/examples/ExHighlights.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ export default {
2828
color: 'white',
2929
},
3030
dates: [
31-
// Use date ranges
31+
// Use single dates
32+
new Date(nextMonthYear, nextMonth, 6),
33+
new Date(nextMonthYear, nextMonth, 23),
34+
// ...or date ranges
3235
{
3336
start: new Date(thisMonthYear, thisMonth, 1),
3437
end: new Date(thisMonthYear, thisMonth, 4),
3538
},
36-
// Or single dates
37-
new Date(nextMonthYear, nextMonth, 6),
38-
new Date(nextMonthYear, nextMonth, 23),
39+
// ...or complex date patterns
40+
{
41+
start: new Date(thisMonthYear, thisMonth, 1),
42+
ordinalWeekdays: { [-1]: 7 }, // Last Saturday of the month
43+
},
3944
],
4045
},
4146
{

docs/components/home/sections/SectionDatePicker.vue

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@
2222
</b-tab-item>
2323
<!--DatePicker Example Options-->
2424
<b-tab-item label='Options' icon='gear'>
25-
<b-field grouped>
26-
<b-field>
27-
<b-switch v-model='showDisabledDates'>Show disabled dates</b-switch>
28-
</b-field>
29-
<b-field>
30-
<b-switch v-model='isInline'>Inline</b-switch>
31-
</b-field>
32-
<b-field v-if='isInline'>
33-
<b-switch v-model='isExpanded'>Expanded</b-switch>
34-
</b-field>
35-
<b-field v-else>
36-
<b-switch v-model='popoverExpanded'>Popover Expanded</b-switch>
37-
</b-field>
38-
</b-field>
3925
<b-field label='Mode'>
4026
<p class='control-offset'>
4127
<b-radio v-model='mode' native-value='single'>Single</b-radio>
@@ -52,6 +38,21 @@
5238
</b-field>
5339
</b-field>
5440
<p class='tip'><strong>Note:</strong> Accepts color names, hex and rgb values</p>
41+
<br />
42+
<b-field grouped>
43+
<b-field>
44+
<b-switch v-model='showDisabledDates'>Show disabled dates</b-switch>
45+
</b-field>
46+
<b-field>
47+
<b-switch v-model='isInline'>Inline</b-switch>
48+
</b-field>
49+
<b-field v-if='isInline'>
50+
<b-switch v-model='isExpanded'>Expanded</b-switch>
51+
</b-field>
52+
<b-field v-else>
53+
<b-switch v-model='popoverExpanded'>Popover Expanded</b-switch>
54+
</b-field>
55+
</b-field>
5556
<div v-if='!isInline'>
5657
<b-field label='Popover Visibility'>
5758
<p class='control-offset'>
@@ -122,13 +123,13 @@ export default {
122123
data() {
123124
return {
124125
exDatePickerCode: ExDatePickerCode,
125-
mode: 'range',
126+
mode: 'single',
126127
selectedValue: null,
127128
showDisabledDates: false,
128129
isInline: false,
129130
isExpanded: false,
130-
popoverExpanded: false,
131-
popoverVisibility: 'hover',
131+
popoverExpanded: true,
132+
popoverVisibility: 'visible',
132133
popoverVisibilities: ['hover', 'focus', 'visible', 'hidden'],
133134
popoverDirection: 'bottom',
134135
popoverDirections: ['bottom', 'top', 'left', 'right'],

0 commit comments

Comments
 (0)