-
-
Notifications
You must be signed in to change notification settings - Fork 753
feat: add navLayout
prop
#2755
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
base: main
Are you sure you want to change the base?
feat: add navLayout
prop
#2755
Conversation
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
@rodgobbi still refining the change, wanted to share with you this proof-of-concept - what do you think? |
Lemme fix the animation issues, I'll push changes to your branch. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach looks good indeed.
I understand better now, using explicit values for the prop fixes #2629.
And I imagine we could make the after
value the default one in the upcoming breaking change.
My only suggestion is to try to move the new nav layout elements out of the months.map
, as they don't repeat per month in the calendar, therefore conceptually they should be out of the months.map
logic.
And I expect that doing so would simplify the CSS styles and perhaps fix the issue happening with the animation.
@@ -377,6 +381,24 @@ export function DayPicker(initialProps: DayPickerProps) { | |||
displayIndex={displayIndex} | |||
calendarMonth={calendarMonth} | |||
> | |||
{navLayout === "around" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could move this out of the months.map
scope, as it is absolute
positioned, I expect we could mount one button before the map and another one after.
If you tried this already, lemme know if there are any issues.
This comment also applies to the after
navLayout
, which is mounted within the map
scope.
Perhaps doing that fixes the issue that happens during the animation.
Signed-off-by: gpbl <io@gpbl.dev>
Thank you, @rodgobbi, for your quick review and suggestions! Apologies for not being clear about how to test this (I use the playground in the website).
Yes, exactly! That is the plan.
The reason I placed the navigation buttons inside the loop is to align them with the caption when displaying multiple months across multiple rows. I can't make assumptions about how large is that container... ![]() Moving the buttons outside the I believe the animation glitch is because these elements are not being hidden while duplicating the container during the transition (the test failure seems to confirm that). If you have some time to look at it I'd be happy to let you fix it! |
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
I see, I think I was testing the branch too soon, even before you pushed some changes required for the nav buttons to be aligned with the caption. For the What do you think of rendering only the I can test this and push the changes if it works. |
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Signed-off-by: gpbl <io@gpbl.dev>
Thanks @rodgobbi I got what you mean. For the
Fixed,
I'm not sure if I can replicate this again - I'll double check.
Also in this case, we want it right after the caption to preserve the tab behavior. |
Signed-off-by: gpbl <io@gpbl.dev>
I confirm the glitch with multiple months is still there: Untitled.movI will give a look to it tomorrow with a fresh mind! |
@gpbl thanks for checking, lemme try to fix it later and I'll message you again with the results 👍 |
@gpbl I need to think more about how to work around that. It's very tricky to support the current On the flip side, the glitch happens when there are multiple months wrapping to the next line, and in the same scenario the tabbing flow is also problematic: Screen.Recording.2025-05-06.at.18.59.50.movI wasn't able to reproduce the glitch happening to the first displayed month like in #2755 (comment). What do you think of always anchoring the Like the last nav button for the |
This PR introduces the new
navLayout
prop, which fixes #2629 and provides a new layout option for navigation:around
: Navigation buttons are displayed on either side of the caption.after
: Navigation buttons are displayed after the captionThis change also accounts for cases where the number of months displayed is greater than one.
Known Issues
useAnimation
hook.Screen.Recording.2025-05-04.at.8.14.09.AM.mov
Notes on Reusing the
Nav
ComponentI considered adding
skipNextButton
orskipPrevButton
props to theNav
component to reuse it. However, I am not sure if as having multiple<nav>
elements with the same label is correct. ReusingNav
would potentially result in a breaking change.