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
feat: Introduced custom components "Months" #1917
Conversation
feat: Introduced custom components "Months"
Interesting, thanks for your contribution! Looking at it. |
Hi @gpbl , do you have any feedback regarding this PR? |
# Conflicts: # src/components/Root/Root.test.tsx
Thanks @pawelgoc I wanted to update a bit the code to match our code style. Thanks for you contribution, coming soon on npm! |
(PS. if you are trying to add animation to the calendar - it is something we plan to add in v9. Would love to see your implementation) |
I doubt our impl. will fit to library as it would require additional dependency. Idea is to utilise pagination build in DayPicker + any library that serve Carousel functionality. Of course there is needed additional sync between both components to resolve what is current month and slideIndex. Simplified example:
How it looks: |
Context
As developer I might want to wrap
<DayPicker />
and use children API to map over months. For instance I would want to extend pagination to behave like carousel - this seems good use case for usingChildren.map
.To achieve it we need to be able to host collection of
<Month />
elements. That's why replacing hardcoded months container by public customisable<Months />
open additional possibility how library can be consumed.Analysis
Current implementation will always return only one children because in Root component DIV element is wrapper on top of months.
Solution
With custom
<Months />
component we can have direct access to array children or to do any other customisation. It means library is more flexible without exposing core functionality.We already can find dedicated
classes and styles
formonths
to allow customisation, that's makes me think that custom component<Months />
also make sense.Other approach I've tried was to compose
DayPicker
form existing components like:but it is also impossible because
<Month />
is private (I believe for good reasons).