-
Notifications
You must be signed in to change notification settings - Fork 9
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
UX-408 Date picker with shortcut panel #94
Conversation
height: rect.height, | ||
}; | ||
} | ||
|
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.
@nahumzs could you review this part? Found a bug in Microsoft Edge and fixed it.
|
||
/** Callback to fire when user select date */ | ||
onSelect: PropTypes.func.isRequired, | ||
|
||
/** Possible date might be selected in moment object */ |
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.
Not sure what this means.
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.
We want to rerender react-date
calendar when the user is typing in the input. This prop is the parsing result(in moment object) from user's input, and I use it to rerender 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.
What makes it possible though? I probably don't mind the name, but this comment is the opportunity to explain that name choice.
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.
maybe predictedDate
? or prediction
?
} | ||
|
||
function renderYearList() { | ||
const SELECTED_YEAR_POSITION = 5; |
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.
What does this 5 mean?
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.
…with-shortcut-panel
height: 0; | ||
overflow: hidden; | ||
`} | ||
|
||
* { | ||
box-sizing: border-box; | ||
font-family: ${tokens.fontFamily.default}; |
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.
Incidental again... but would inherit
work here instead, so this component remains agnostic of the app's typeface?
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 moved font-family: ${tokens.fontFamily.default};
to DatePicker.styles.js
. I think it's good to set the default font-family
otherwise I need to set it in the date picker example in storybook.
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.
Does the component need to be a specific font? Ideally when we switch our apps to use IBM Plex
, this component shouldn't have to be changed. In fact we could use it in different apps with different UI fonts, and the component should adapt. Ideally.
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.
🤔Sure! The only thing is some font doesn't works well with bold
on hover, for example Helvetica Neue
. It will shift a little bit as you said before. IBM Plex
and Lato
doesn't have this issue. I will just use inherit then. I can add the default font in storybook if that looks bad.
packages/DatePicker/src/components/ShortcutPanel/ShortcutPanel.styles.js
Outdated
Show resolved
Hide resolved
packages/DatePicker/src/components/ShortcutPanel/ShortcutPanel.styles.js
Outdated
Show resolved
Hide resolved
…with-shortcut-panel
…with-shortcut-panel
…with-shortcut-panel
I just noticed that moment is a dependency, but shouldn't be a peer-dependency? cc @alexzherdev |
setCurrentMonth(null); | ||
} | ||
keepFocus(); | ||
}, [isVisible]); |
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 think the linter should be warning you that you need to add keepFocus
as part of the arrayDependency isn't?
@@ -220,18 +220,47 @@ class Popover extends React.Component { | |||
this.updateVisibilityAndPositionState(isOpening); | |||
} | |||
|
|||
getBoundingClientRect(el) { |
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 could be a hook, but that scope would be totally out of this PR. seem ok to me.
Hmm did some research. TL;DR yeah let's make it a peerDependency. Unless we're really using some super new features, let's depend on a broad range like I had thought that in this case peerDep would only help ensure one copy of moment was in the tree for bundle size purposes (and not break anything, unlike with React, where two copies could break the app). But turns out that two copies of moment can also cause breakage when you do checks on whether something is a moment object: import moment from 'moment';
moment.isMoment(momentObj); // or momentObj instanceof moment If |
Thanks Alex! Nahum and I also had a small conversion in person. I was asking why not put |
…-panel' into UX-408/Date-picker-with-shortcut-panel
I'd say that's overdoing it. Part of the reason we switched to a monorepo was the ability to have multiple versions of the same component in the tree if we need to—peerDep undoes that. |
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 seems good enough for the first version seems there is a little concern with the prop possibleDate
. Though nobody reply or comment after 13 days, so I will take it as the prop name has a low "giveAFu" value on the thermometer of the reviewers.
🛠 Purpose
Adding shortcut panel to date picker component.
✏️ Notes to Reviewer
humanFormat
for customize spelled out formatDatePicker.Popover
🖥 Screenshots
GIF
Popover bug in Edge:
It was because
getBoundingClientRect
won't returnx
y
in Edge and IE11