Skip to content

Commit 0ba8833

Browse files
Add overlay and cancel button
1 parent 33f5595 commit 0ba8833

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

dist/vue-rangedate-picker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-rangedate-picker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RangedatePicker.vue

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="calendar" :class="{'calendar-mobile ': isCompact, 'calendar-right-to-left': isRighttoLeft}" v-if="isOpen">
55
<div class="calendar-head" v-if="!isCompact">
66
<h2>{{captions.title}}</h2>
7-
<i class="close" @click="toggleCalendar()">&times</i>
7+
<i :class="{'cancel-button-hidden': !isCancelButtonHidden}" class="close" @click="toggleCalendar()">&times</i>
88
</div>
99
<div class="calendar-wrap">
1010
<div class="calendar_month_left" :class="{'calendar-left-mobile': isCompact}" v-if="showMonth">
@@ -49,11 +49,15 @@
4949
:class="{'active-preset': presetActive === item.label}">
5050
{{item.label}}
5151
</li>
52-
<li><button class="calendar-btn-apply" @click="setDateValue()">{{captions.ok_button}}</button></li>
5352
</ul>
53+
<div class="calendar-range-button-container">
54+
<button class="calendar-btn-cancel" @click="toggleCalendar()">{{captions.cancel_button}}</button>
55+
<button :class="{'cancel-button-hidden': isCancelButtonHidden}" class="calendar-btn-apply" @click="setDateValue()">{{captions.ok_button}}</button>
56+
</div>
5457
</div>
55-
58+
5659
</div>
60+
<div class='overlay' @click="toggleCalendar()"></div>
5761
</div>
5862
</template>
5963

@@ -249,12 +253,36 @@ li.calendar_days_in-range {
249253
margin: -20px 0;
250254
}
251255
252-
.calendar-btn-apply {
253-
width: 100%;
254-
background: #f7931e;
256+
.calendar-range-button-container {
257+
position: absolute;
258+
bottom: 0;
259+
padding: 20px 0px;
260+
}
261+
262+
.calendar-range-button-container button {
255263
color: #fff;
256264
border: none;
257265
padding: 5px;
258266
font-size: 14px;
259267
}
268+
269+
.calendar-btn-apply {
270+
background: #f7931e;
271+
}
272+
273+
.calendar-btn-cancel {
274+
background: #cccccc;
275+
}
276+
277+
.cancel-button-hidden {
278+
display: none;
279+
}
280+
281+
.overlay {
282+
bottom: 0;
283+
left: 0;
284+
position: fixed;
285+
right: 0;
286+
top: 0;
287+
}
260288
</style>

src/js/rangedate-picker.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const presetRangeLabel = {
3333

3434
const defaultCaptions = {
3535
'title': 'Choose Dates',
36-
'ok_button': 'Apply'
36+
'ok_button': 'Apply',
37+
'cancel_button': 'Cancel'
3738
}
3839

3940
const defaultStyle = {
@@ -176,6 +177,10 @@ export default {
176177
righttoleft: {
177178
type: String,
178179
default: 'false'
180+
},
181+
cancelButtonHidden: {
182+
type: String,
183+
default: 'true'
179184
}
180185
},
181186
data () {
@@ -251,6 +256,9 @@ export default {
251256
},
252257
isRighttoLeft: function () {
253258
return this.righttoleft === 'true'
259+
},
260+
isCancelButtonHidden: function () {
261+
return this.cancelButtonHidden === 'true'
254262
}
255263
},
256264
methods: {
@@ -282,6 +290,7 @@ export default {
282290
getNewDateRange (result, activeMonth, activeYear) {
283291
const newData = {}
284292
let key = 'start'
293+
debugger
285294
if (!this.isFirstChoice) {
286295
key = 'end'
287296
} else {

0 commit comments

Comments
 (0)