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

Show week numbers and handle week number selection #304

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

Show week numbers and handle week number selection #304

rodeinator opened this issue Apr 21, 2017 · 2 comments
Assignees
Milestone

Comments

@rodeinator
Copy link

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
Copy link
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 this to the v5.5.0 milestone May 6, 2017
@gpbl gpbl closed this as completed May 10, 2017
@gpbl
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants