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

Redo DateTimeInput with downshift #282

Merged
merged 8 commits into from
Dec 5, 2018

Conversation

dferber90
Copy link
Contributor

@dferber90 dferber90 commented Dec 3, 2018

This is the new DateTimeInput based on downshift.

Before  After
image image

See also #281 which replaces DateInput.

Breaking Change Previously onChange would be called with the value directly. Now it gets called with an event containing the value. This was done to be in line with how the other inputs work.

@dferber90 dferber90 requested review from pa3 and montezume December 3, 2018 13:03
@dferber90 dferber90 mentioned this pull request Dec 3, 2018
@dferber90 dferber90 force-pushed the df-redo-date-input-using-downshift branch from df503d4 to 5d790e5 Compare December 3, 2018 13:30
@dferber90 dferber90 force-pushed the df-redo-date-time-input-using-downshift branch from 8f9f94d to 6e5e083 Compare December 3, 2018 13:31
@@ -0,0 +1,135 @@
// Difference of this file to utils.js is that this file
Copy link
Contributor

Choose a reason for hiding this comment

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

why the name calendar-time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are utilities for a calendar which respects time. It was really hard to find good names here. We need the utils to:

  • share logic between the calendars (DateInput & DateRangInput). DateTimeInput uses its own utils (this file).
  • keep the date library (moment) out of our components which makes them more readable and makes it easier to replace the date-library if we ever want to

return addFlatpickrOffset(value, timeZone);
const preventDownshiftDefault = event => {
// eslint-disable-next-line no-param-reassign
event.nativeEvent.preventDownshiftDefault = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a really nice way to give a lot of opt-in control to consumers.

getDaysInMonth(today, this.props.timeZone) -
1,
}),
() => this.inputRef.current.focus()
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@emmenko
Copy link
Member

emmenko commented Dec 4, 2018

Nitpick: can the default day be highlighted a bit more? It's a bit "hard" to see the blue color. Also the months/years do not seem to be aligned correctly.

image

@dferber90
Copy link
Contributor Author

dferber90 commented Dec 5, 2018

can the default day be highlighted a bit more? It's a bit "hard" to see the blue color.

The blue color represents "today". It is not the default highlighted date.A highlight looks like this. The 14th is highlighted here.

Also the months/years do not seem to be aligned correctly.

Thanks for the hint. This was a problem in Firefox only. I fixed it there now (in #281).

@dferber90 dferber90 force-pushed the df-redo-date-input-using-downshift branch from 3ac9eb3 to 2932680 Compare December 5, 2018 09:59
@dferber90 dferber90 changed the base branch from df-redo-date-input-using-downshift to master December 5, 2018 10:43
@dferber90 dferber90 force-pushed the df-redo-date-time-input-using-downshift branch from 6e5e083 to 0da4c39 Compare December 5, 2018 11:02
@dferber90 dferber90 force-pushed the df-redo-date-time-input-using-downshift branch from 0da4c39 to 89d0e0b Compare December 5, 2018 11:16
@dferber90 dferber90 merged commit 437c29a into master Dec 5, 2018
@dferber90 dferber90 deleted the df-redo-date-time-input-using-downshift branch December 5, 2018 16:39
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.

4 participants