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

onClickWeek and onClickMonthLabel #12

Closed
amansur opened this issue Nov 29, 2017 · 11 comments
Closed

onClickWeek and onClickMonthLabel #12

amansur opened this issue Nov 29, 2017 · 11 comments
Milestone

Comments

@amansur
Copy link

amansur commented Nov 29, 2017

Hi there wojtekmaj

I'm really enjoying using your Calendar component.

The showWeekNumbers prop is especially useful for me. Would it be possible to add a click listener for the week numbers similar to the other onClick{period} props.

For my use, I'm also disabling all views aside from Month using the minDetail prop. Since the month label no longer changes the view, I'd like to be able to attach a click handler on the month label. Could that be a prop as well?

Thanks again for the great module!

@wojtekmaj
Copy link
Owner

wojtekmaj commented Nov 30, 2017

Hey @amansur,
that sounds nice! Check out feature/active-week-numbers branch and tell me what you think!

You can install it directly from npm for testing purposes (do not use on production):

npm install wojtekmaj/react-calendar#feature/active-week-numbers

onClickWeekNumber callback is called with two arguments, weekNumber and weekStartDate.

@amansur
Copy link
Author

amansur commented Dec 1, 2017

Thanks so much for the speedy enhancement!

Unfortunately, I wasn't able to get the new branch installed. Looking at the node_modules/react-calendar directory after using your install command, it seems to be missing the build folder?

Failed to compile.

./src/App.js
Module not found: Can't resolve 'react-calendar' in '/Users/amansur/code/calendar-test/src'

@wojtekmaj
Copy link
Owner

Ah yeah, sorry, I missed the part that git branch lacks /build folder. You'd need to run npm install and npm run build in its directory to make it work.

@wojtekmaj
Copy link
Owner

...or take it precompiled from me:
build.zip

@amansur
Copy link
Author

amansur commented Dec 1, 2017

Thank you, the precompiled version works great.

For the calculation, I assume you're using the ISO 8601 standard of having Monday be the first day of the week?

@wojtekmaj
Copy link
Owner

wojtekmaj commented Dec 1, 2017

Not necessairly. If you explicitly chose calendarType ISO 8601 or set non-en-US locale, then yes, of course the calendar will follow ISO standard. Please mind that in US calendar not only the week starts on Sunday, but also week numbers are calculated differently.

@amansur
Copy link
Author

amansur commented Dec 1, 2017

The callback is always given the Monday as the weekStartDate. I've tried explicitly setting the calendarType prop to 'US' and also excluded the prop (I'm in a en-US locale).

@wojtekmaj
Copy link
Owner

Sorry, my bad! Forgot to pass one parameter. ;)

build.zip

@amansur
Copy link
Author

amansur commented Dec 1, 2017

Awesome, it works great now! Thanks again!

@wojtekmaj
Copy link
Owner

Glad I could help. Expect it in the next release :)

@wojtekmaj wojtekmaj added this to the 2.6.0 milestone Dec 2, 2017
@wojtekmaj
Copy link
Owner

onClickWeekNumber has been added in v2.6.0. onClickMonthLabel would be too problematic, but I think you can apply custom callbacks by yourself, as well.

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