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

Show week numbers and handle week number selection #304

Closed
rodeinator opened this Issue Apr 21, 2017 · 2 comments

Comments

2 participants
@rodeinator

rodeinator commented Apr 21, 2017

I need a quick week selection in this awesome day picker. It is already possible to show week numbers in day picker? Would this feature be something for the core implementation?

week-selection

I would suggest to implements props like this:
<DayPicker enableWeekSelection={true} onWeekClick={ this.handleWeekClick } />

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Apr 21, 2017

Owner

Yeah we could consider to add a showWeekNumbers and onWeekClick. 👍🏽

For selecting a week, you could implement an onDayClick saving in your component's state the clicked day's week number:

handleDayClick = day =>
    this.setState({
      selectedWeek: getWeekNumber(day)
    })

then pass a function to the selectedDays prop:

<DayPicker
    onDayClick={ this.handleDayClick }
    selectedDays={ day => getWeekNumber(day) === this.state.selectedWeek }
/>
  • you need to implement getWeekNumber by yourself (example)
  • you may add more logic to unselect the week when the user clicks on a day of a already selected week
Owner

gpbl commented Apr 21, 2017

Yeah we could consider to add a showWeekNumbers and onWeekClick. 👍🏽

For selecting a week, you could implement an onDayClick saving in your component's state the clicked day's week number:

handleDayClick = day =>
    this.setState({
      selectedWeek: getWeekNumber(day)
    })

then pass a function to the selectedDays prop:

<DayPicker
    onDayClick={ this.handleDayClick }
    selectedDays={ day => getWeekNumber(day) === this.state.selectedWeek }
/>
  • you need to implement getWeekNumber by yourself (example)
  • you may add more logic to unselect the week when the user clicks on a day of a already selected week

@gpbl gpbl self-assigned this May 6, 2017

@gpbl gpbl added new feature and removed user support 🚑 labels May 6, 2017

@gpbl gpbl added this to the v5.5.0 milestone May 6, 2017

@gpbl gpbl closed this May 10, 2017

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl May 10, 2017

Owner

showWeekNumbers and onWeekClick have been added to v5.5.0 🙆🏽

Owner

gpbl commented May 10, 2017

showWeekNumbers and onWeekClick have been added to v5.5.0 🙆🏽

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