Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Independent Daterangepicker months #575

Merged
merged 22 commits into from
Feb 20, 2017

Conversation

leebyp
Copy link
Contributor

@leebyp leebyp commented Jan 30, 2017

Fixes #432

  • Fix existing tests

  • Add new tests

  • Update documentation

  • DateRangePicker months set to be contiguous through prop

  • Extracted date comparison logic into separate class for readability

@blueprint-bot
Copy link

turn on all tests

Preview: docs | landing | table
Coverage: core | datetime

@llorca
Copy link
Contributor

llorca commented Jan 31, 2017

Feels pretty good. Nice to show the bounds of > 2 months ranges on each calendar through the shortcuts 👍

Worth asking: should we disallow "go next" in left calendar / "go prev" in right calendar when the 2 months are contiguous?

@cmslewis
Copy link
Contributor

cmslewis commented Jan 31, 2017

@llorca I guess it depends how valuable the interaction of shuffling both months together might be; that's the capability that would go away if we hide the buttons when the months are contiguous. I don't have a good sense for that at this point.

EDIT: But there is definitely some awkwardness/non-clarity there at this point. I could easily see this confusing some users as is.

@llorca
Copy link
Contributor

llorca commented Jan 31, 2017

@thisisalessandro would love to get your design input

@sonovawolf
Copy link

sonovawolf commented Feb 1, 2017

A few notes:

  • Disabling the arrows might be equally confusing: the mental gap between noticing that the arrows are disabled and understanding that it's because the months are contingent is big. Having the months "move" together is at least practical
  • Maybe the first click should always be interpreted as a start date. Right now if you pick a date and then pick another one that precedes the former, the first one counted as an end date and the second one as a start date. I think the most common case for pick a date prior to the one you just selected is because you picked a wrong start date, not because you are thinking in reverse
  • Related to☝️ : when we print the dates we represent the first click as a start date
  • Not super convinced by the fact that disabled days don't have a gray background. Especially in cases like this:
    screen shot 2017-01-31 at 4 16 52 pm

@leebyp
Copy link
Contributor Author

leebyp commented Feb 1, 2017

re- @thisisalessandro 's points

  1. Yeah that was my worry too. I think this is intrinsically linked with the decision of whether you can move the left date ahead of the right one directly with the dropdown.
  2. This is related but should definitely not be in this PR - related to things @cmslewis is doing.
  3. ...
  4. With the increased flexibility in the component now, I'm actually down to just set showOutsideDays to false - then it should be obvious which are disabled.

@llorca
Copy link
Contributor

llorca commented Feb 1, 2017

I'm not opposed to having showOutsideDays to false by default if you feel strongly 👍

@cmslewis
Copy link
Contributor

cmslewis commented Feb 1, 2017

@llorca @leebyp @thisisalessandro - just touched on outside days in my first PR on the road to merging my DateRangeInput work. I kind of think we should just get rid of them. Reasoning here:
https://github.com/palantir/blueprint/pull/586/files#r98813760

@blueprint-bot
Copy link

add comments to explain logic behind updating displayed months

Preview: docs | landing | table
Coverage: core | datetime

@llorca
Copy link
Contributor

llorca commented Feb 10, 2017

This is cool, we want it. Can we have it as a simple prop/option on the date range picker?

* Create new class for DateRangePicker state internals
@blueprint-bot
Copy link

Create new class for DateRangePicker state internals (#619)

Preview: docs | landing | table
Coverage: core | datetime

@leebyp
Copy link
Contributor Author

leebyp commented Feb 13, 2017

@llorca the optional prop is implemented in #678

#678)

* Add tests

* set indepedent months feature through prop

* update docs

* update example in docs
@leebyp leebyp changed the title (WIP) Independent Daterangepicker months Independent Daterangepicker months Feb 15, 2017
@blueprint-bot
Copy link

Set independent months in DateRangePicker through props, and add tests (#678)

Preview: docs | landing | table
Coverage: core | datetime

Copy link
Contributor

@cmslewis cmslewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, I'm going with "Request changes" instead of "Comment" for the first time. Left some questions and corrections. LMK when you're ready for review, @leebyp.

@@ -55,11 +55,26 @@ Styleguide components.datetime.daterangepicker.js
.pt-daterangepicker {
white-space: nowrap;

&.pt-daterangepicker-sequential {
.DayPicker {
min-width: $pt-grid-size * 43;
Copy link
Contributor

@cmslewis cmslewis Feb 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

43 looks so arbitrary, haha. What's the width of each content column here? Can we make variables for (1) the width of each calendar and (2) the width of the shortcuts list, then add them in place here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted out the width for DayPicker since it's used to calculate the other widths. And made the css a bit more verbose to show what's going on. I haven't moved the shortcuts out, since it is arbitrary.


~ .DayPicker {
border-left: 1px solid $pt-divider-black;
min-width: $pt-grid-size * 44;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the min-widths different?

@@ -18,6 +18,7 @@ export const DATEPICKER_MONTH_SELECT = "pt-datepicker-month-select";
export const DATEPICKER_YEAR_SELECT = "pt-datepicker-year-select";

export const DATERANGEPICKER = "pt-daterangepicker";
export const DATERANGEPICKER_SEQUENTIAL = "pt-daterangepicker-sequential";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class still abides by the old isSequential naming scheme. Can we change to pt-daterangepicker-contiguous or something?


export function getDatePreviousMonth(date: Date): Date {
const monthIsJanuary = date.getMonth() === Months.JANUARY;
if (monthIsJanuary) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IMO the equality expression above is clear enough without this extra variable.

}

// returns -ve if left < right
// returns +ve if left > right
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the ...ve suffix took a sec for me to interpret. I guess I'm not mathy enough. Mild preference for negative and positive.

renderDateRangePicker({ contiguousCalendarMonths, maxDate, minDate });
assert.lengthOf(document.getElementsByClassName("DayPicker"), 1);
assert.lengthOf(document.getElementsByClassName(".DayPicker-NavButton--prev"), 0);
assert.lengthOf(document.getElementsByClassName(".DayPicker-NavButton--next"), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the dots in the class name when using document.getElementsByClassName. Won't return anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha oops...

});

it("is a day between minDate and maxDate if only maxDate/minDate set and today is not in range", () => {
const maxDate = new Date(2005, Months.JANUARY);
const minDate = new Date(2000, Months.JANUARY);
renderDateRangePicker({ maxDate, minDate });
const { displayMonth, displayYear } = dateRangePicker.state;
assert.isTrue(DateUtils.isDayInRange(new Date(displayYear, displayMonth), [minDate, maxDate]));
const leftDisplayMonth = dateRangePicker.state.leftView;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Pondering to myself it const leftView = ... would be clearer to me than const leftDisplayMonth = ..., since the display month includes a year. Thoughts @leebyp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes thanks, this was leftover from refactors - updated a couple of other places i missed too.

@blueprint-bot
Copy link

more verbose css and add toggle to example

Preview: docs | landing | table
Coverage: core | datetime

@blueprint-bot
Copy link

missed capital letter

Preview: docs | landing | table
Coverage: core | datetime

@leebyp
Copy link
Contributor Author

leebyp commented Feb 17, 2017

@cmslewis should be easier to read now

@cmslewis
Copy link
Contributor

cmslewis commented Feb 17, 2017

@leebyp love the "Show shortcuts" toggle and the CSS variables! The monthAndYear variables are still a little tricky, but I'm okay with them as is. My only remaining nit is to give the toggle labels a little more room if possible:

2017-02-17 14 51 42

Otherwise, looks good IMO.

@blueprint-bot
Copy link

docs css

Preview: docs | landing | table
Coverage: core | datetime

@leebyp leebyp merged commit f667b2c into master Feb 20, 2017
@leebyp leebyp deleted the bl/independent-daterangepicker-months branch February 20, 2017 04:12
@llorca
Copy link
Contributor

llorca commented Feb 20, 2017

Shouldn't it be "Constrain" instead of "Contrain"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants