React-dates: [Feature Request] Preset date ranges

Created on 19 Aug 2016  路  9Comments  路  Source: airbnb/react-dates

One thing that is necessary for an app that I am building is preset date ranges. For what I am doing, it is a bad UX to force users to pick specific dates always; oftentimes they want just the data from the last week/month/etc. I understand that for Airbnb this is not a valid use case, but for many other styles of it is. A good mockup for how this might look is from bootstrap-daterange-picker:

calendar-with-presets

Would the maintainers be open to accepting a PR with the feature if it was not part of the default configuration?

feature request question

Most helpful comment

Are presets now natively supported ?!

All 9 comments

Could you provide some examples of how the "presets picker" would look in all the various configurations? ie, vertical, single month, double month, etc?

@ianks you can build your own either as dropdown next to picker, links, or get fancy and add to div.

Simple implementation re-using the change callback

~
|  
|  
|  
|  

~

screen shot 2017-01-16 at 2 37 02 pm

@mikesparr your solution might not work if you have calendar opened and part of the range isn't visible.

1

I click at quarter range, but only half of dates are highlighted. The problem is that when the dates aren't visible (!isDayVisible(...)), modifiers wouldn't be updated.

https://github.com/airbnb/react-dates/blob/master/src/components/DayPickerSingleDateController.jsx#L442-L444

Would appreciate any help.

Are presets now natively supported ?!

Need this too, for weeks, months, and years.

@sharq1 Your extension looks promising, but unfortunately it has no license attached to it.

@derwaldgeist it's MIT now. Cheers!

This is somewhat addressed in that there is an example of how to do this at http://airbnb.io/react-dates/?react_perf=1&selectedKind=PresetDatePicker&selectedStory=default&full=0&down=1&left=1&panelRight=0&downPanel=storybook%2Factions%2Factions-panel

I don't think we will be shipping anything preset specific because it's already possible to implement it yourself with the API. Now there is better documentation of that. :)

Was this page helpful?
0 / 5 - 0 ratings