-
-
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
Custom Info Panel position #989
Conversation
src/components/DayPicker.jsx
Outdated
ref={this.setCalendarInfoRef} | ||
{...css((calendarInfoIsInline) && styles.DayPicker_calendarInfo__horizontal)} | ||
> | ||
{ renderCalendarInfo() } |
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: jsx curly braces shouldn't have padding spaces inside them
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.
Done
src/components/DayPicker.jsx
Outdated
}; | ||
|
||
const dayPickerStyle = { | ||
width: this.isHorizontal() && fullHorizontalWidth, |
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.
can we cache the isHorizontal
result in a var, so we don't have to call the function multiple times?
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.
Done.. but the function is called at other different places in the code... Will it be better to cache the result in a state?
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.
nah, that would cause a rerender. It's fine to call multiple times conceptually, but it's nice to minimize duplicate function calls within the body of a single function :-)
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.
So, it is okay like that ?
src/components/DayPicker.jsx
Outdated
|
||
// These values are to center the datepicker (approximately) on the page | ||
marginLeft: this.isHorizontal() && withPortal && -fullHorizontalWidth / 2, | ||
marginTop: this.isHorizontal() && withPortal && -calendarMonthWidth / 2, |
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.
rather than overloading &&
for value selection, can these use explicit ternaries?
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 changed it, but for the record, the implicit ternaries were already here before, I only change their position in the 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.
Fair enough :-) thanks for leaving it cleaner than you found 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.
My pleasure ! :)
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 @mariepw, the code for this looks good and I checked out the branch as well.
Two comments:
- Can we default the info position to the bottom so as not to break this for current consumers?
- The height animation seems broken when the info panel is on the left or on the right:
Can you investigate a bit?
Hi @majapw , 1 - Totally right, sorry for the "glitch", I changed the default info position. |
I just found out where the issue is coming from... It is due to the use of |
…" by "before | after" - react-dates#989
I'm still stuck with this problem... When I change :
|
I finally fixed the issue.. |
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 is awesome! Thank you so much. I have two small comments and then I think we're good to go.
Thank you so much for debugging and putting in the work @mariepw! :)
src/components/DayPicker.jsx
Outdated
calendarInfoWidth: calendarInfoPanelWidth, | ||
}); | ||
} | ||
}, 200); |
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.
Should we use transitionDuration
here instead?
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.
Makes sense :) I didn't see the props...
src/components/DayPicker.jsx
Outdated
// The setTimeout will wait until the transition ends. | ||
if (this.calendarInfo) { | ||
const { calendarInfoWidth } = this.state; | ||
this.timeout = setTimeout(() => { |
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.
Can we name this this.setCalendarInfoWidthTimeout
or something else meaningful
Hi @majapw do you know when it will be possible to merge ? |
Sorry @mariepw, it slipped off my radar! :) Let me do a release today. |
Yeeaah for the release, perfect !! Thanks a lot @majapw ! |
Hi @majapw, Hi @ljharb, Hi all,
I implemented the changes proposed in #840 by adding prop 'calendarInfoPosition' to 'SingleDatePicker' and 'DateRangePicker'.
I also directly updated the stories, to test thoses changes.
Thanks.