From ec3d6f2a0ad82fa55749bec2646c0fa9964b7cff Mon Sep 17 00:00:00 2001 From: liviaalmeida Date: Thu, 21 Nov 2019 09:39:09 -0300 Subject: [PATCH 1/2] docs(components): using daterangepicker on sandbobx bugfix/daterangepicker --- sandbox/blipDaterangepicker.js | 11 +++++++++++ sandbox/index.html | 2 +- sandbox/main.js | 5 +++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 sandbox/blipDaterangepicker.js diff --git a/sandbox/blipDaterangepicker.js b/sandbox/blipDaterangepicker.js new file mode 100644 index 0000000..97104f4 --- /dev/null +++ b/sandbox/blipDaterangepicker.js @@ -0,0 +1,11 @@ +import { BlipDaterangepicker } from '../src/components/blipDaterangepicker' + +const daterangepicker = new BlipDaterangepicker({ + hasTime: true, + onSelection: ($period) => { + console.log('selected period', $period) + }, +}) + +const daterangepickerParent = document.getElementById('daterangepicker') +daterangepickerParent.appendChild(daterangepicker.render()) diff --git a/sandbox/index.html b/sandbox/index.html index b69cb2f..5c919fa 100644 --- a/sandbox/index.html +++ b/sandbox/index.html @@ -27,7 +27,7 @@

Datepicker

-
+

TOASTS

diff --git a/sandbox/main.js b/sandbox/main.js index 9d15f2a..f2034f6 100644 --- a/sandbox/main.js +++ b/sandbox/main.js @@ -1,8 +1,9 @@ import '../src/scss/main.scss' +import './blipCarousel' +import './blipDaterangepicker' +import './blipLoading' import './blipSelect' import './blipTag' import './blipTags' -import './blipLoading' import './blipTabs' // import './blipToasts' -import './blipCarousel' From d05c9bb15ff9c76533f5cb657d784e4018fdae0b Mon Sep 17 00:00:00 2001 From: liviaalmeida Date: Thu, 21 Nov 2019 09:46:52 -0300 Subject: [PATCH 2/2] fix(components): fixed some bugs on blip-daterangepicker Moved native months and weekdays strings to shared folder Fixed bug on select or cancel date on daterangepicker bugfix/daterangepicker --- src/components/blipDatepicker/index.js | 15 +++++++-------- src/components/blipDaterangepicker/index.js | 12 +++++++----- src/components/shared/DateHelper.js | 5 +++++ src/scss/components/_daterangepicker.scss | 1 - 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/components/blipDatepicker/index.js b/src/components/blipDatepicker/index.js index 77d5c48..cd8ffec 100644 --- a/src/components/blipDatepicker/index.js +++ b/src/components/blipDatepicker/index.js @@ -13,13 +13,8 @@ export class BlipDatepicker extends Component { static monthRows = 6 static selectorRows = 4 static selectorColumns = 3 - static i18nEN = { - months: ['January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December'], - weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', - 'Thursday', 'Friday', 'Saturday'], - timeInputText: 'Time', - } + static timeInputText = 'Time' + static style = { datepicker: 'bp-datepicker', monthTable: 'month-table', @@ -55,7 +50,11 @@ export class BlipDatepicker extends Component { this.name = options.name this.hasTime = options.hasTime || false - this.i18n = options.i18n || BlipDatepicker.i18nEN + this.i18n = options.i18n || { + months: DateHelper.months, + weekdays: DateHelper.weekdays, + timeInputText: BlipDatepicker.timeInputText, + } this._selectedPeriod = options.selectedPeriod this._validPeriod = options.validPeriod diff --git a/src/components/blipDaterangepicker/index.js b/src/components/blipDaterangepicker/index.js index d25370d..76d1ecc 100644 --- a/src/components/blipDaterangepicker/index.js +++ b/src/components/blipDaterangepicker/index.js @@ -26,8 +26,8 @@ export class BlipDaterangepicker extends Component { this.hasTime = options.hasTime || false - this.months = options.months - this.weekdays = options.weekdays + this.months = options.months || DateHelper.months + this.weekdays = options.weekdays || DateHelper.weekdays this.cancelText = options.cancelText || 'Cancel' this.applyText = options.applyText || 'Apply' @@ -216,7 +216,7 @@ export class BlipDaterangepicker extends Component { this._setDateOnInput(endDate, this.endDateInput) if (this.onSelection) { - this.onSelection(period) + this.onSelection(this.selectedPeriod) } } @@ -224,8 +224,10 @@ export class BlipDaterangepicker extends Component { } _cancelDate = () => { - this._leftPicker.selectedPeriod = this.selectedPeriod - this._rightPicker.selectedPeriod = this.selectedPeriod + if (this.selectedPeriod) { + this._leftPicker.selectedPeriod = this.selectedPeriod + this._rightPicker.selectedPeriod = this.selectedPeriod + } this._pickerNotActive() } diff --git a/src/components/shared/DateHelper.js b/src/components/shared/DateHelper.js index 74d37b8..9f99589 100644 --- a/src/components/shared/DateHelper.js +++ b/src/components/shared/DateHelper.js @@ -1,4 +1,9 @@ export class DateHelper { + static months = ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'] + static weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', + 'Thursday', 'Friday', 'Saturday'] + static thisMonth(sourceDate) { return new Date( sourceDate.getFullYear(), diff --git a/src/scss/components/_daterangepicker.scss b/src/scss/components/_daterangepicker.scss index 83dc3ae..c7e98cd 100644 --- a/src/scss/components/_daterangepicker.scss +++ b/src/scss/components/_daterangepicker.scss @@ -43,7 +43,6 @@ .bp-daterange-dropdown { position: absolute; - right: 0; margin-top: 0.2*$m; background-color: $bp-color-white; border-radius: 8px;