-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: ✨ new date picker v9 #4421
base: main
Are you sure you want to change the base?
Conversation
@flixlix is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
|
Co-authored-by: kchro3 <[email protected]>
React daypicker already has functionality for month/year select. So it would probably be better to use that: |
I did see this, but in my opinion the select dropdown is not as user friendly, especially considering might want to enter their birth dates in some cases |
While i agree that it isn't as clean as your solution. It still exists in the original component, and since this library is a wrapper it feels a bit weird to not support that. Since this library gives you the code, we can extend it ourselves for better UX like you did, but not sure it should be in the base component. Not hating on your work because it looks great! |
Alright I see your point, maybe I'll try contributing to RDP directly and hopefully we can use it directly in shadcn after that :) |
@flixlix |
Any update? |
Hi @flixlix
|
(_, i) => { | ||
const isBefore = | ||
differenceInCalendarDays( | ||
new Date(displayYears.from + i, 12, 31), |
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.
Please beware of the second argument being monthIndex
and is zero-based:
new Date(displayYears.from + i, 12, 31), | |
new Date(displayYears.from + i, 11, 31), |
disabled: "text-muted-foreground opacity-50", | ||
range_middle: | ||
"rounded-none aria-selected:bg-accent aria-selected:text-accent-foreground hover:aria-selected:!bg-accent hover:aria-selected:text-accent-foreground", | ||
hidden: "invisible hidden", |
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'm observing that when showOutsideDays is false for a 2 month calendar, the "hidden" property messes with the flex positioning since the hidden days still need to take up space along the row
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.
Same here. The hidden
class should be removed
This is probably my favorite among the previous attempts to extend the date picker. It feels really nice and intuitive to use. Btw, not sure if
Maybe it'd be better to move the components outside. |
That would be great. Nice job man. |
It would be nice to have this functionality, it's modern and other libraries are doing something similar. |
Great job! |
Here's an improved version of this calendar. This code fixes the following:
|
Hello, do we know when the fix will be released? Thanks! |
@musthafa1996 your component lacks some styles polish-for example when I hover the corners are not rounded: |
|
Thanks, you saved me some work. Finally a version which works with captureLayout="dropdown" <3 |
@Blackvz works, but does not display two calendars side by side in range select mode 👎 |
Added support for
react-day-picker
v9.Currently using this version in conjunction with the calendar component leads to this broken view:
The fix leads to this view (should be the same as before):
Had to change quite a bit in the calendar component, but tried to keep the visual aspect as close to before as possible.
Year Picker
Also added a new feature that is especially useful when trying to select a birth date. Before, a user would have to navigate through each month at a time. This obviously is not very good UX, the older the user, the worse the experience. ;)
Here is a demo of the new functionality, to add it to the date picker component, the user only needs to pass the
showYearSwitcher
prop to the calendar component.notice this label can now be a button. When clicking this button, a new view will appear.
This is the year view, the user can now navigate and switch between years instead of only one month.
The amount of years shown in this view can also be customised, by passing the number of years desired to the
yearRange
prop. By default this is 12.In the meantime, this component can be used and tested by anyone using this link:
✨ https://date-picker.luca-felix.com/ ✨