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

Disable range of time #7

Open
etairi opened this issue Nov 23, 2017 · 3 comments
Open

Disable range of time #7

etairi opened this issue Nov 23, 2017 · 3 comments

Comments

@etairi
Copy link

etairi commented Nov 23, 2017

I would like to suggest a possible feature for the TimePicker. I would like to have the option to disable hours and minutes like in Material-UI DatePicker with "minDate" and "maxDate" parameters. It would be useful to set the available time range.

For example, <TimePicker from={'9:50'} to={'16:33'} />

@gunn
Copy link

gunn commented Dec 26, 2017

A fully flexible approach that works more like DatePicker's shouldDisableDate option:

const allowHours   = ({hours})=> hours >=9 && hours <= 16

const allowMinutes = ({hours, minutes})=> (
  (hours==9 && minutes>=50) ||
  (hours==16 && minutes<=33) ||
  true
)

return <TimePicker allowHours={allowHours} allowMinutes={allowMinutes}/>

Or a better compromise:

const allowedTimes = [{from: '9:50', to: '16:33'}]

return <TimePicker allowedTimes={allowedTimes}/>

@leMaik
Copy link
Member

leMaik commented Dec 26, 2017

@etairi Good idea! 👍

@gunn Your first option is far too complicated imho, and the second option is just a more complicated way to configure what @etairi suggested. 😉

@gunn
Copy link

gunn commented Dec 28, 2017

@leMaik agreed on the first option. The point of the second option is to allow this:

const officeHours = [{from: '9:00', to: '12:00'}, {from: '13:00', to: '17:00'}]
return <TimePicker allowedTimes={officeHours}/>

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

No branches or pull requests

3 participants