freiksenet / react-calendar

A modular toolkit to build calendar-related things in React
http://freiksenet.github.io/react-calendar/
MIT License
249 stars 46 forks source link

api for adding/removing days on click handler #15

Closed srconklin closed 8 years ago

srconklin commented 9 years ago

I don't see much in the way of documentation nor could i tell from the source, but is there an API method to add/remove days (make them current) to the calendar interactively ..say in the onclick handler of the component?

freiksenet commented 9 years ago

What do you mean by adding and removing days? You can pass more or less days as children if you want to mark more or less days with CSS classes.

srconklin commented 9 years ago

Perhaps i don't understand how the component works fully.. but i did not see how to do this from the examples.

I see in the example that a moment object is passed to the onClick handler , but can i use that to make the day they clicked on in the calendar "current" or "active"? ....likewise, if they click one of the highlighted days set up at render using the Day component, i want to toggle that off.. (or remove it)

I effectively want to keep an array of user selected "days" in state so that i can submit a form and serialize and persist those dates.

Can i do this?

srconklin commented 9 years ago

Ultimately, what I am looking for is a calendar component that lays out several months at a time like you have created.. in most cases it is empty.. i.e. no current dates.. Then a user would pick large ranges of dates... It would be really nice, if i can mousedown on say Monday and drag over to Friday and select (make active) the whole week.. I am need of this kind of functionality for a Bus Timetable scheduler.

freiksenet commented 9 years ago

Sorry for the late response.

The idea currently is that if you want to modify behaviour or look of certain days, you pass the Day component that has corresponding date passed to it and then has handlers or, eg, new classes. See example with 'current day' - it is passed 'today' , so "today's" day will be adjusted.

Hope that helps.