Skip to content

Conversation

@jacobdevera
Copy link
Contributor

Description

Refactors Calendar and DatePicker to use momentjs. Attempting to get rid of redundant logic covered by moment.

fixes #703
fixes #550
fixes #493

@jacobdevera jacobdevera self-assigned this Dec 6, 2019
@netlify
Copy link

netlify bot commented Dec 6, 2019

return null;
}

//If range is enabled and the date from the parent component does not match the array dates of the states then states are updated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was one of the hardest parts to deal with. Ideally, this would not be deriving state from props, but mainly wanted to focus on simplifying logic rather than try to overhaul the whole component at once. Hopefully it is at least a bit more readable.

expect(wrapper.state('arrSelectedDates')).toEqual('undefined');
});

test('entering invalid range dates', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DatePicker used to arbitrarily set a limit of 3000 for the year. I do not think we need to impose this limitation now that moment is handling validation.

@jacobdevera jacobdevera requested review from a team and meganaconley December 6, 2019 09:28
});
let formatDate = date[0].format('MM/DD/YYYY');
if (!!date[1]) {
formatDate += '-' + date[1].format('MM/DD/YYYY');
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of hardcoding month/day/year could we use L and set the locale so it's always localized?

@jacobdevera
Copy link
Contributor Author

jacobdevera commented Dec 6, 2019

Bundle size has increased over the 150 KB limit which causes builds to fail.

Package size limit has exceeded by 52.39 KB Size limit: 150 KB Package size: 202.39 KB with all dependencies, minified and gzipped Loading time: 4.1 s on slow 3G Running time: 272 ms on Snapdragon 410 Total time: 4.4 s

Wonder if we should disable some locales, or revert back to consumers manually providing the month/day names.

jbadan
jbadan previously requested changes Dec 9, 2019
Copy link
Contributor

@jbadan jbadan left a comment

Choose a reason for hiding this comment

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

Can you add storybook examples for the logic you updated?

@jbadan
Copy link
Contributor

jbadan commented Dec 9, 2019

Can you see if there's an easy fix as well to cleanup the code examples on the docs site?

Screen Shot 2019-12-09 at 1 47 10 PM
Screen Shot 2019-12-09 at 1 47 15 PM

disablePastDates,
disableFutureDates,
disabledDates
} = this.props;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These props now accept Date objects again instead of moment objects so consumers don't need to worry about importing moment. The Dates are just wrapped in moment inside. This fixes the entire moment objects' props being listed out on the docs site, but the API might actually be better handled this way in the first place.

@jacobdevera jacobdevera requested a review from jbadan December 16, 2019 19:04
@jbadan jbadan dismissed their stale review December 17, 2019 21:01

added storybook + documentation site

@jacobdevera jacobdevera merged commit 01a4c6c into master Dec 17, 2019
@jacobdevera jacobdevera deleted the fix/moment branch December 17, 2019 21:56
@jbadan jbadan restored the fix/moment branch January 2, 2020 18:03
jbadan pushed a commit that referenced this pull request Jan 2, 2020
* fix: use momentjs

* fix: next/prev handling

* fix: use moment in datepicker

* fix: simplify derived state logic

* fix: simplify enabled date logic

* fix: simplify validation logic

* fix: tests

* fix: localization

* fix: increase size limit

* fix: use date objects for props

* chore: calendar stories

* chore: datepicker stories

* chore: locale

* merge

* fix: unnecessary diffs

* fix: visual regression testing
jbadan pushed a commit that referenced this pull request Jan 2, 2020
* fix: use momentjs

* fix: next/prev handling

* fix: use moment in datepicker

* fix: simplify derived state logic

* fix: simplify enabled date logic

* fix: simplify validation logic

* fix: tests

* fix: localization

* fix: increase size limit

* fix: use date objects for props

* chore: calendar stories

* chore: datepicker stories

* chore: locale

* merge

* fix: unnecessary diffs

* fix: visual regression testing
@jbadan jbadan deleted the fix/moment branch February 26, 2020 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants