-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adding an input icon to the begining of the DateRangePickerInput #222
Conversation
I imagine that people will want to be able to customize the icon to match their sites. Instead of baking the icon in, it seems better to allow a component to be passed in that would enable people to use whatever decoration they wanted. What do you think @majapw? |
I can change that if needed but I just followed the choices made with the arrow and the close button of baking them in. |
Hi @AntiFish03! I think it makes sense to have it be configurable a la the month navigation buttons but maybe default to the SVG you've provided. Can you also post a screenshot of how this looks? Thanks! |
Also, I am more than happy to make the requested change give me a few minutes to adjust it. |
``` | ||
showCalendarIcon: PropTypes.bool | ||
showInputIcon: PropTypes.bool, | ||
customInputIcon: PropTypes.node |
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.
could we just have a inputIcon
prop that's either null
or a node
? I'm not sure I see the point in having both.
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.
but maybe default to the SVG you've provided.
If it is both optional and customizable it needs to know when to display, when to display the default, and when to display the custom icon.
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.
ah, i didn't realize there'd be an icon included by default. Might it be simpler to go with a single inputIcon
prop, and then export the default icon so that users can pass that in if they want it?
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.
Possibly... Its your call. The icon is an export out of the Font Awesome SVG, under its open license. So its definitely not a custom calendar icon.
However, this is more simple if you are just going to use the basic input icon because trying to use the traditional method of adding to the HTML below and adjusting its positioning could create user interaction difficulties (i.e the icon steals the click).
And this version has a customizable capability that someone with a truly custom calendar icon could use without difficulty.
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.
true - i'm torn. We could do PropTypes.oneOfType([PropTypes.oneOf([true]), PropTypes.node])
but that seems icky.
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.
Wouldn't PropTypes.oneOfType([PropTypes.bool, PropTypes.node])
work. It would be less exact but its also less icky
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.
And thinking about it a little further that would actually be more exact not less, Because false, true, node should all be valid values. We are just choosing to think of it as null, true, node.
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.
Hmm, whatever we choose to use here will likely also end up influencing how we implement customization on the clear dates SVG.
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 am happy to make changes in what ever direction... I have a need for this and would rather assist the community using this than maintain a fork...
I am happy to adjust this however it needs to be to allow the input icon, (so I don't have to maintain a fork). Whether there is a baked in default or customizable, or both. Just need to know which way to take the code. |
@AntiFish03 For defensive purposes, if both props are there, the custom icon should take precedence. Does that seem good? |
@majapw, I made the changes you suggested. |
@AntiFish03 would you mind rebasing on top of latest master on the command line, so that there's no merge commits? If you have trouble, please let us know and we can take care of it for you (but please don't close this PR, delete the branch, or open a new one) |
@ljharb, I would but I am away from a consistent internet connection at the moment. |
3c7b6d1
to
0cbdfc3
Compare
@AntiFish03 np, i've gone ahead and rebased it for you. |
@ljharb thanks |
48623b6
to
2077332
Compare
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.
Looks reasonable to me, although we'll want to do some work in the future to a11y this probs.
return ( | ||
<div | ||
className={cx('DateRangePickerInput', { | ||
'DateRangePickerInput--disabled': disabled, | ||
})} | ||
> | ||
{(showDefaultInputIcon || customInputIcon !== null) && |
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.
nit this could just be (showDefaultInputIcon || customInputIcon)
Changes Unknown when pulling 2077332 on getaroom:add-calendar-icon into ** on airbnb:master**. |
@cgriego requested the addition of a calendar icon to the date range picker. Simple boolean to enable, default is disabled. Interaction is the same as a focus of the start date. Rename `showCalendarIcon` to `showInputIcon` and add `customInputIcon` At the request of the project members I have added the prop `customInputIcon` and as it can now show more than just a calendar icon, it was sensible to rename the prop to `showInputIcon`. Making requested changes. showInputIcon to showDefaultInputIcon. display default icon unless custom icon is given.
2077332
to
2e1e6b8
Compare
I needed a simple icon added to the beginning of the Date Range Picker. And I thought that others might also like a simple decoration / interaction point.
showCalendarIcon defaults to false, added using
Interaction uses
onStartDateFocus
Calendar Icon was extracted from font-awesome 4.7.0 licensing is fully open source, http://fontawesome.io/license/
Added storybook entry, Readme entry and tests.