-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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(components): calendar/datepicker with month and year select #1739
base: main
Are you sure you want to change the base?
Conversation
@jhavej is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Whilst testing this change, it seems fromDate & toDate no longer work. With the changes made in this PR: With the previous calendar component: In the 1st screenshot, the calendar defaults to October 2023. In the 2nd screenshot the calendar defaults to October 2005. The expected behaviour is the latter. The following is my implementation of this component (which is static between the test scenarios):
Maybe the implementation should change, but from the original comment I don't think so. Happy to make changes to my implementation as per instruction. Thanks |
Thanks for the catch @iaingymware 👍 It was caused because of the default values for I removed the default values and passed Tested also with |
Hi @shadcn 👋 Yeah, I noticed this PR, see it in my first comment. It brings unnecessary complexity as it adds a custom dropdown and event handlers - you can see it here. My solution is purely based on the capabilities of React DayPicker by enabling its Just fixed the minor issue above & built the registry so we can finish this soon. Cheers, |
I tested both and imo @jhavej implementation is less bloated, and works better. |
Thanks for the approval @pyloverm 👍 Should I merge Let me know and thanks again. |
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 addition of the date-picker-with-range and date-picker-with-month-year components appears consistent with the component organization.
The enhancements to the default calendar, including the month and year dropdowns in date-picker-with-month-year, align with the design goals of shadcn/ui . It's great to see improvements in usability.
The documentation for the date-picker-with-month-year component in date-picker.mdx is clear and well-integrated.
The updates to the styles in both default and New York registries show attention to detail.
Overall, this is a solid contribution!👏🚀
Hi @jhavej I have tried your approach [not gonna lie it is a clean one], however since it uses the default browser dropdown it's not working correctly while in dark mode Extra: I have also tried #1680 and yours works better, but is there a way to combine both the clean look of shadcn/ui select component and your approach? (Your approach works much better for range selection since I can change the month from both sides) |
would it be somehow add month and year picker but not only day picker in the future? |
Hello everyone, i have seen this pull request and though that it needs more love, so i put together my spin on dropdown month/year picker. It requires a lot more code to work, but it's probably worth it. Demo: https://shadcn-calendar-v9-m9mh.vercel.app/ Many thanks to @Nhollas for providing styling for day-react-picker v9 in this https://github.com/shadcn-ui/ui/pull/4371#issuecomment-2284286079 Feel free to borrow my code it's MIT |
This PR implements the missing month/year
select
in the calendar/datepicker component.Related PRs: #1680 #320 #546 #509 #880
My approach relies exclusively on the native
captionLayout
prop offered by React DayPicker, along with additional Tailwind CSS styling for the Calendar component. This approach maximizes the capabilities of React DayPicker, simplifying the solution and reducing the risk of bugs.Other calendar/datepicker use cases remain unchanged.
Here's the demo:
Screen.Recording.2023-10-13.at.16.21.15.mov
Cheers,
Jakub 👋