-
-
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
DaySize update #406
DaySize update #406
Conversation
6dfdab4
to
e218f00
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.
src/components/CalendarDay.jsx
Outdated
@@ -17,6 +18,7 @@ const propTypes = forbidExtraProps({ | |||
|
|||
const defaultProps = { | |||
day: moment(), | |||
daySize: 40, |
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 start like a theme constants file? We're going to grow the random numbers that we have and this default gets used throughout the tree.
47b5eb3
to
2b1d9ff
Compare
Thanks @majapw, extracted |
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 this potentially be semver-major because of the css changes?
src/components/CalendarMonth.jsx
Outdated
@@ -25,6 +26,7 @@ const propTypes = forbidExtraProps({ | |||
enableOutsideDays: PropTypes.bool, | |||
modifiers: PropTypes.object, | |||
orientation: ScrollableOrientationShape, | |||
daySize: PropTypes.number, |
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 this allow any number, or only a positive integer? If the latter, let's use airbnb-prop-types to restrict 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.
i concur. airbnb-prop-types is already available to you.
src/components/CalendarMonthGrid.jsx
Outdated
@@ -33,6 +35,7 @@ const propTypes = forbidExtraProps({ | |||
onMonthTransitionEnd: PropTypes.func, | |||
renderDay: PropTypes.func, | |||
transformValue: PropTypes.string, | |||
daySize: PropTypes.number, |
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.
Since this propType definition appears in multiple places, let's use a shared one so the source of truth only lives in one place.
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.
Isn't that true of like... 90% of react-dates proptypes though?
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.
yes, and ideally they'd be imported all from one place too - my personal preference is to export it from the leaf-est component that needs 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.
I think that is clean up that we could do all at once in a follow up PR.
src/components/DayPicker.jsx
Outdated
@@ -38,6 +39,7 @@ const propTypes = forbidExtraProps({ | |||
hidden: PropTypes.bool, | |||
initialVisibleMonth: PropTypes.func, | |||
renderCalendarInfo: PropTypes.func, | |||
daySize: PropTypes.number, |
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.
also here
@@ -43,6 +44,7 @@ const propTypes = forbidExtraProps({ | |||
orientation: ScrollableOrientationShape, | |||
withPortal: PropTypes.bool, | |||
initialVisibleMonth: PropTypes.func, | |||
daySize: PropTypes.number, |
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 here
src/shapes/SingleDatePickerShape.js
Outdated
@@ -35,10 +35,12 @@ export default { | |||
keepOpenOnDateSelect: PropTypes.bool, | |||
reopenPickerOnClearDate: PropTypes.bool, | |||
renderCalendarInfo: PropTypes.func, | |||
daySize: PropTypes.number, |
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 here
2b1d9ff
to
553e126
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.
Did you ever look into the weird padding issue?
@@ -11,4 +11,6 @@ module.exports = { | |||
|
|||
ANCHOR_LEFT: 'left', | |||
ANCHOR_RIGHT: 'right', | |||
|
|||
DAY_SIZE: 39, |
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.
Didn't you change this one to 40?
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.
40
was a mistake when I misinterpreted the getCalendarMonthWidth
logic. It was causing the missing right padding you pointed out.
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.
Wonderful.
@@ -25,6 +26,7 @@ const propTypes = forbidExtraProps({ | |||
enableOutsideDays: PropTypes.bool, | |||
modifiers: PropTypes.object, | |||
orientation: ScrollableOrientationShape, | |||
daySize: nonNegativeInteger, |
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 you double-check that this doesn't need to be nonNegativeInteger()
?
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.
Tested with daySize={-1}
, nonNegativeInteger
without extra function invocation correctly prints to console.error
.
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.
Oh! Great. :)
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.
thats an omission in airbnb-prop-types, which i'll fix in the next semver-major :-)
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.
@majapw @ljharb I think this does need to be nonNegativeInteger(). This leads to a lot of warnings for me, of the form:
Warning: CalendarDay: type specification of prop `daySize` is invalid; the type checker function must return `null` or an `Error` but returned a function. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).
I have opened a PR to fix this issue: #664
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.
in fact nonNegativeInteger isn't thunkified, so this is correct as-is https://unpkg.com/[email protected]/src/nonNegativeInteger.js
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.
@palashkaria what version of react are you using?
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 concerns have been addressed
@@ -25,6 +26,7 @@ const propTypes = forbidExtraProps({ | |||
enableOutsideDays: PropTypes.bool, | |||
modifiers: PropTypes.object, | |||
orientation: ScrollableOrientationShape, | |||
daySize: nonNegativeInteger, |
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.
thats an omission in airbnb-prop-types, which i'll fix in the next semver-major :-)
fc8272c
to
cbe1460
Compare
f92b63c
to
b5bbab7
Compare
b5bbab7
to
7c51f65
Compare
to: @majapw @ljharb
Continuation of Maja's original PR to add customizable daySize's. I rebased and inlined a
39 + 1
calculation to40
daySize default for a slightly cleaner number.I punted on my request to make the padding configurable as well. It's on of a few remaining hardcoded sizes, and I think we can revisit with a more general solution like sizing with pure css. On this topic, is there any sizing logic that strictly requires js? I think the transition animation should be doable without knowing pixel sizes in js, e.g. using translate
-100%
.This current version should be sufficient for our use, so PTAL.