Comments (7)
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.
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.
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.
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.
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.
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.
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)
- Invalid Hooks Error HOT 2
- Make calendar theme system-ui compatible
- Replace styleguidist with docz
- Update popover module HOT 1
- Add theming support
- Export useFormatDate
- Fix double lib path in build HOT 1
- Update README
- Remove camelcase from Datepicker name
- Use css-vars-hook
- Replace wrapper components with classes
- Create pre-release for testing
- Reafctor WeekDays
- Add hours and minutes precision
- Add Calendar component
- Check peer dependencies
- Add precision info as a separate page in docs
- eslint-plugin-import dependency update
- Transform API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-calendar-toolkit.