Skip to content
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

Merged
merged 1 commit into from Mar 31, 2017
Merged

Conversation

moonboots
Copy link
Collaborator

to: @majapw @ljharb

Continuation of Maja's original PR to add customizable daySize's. I rebased and inlined a 39 + 1 calculation to 40 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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 87.437% when pulling 6dfdab4 on moonboots:maja-add-calendarday-size-prop into b90ee78 on airbnb:master.

@moonboots moonboots force-pushed the maja-add-calendarday-size-prop branch from 6dfdab4 to e218f00 Compare March 27, 2017 21:34
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 87.406% when pulling e218f00 on moonboots:maja-add-calendarday-size-prop into b90ee78 on airbnb:master.

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, but maybe we should create a constants file since we have a magic number all over the place rn.

Also things don't quite seem aligned. Can you investigate the right padding on this screenshot?
screen shot 2017-03-30 at 10 56 46 am

@@ -17,6 +18,7 @@ const propTypes = forbidExtraProps({

const defaultProps = {
day: moment(),
daySize: 40,
Copy link
Collaborator

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.

@moonboots
Copy link
Collaborator Author

Thanks @majapw, extracted DAY_SIZE into a constant fixed the right padding calc

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 87.421% when pulling 2b1d9ff on moonboots:maja-add-calendarday-size-prop into f1cee85 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 87.421% when pulling 2b1d9ff on moonboots:maja-add-calendarday-size-prop into f1cee85 on airbnb:master.

Copy link
Member

@ljharb ljharb left a 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?

@@ -25,6 +26,7 @@ const propTypes = forbidExtraProps({
enableOutsideDays: PropTypes.bool,
modifiers: PropTypes.object,
orientation: ScrollableOrientationShape,
daySize: PropTypes.number,
Copy link
Member

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.

Copy link
Collaborator

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.

@@ -33,6 +35,7 @@ const propTypes = forbidExtraProps({
onMonthTransitionEnd: PropTypes.func,
renderDay: PropTypes.func,
transformValue: PropTypes.string,
daySize: PropTypes.number,
Copy link
Member

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.

Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator

@majapw majapw Mar 31, 2017

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.

@@ -38,6 +39,7 @@ const propTypes = forbidExtraProps({
hidden: PropTypes.bool,
initialVisibleMonth: PropTypes.func,
renderCalendarInfo: PropTypes.func,
daySize: PropTypes.number,
Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@@ -35,10 +35,12 @@ export default {
keepOpenOnDateSelect: PropTypes.bool,
reopenPickerOnClearDate: PropTypes.bool,
renderCalendarInfo: PropTypes.func,
daySize: PropTypes.number,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@moonboots
Copy link
Collaborator Author

@majapw @ljharb Updated with nonNegativeNumber, deferred the proptype crunch, ptal

@moonboots moonboots force-pushed the maja-add-calendarday-size-prop branch from 2b1d9ff to 553e126 Compare March 31, 2017 20:15
Copy link
Collaborator

@majapw majapw left a 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,
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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,
Copy link
Collaborator

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()?

Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Great. :)

Copy link
Member

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 :-)

Copy link

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

Copy link
Member

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/airbnb-prop-types@2.8.0/src/nonNegativeInteger.js

Copy link
Member

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?

Copy link
Member

@ljharb ljharb left a 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,
Copy link
Member

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 :-)

@moonboots moonboots force-pushed the maja-add-calendarday-size-prop branch 2 times, most recently from fc8272c to cbe1460 Compare March 31, 2017 21:51
@majapw majapw force-pushed the maja-add-calendarday-size-prop branch 4 times, most recently from f92b63c to b5bbab7 Compare March 31, 2017 22:53
@majapw majapw force-pushed the maja-add-calendarday-size-prop branch from b5bbab7 to 7c51f65 Compare March 31, 2017 23:09
@majapw majapw merged commit 8b6e41c into react-dates:master Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants