-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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: add customizable calendar icon #4295
feat: add customizable calendar icon #4295
Conversation
Introduce the ability to customize the calendar icon used in the DatePicker. This is achieved by allowing a new prop which can accept a string (class name) or a React component. This aims to enhance the component's flexibility and user customization options.
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.
✅ This pull request was sent to the PullRequest network.
@frankops11 you can click here to see the review status or cancel the code review job.
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.
PullRequest Breakdown
Reviewable lines of change
+ 172
- 10
60% JavaScript
34% JavaScript (tests)
4% Markdown
2% HTML
Type of change
Feature - These changes are adding a new feature or improvement to existing code.
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.
It might be worth adding an example for the second use case, but outside of that this looks like a solid feature to add and I see no issues with the implementation to prevent this from moving forward
Reviewed with ❤️ by PullRequest
@@ -5,6 +5,7 @@ | |||
showIcon | |||
selected={startDate} | |||
onChange={(date) => setStartDate(date)} | |||
icon="fa fa-calendar" |
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.
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.
James, good call on the SVG component example. I'll add that in and push it soon. Thanks!
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.
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.
Hi James,
I've added the examples! 🚀 The SVG one isn’t as clean since I embedded the SVG directly, but I hope it makes sense. :D
Cheers!
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.
This looks really useful, and thanks for writing so much in the PR description.
The only comment I really have for improvement is it could be nice to have some tests for this.
Reviewed with ❤️ by PullRequest
Hi Dallas, Absolutely! I've attached a few, looking forward to your feedback! 😄 Cheers! |
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.
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.
This looks really useful, and thanks for writing so much in the PR description.
The only comment I really have for improvement is it could be nice to have some tests for this.
Reviewed with ❤️ by PullRequest
Hi Dallas,
Absolutely! I've attached a few, looking forward to your feedback! 😄
Cheers!
Codecov Report
@@ Coverage Diff @@
## main #4295 +/- ##
==========================================
+ Coverage 96.52% 96.54% +0.01%
==========================================
Files 25 27 +2
Lines 2358 2370 +12
Branches 962 965 +3
==========================================
+ Hits 2276 2288 +12
Misses 82 82
|
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.
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.
Hey @martijnrusschen! I'm Francisco, and I've been poking around and contributing a bit to react-datepicker lately. Just shot a PR your way with a feature that allows for more versatile calendar icon customization. Have you had a chance to take a look? I’d love to hear your thoughts and find out if there’s a chance we could merge it into main. Along the way, I've also been thinking about a couple of things that could be cool for the project. For instance, I'm considering playing around with VitePress to propose a redesign of the documentation website. It’s not bad as it stands, but I’ve got some ideas that might make it a bit more polished and user-friendly. Would you be open to discussing this? I'm keen on continuing to contribute to the project, both in improvements and solving issues. Looking forward to your feedback on the PR and chatting about these ideas. Cheers! |
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.
Thank you for the extensive examples and write-up. This is looking good!
@frankops11 Thanks for your contribution. I'd love to hear your thoughts on improving the documentation site. The component has significantly grown over the years and could use some rework to make it future proof. |
Hey, thanks a lot for merging the PR and for being open to dialogue about improving the documentation site! I'm particularly excited about infusing the documentation site with a modern, sleek aesthetic, and VitePress strikes me as an ideal tool for this. Despite its Vue.js foundation, we can utilize Whyframe to render React previews and examples. This would not only allow users to explore live demos but also interact with and understand the code in an approachable manner. Diving into react-datepicker component enhancements: TypeScript Compatibility: Generating or exposing TypeScript definitions should enhance the experience for TypeScript projects. A full TypeScript migration is in my thoughts too but let's indeed tread step by step. Eager to dive into your thoughts and, upon approval, immerse myself in implementing these enhancements! Warm regards, |
Let's move this discussion to an issue or discussion so we can chat about the initiatives. |
🚀 Proposal:
Enhance the customization capabilities of the calendar icon in the
DatePicker
component, allowing the use of custom icons and not solely the default provided icon.🏗 Changes Made:
New
icon
Property:icon
prop that accepts either a string (icon class name) or a React component (e.g., a custom SVG).icon
is a string, an<i>
element is rendered with that string as its class name.icon
is a React component, it is rendered as-is.New
calendarIconClassName
Property:calendarIconClassName
prop for further icon styling customization.calendarIconClassName
will be added as an additional CSS class to the calendar icon, allowing enhanced style customization.Code Refactor:
CalendarIcon
) for improved code readability and maintainability.renderInputContainer
method to utilize the newCalendarIcon
component.🎯 Motivation:
The inspiration behind these changes is to bestow developers with greater control over the
DatePicker
's display. By enabling calendar icon customization, we enhance the developers' UI control over theDatePicker
without sacrificing functionality or user experience.👀 How to Use the New Feature:
You can now utilize various renowned icon libraries, such as Font Awesome, Material Icons, or your custom SVGs, with the new
icon
prop. Here are examples of how to implement this:🔄 Backward Compatibility:
It is pivotal to note that these changes have been implemented to ensure backward compatibility. Existing implementations of the
DatePicker
using theshowIcon
prop will continue to function as before, displaying the default calendar icon if noicon
prop is provided.📝 Final Notes:
These proposed changes aim to deliver a flexible solution to accommodate various needs without introducing significant overhead to the codebase or altering the API properties in a way that disrupts existing implementations. I am open to feedback and suggestions to refine this proposal and hope that this change brings valuable additions to the
react-datepicker
user community.