Giter VIP home page Giter VIP logo

Comments (7)

fabiofranzini avatar fabiofranzini commented on June 15, 2024 1

This could be a scenario:
Imagine that I have to show appointments on the calendar.
To avoid loading all the data from a Rest API, if I were notified via an event at the change of year or month I could call it Rest, get the data and then use it within highlightDate.
Seems ok?
Or in this case, how would you do it?

from react-calendar-toolkit.

morewings avatar morewings commented on June 15, 2024

Hi. Can you explain your idea?

it would be very useful to have 2 events that are triggered when the year and month are selected, a bit like the date selection (onDateSet event).

Internally, reducer actions are triggered when user changes calendar precision. But onDateSet triggers only when user clicked date with minimum precision (see Define minimal precision of Calendar example here https://morewings.github.io/react-calendar-toolkit/#!/Available%20components/DatePicker).

This way you could optimally load data that can then be used in 'highlightDate' or simply be notified when the monthly or annual view changes.

In existing code highlightDate receives precision param. So you can do something like this:

highlightDate: ({precision, date}) => {
  return precision === 'month' && isSameMonth(date, new Date(2012, 11, 0));
}

This will highlight December of 2012 when user selects month view. Is that what you looking for?

from react-calendar-toolkit.

morewings avatar morewings commented on June 15, 2024

Now I see your point. It makes sense together with visible date state updates, for same reasons you told.
Do you have any ideas, how api can look like? Easiest option is to expose two additional callbacks.

from react-calendar-toolkit.

fabiofranzini avatar fabiofranzini commented on June 15, 2024

Exposing 2 callbacks could be useful to notify the change of month and year, but then eventually how do you update the status of individual days?
Currently there is a call back 'highlightDate' but I don't think it is useful in case of calls of this type.

What about a 'highlightDates' property where you pass the dates and for each date a state and a 'renderDate' callback where in this case you can implement rendering logic based on 'highlightDates'.

So, just an idea .. tell me yours

from react-calendar-toolkit.

morewings avatar morewings commented on June 15, 2024

eventually how do you update the status of individual days?

Actually that's what highlightDate prop does. It is called each time calendar renders, so you can pass array of dates to match.

a 'renderDate' callback where in this case you can implement rendering logic based on 'highlightDates'.

It's done already there are renderDayAs, renderMonthAs and so on props, which you can pass React component to render. Component will receive highlight Boolean prop. https://morewings.github.io/react-calendar-toolkit/#/Datepicker%20custom%20UI?id=day

from react-calendar-toolkit.

fabiofranzini avatar fabiofranzini commented on June 15, 2024

Yes, I understand the logic. My question was about how to trigger the render method after a an external callback. highlightDate is a callback, not a prop with data.
If we'll have the 2 callback fot month and year selection, int whitch way we can re-render the control to force the execution of highlightDate?

from react-calendar-toolkit.

morewings avatar morewings commented on June 15, 2024

My idea is that ‘highlightDate’ should handle this. It receives ‘precision’ param, which indicates what calendar (day, month) is visible.
User can change type of visible calendar by clicking the control.
Developer can’t change visibility of calendar via props, that would too much imperative imho. But developer should be notified about this change.

from react-calendar-toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.