Skip to content

Commit a99d557

Browse files
authored
Merge pull request #31 from mazipan/master
Add demo for custom format
2 parents d50e1fb + 2a3c712 commit a99d557

File tree

3 files changed

+69
-31
lines changed

3 files changed

+69
-31
lines changed

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,43 @@ You can pass these below props to `<rangedate-picker :props="props"></rangedate-
164164

165165
+ **presetRanges**
166166

167-
*Description* : -
167+
*Description* : Set of objects that will shown as quick selection of daterange
168168

169169
*Type* : Object
170170

171-
*Default Value* : `{}`
171+
Example Object :
172+
```javascript
173+
{
174+
today: function () {
175+
const n = new Date()
176+
const startToday = new Date(n.getFullYear(), n.getMonth(), n.getDate() + 1, 0, 0)
177+
const endToday = new Date(n.getFullYear(), n.getMonth(), n.getDate() + 1, 23, 59)
178+
return {
179+
label: presetRangeLabel[i18n].today,
180+
active: false,
181+
dateRange: {
182+
start: startToday,
183+
end: endToday
184+
}
185+
}
186+
}
187+
}
188+
```
189+
190+
*Default Value* :
191+
```javascript
192+
{
193+
today: function () {
194+
return {
195+
// label: 'string', active: 'boolean', dateRange: {start: date, end: end}
196+
}
197+
},
198+
thisMonth: function () {},
199+
lastMonth: function () {},
200+
last7days: function () {},
201+
last30days: function () {}
202+
}
203+
```
172204

173205
+ **compact**
174206

demo/index.html

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ <h2 class="subtitle">
5757

5858
<div class="column">
5959
<div class="card">
60-
<p class="title is-4">Range Date Compact Mode</p>
60+
<p class="title is-4">Range Date Normal Mode</p>
6161
<br>
62-
<p class="subtitle is-6">Start Date : {{ date1.start }}</p>
63-
<p class="subtitle is-6">End Date : {{ date1.end }}</p>
62+
<p class="subtitle is-6">Start Date : {{ selectedDate.start }}</p>
63+
<p class="subtitle is-6">End Date : {{ selectedDate.end }}</p>
6464

6565
<div class="card-content">
66-
<div class="compact-wrapper">
67-
<rangedate-picker @selected="date1Selected" compact="true" i18n="EN">
66+
<div class="daterange-wrapper">
67+
<rangedate-picker @selected="onDateSelected" i18n="EN">
6868
</rangedate-picker>
6969
</div>
7070
</div>
@@ -74,14 +74,14 @@ <h2 class="subtitle">
7474

7575
<div class="column">
7676
<div class="card">
77-
<p class="title is-4">Range Date Normal Mode</p>
77+
<p class="title is-4">Range Date Custom Format</p>
7878
<br>
79-
<p class="subtitle is-6">Start Date : {{ date2.start }}</p>
80-
<p class="subtitle is-6">End Date : {{ date2.end }}</p>
79+
<p class="subtitle is-6">Start Date : {{ selectedDate.start }}</p>
80+
<p class="subtitle is-6">End Date : {{ selectedDate.end }}</p>
8181

8282
<div class="card-content">
8383
<div class="daterange-wrapper">
84-
<rangedate-picker @selected="date2Selected" i18n="EN">
84+
<rangedate-picker @selected="onDateSelected" i18n="EN" format="YYYY-MM-DD hh:mm:ss">
8585
</rangedate-picker>
8686
</div>
8787
</div>
@@ -93,12 +93,32 @@ <h2 class="subtitle">
9393
<div class="card">
9494
<p class="title is-4">Range Date Right To Left</p>
9595
<br>
96-
<p class="subtitle is-6">Start Date : {{ date3.start }}</p>
97-
<p class="subtitle is-6">End Date : {{ date3.end }}</p>
96+
<p class="subtitle is-6">Start Date : {{ selectedDate.start }}</p>
97+
<p class="subtitle is-6">End Date : {{ selectedDate.end }}</p>
9898

9999
<div class="card-content">
100100
<div class="daterange-wrapper">
101-
<rangedate-picker @selected="date3Selected" i18n="EN" righttoleft="true">
101+
<rangedate-picker @selected="onDateSelected" i18n="EN" righttoleft="true">
102+
</rangedate-picker>
103+
</div>
104+
</div>
105+
106+
</div>
107+
</div>
108+
109+
</div>
110+
<div class="columns is-centered">
111+
112+
<div class="column">
113+
<div class="card">
114+
<p class="title is-4">Range Date Compact Mode</p>
115+
<br>
116+
<p class="subtitle is-6">Start Date : {{ selectedDate.start }}</p>
117+
<p class="subtitle is-6">End Date : {{ selectedDate.end }}</p>
118+
119+
<div class="card-content">
120+
<div class="compact-wrapper">
121+
<rangedate-picker @selected="onDateSelected" compact="true" i18n="EN">
102122
</rangedate-picker>
103123
</div>
104124
</div>

demo/src/main.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,15 @@ var app = new Vue({
22
el: '#app',
33
data () {
44
return {
5-
date1: {
6-
start: '',
7-
end: ''
8-
},
9-
date2: {
10-
start: '',
11-
end: ''
12-
},
13-
date3: {
5+
selectedDate: {
146
start: '',
157
end: ''
168
}
179
}
1810
},
1911
methods: {
20-
date1Selected: function (daterange) {
21-
this.date1 = daterange
22-
},
23-
date2Selected: function (daterange) {
24-
this.date2 = daterange
25-
},
26-
date3Selected: function (daterange) {
27-
this.date3 = daterange
12+
onDateSelected: function (daterange) {
13+
this.selectedDate = daterange
2814
}
2915
},
3016
components: {

0 commit comments

Comments
 (0)