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

add hovered-start-blocked-minimun-nights and hovered-start-first-possible-end modifiers #1547

Conversation

nkinser
Copy link
Contributor

@nkinser nkinser commented Feb 15, 2019

This PR adds two new modifiers, hovered-start-blocked-minimum-nights and hovered-start-first-possible-end, which, when focusedInput is START_DATE, keep track of the days blocked by the minimum nights requirement and the first possible end date for the hovered day. This makes the user aware of the minimum nights requirement before even clicking on the day.
I added the getMinNightsForHoverDate function to the props because in my case it is possible for the min nights requirement for the hovered date to be different from the one passed in as the minimumNights prop.

I originally intended to make a more generic modifier similar to highlighted-calendar where the user could supply the function used to determine if the day should have the modifier applied to it, but it was too computationally heavy to call this function on every visible day every time the hover day changed.

Gif of change:

hovered-start-modifiers

Reviewers:

@majapw @ljharb

@coveralls
Copy link

coveralls commented Feb 15, 2019

Coverage Status

Coverage decreased (-0.006%) to 84.486% when pulling 99135fe on nkinser:nk--add-modifier-for-styles-depending-on-hovered-day into ea0cf80 on airbnb:master.

@nkinser nkinser requested review from majapw and ljharb February 15, 2019 03:44
@nkinser
Copy link
Contributor Author

nkinser commented Feb 19, 2019

@majapw @ljharb Can you please review? Thanks!

@nkinser
Copy link
Contributor Author

nkinser commented Feb 19, 2019

@TaeKimJR @noratarano @monokrome Can you also please take a look? Thanks!

@ljharb ljharb added the semver-minor: new stuff Any feature or API addition. label Feb 19, 2019
@nkinser nkinser force-pushed the nk--add-modifier-for-styles-depending-on-hovered-day branch 2 times, most recently from 7fb6fb3 to 49c6582 Compare February 27, 2019 20:21
@nkinser
Copy link
Contributor Author

nkinser commented Feb 27, 2019

@ljharb @majapw Pinging you if you'd like to take another look because I've made some changes.
Now the modifiers aren't applied when the hovered date is blocked.

it('does not call addModifierToRange with `hovered-start-blocked-minimum-nights` if the hovered date is blocked', () => {
const addModifierToRangeSpy = sinon.spy(DayPickerRangeController.prototype, 'addModifierToRange');
const getMinNightsForHoverDateStub = sinon.stub().returns(2);
const wrapper = shallow(<DayPickerRangeController
Copy link
Member

Choose a reason for hiding this comment

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

a ( should end the line here

{...props}
getMinNightsForHoverDate={getMinNightsForHoverDateStub}
isDayBlocked={day => isSameDay(day, today)}
/>);
Copy link
Member

Choose a reason for hiding this comment

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

and ) should begin one

@@ -0,0 +1 @@
{"value":{"success":true,"data":{"next":{"version":"5.0.0-rc.6","info":{"plain":"### Bug Fixes\n\n* Addon-actions: FIX performance by upgrading to telejson 2.1 ([#5751](https://github.com/storybooks/storybook/pull/5751))\n* UI: FIX bad treeview mockdata ([#5741](https://github.com/storybooks/storybook/pull/5741))\n* UI: About page styling fixes ([#5732](https://github.com/storybooks/storybook/pull/5732))\n* UI: Restore the toolbar eject button ([#5737](https://github.com/storybooks/storybook/pull/5737))"}},"latest":{"version":"4.1.13","info":{"plain":"### Documentation\n\n* Fix unkind addon-ondevice-knobs readme. ([#5629](https://github.com/storybooks/storybook/pull/5629))\n\n### Maintenance\n\n* Cleanup CLI version notice ([#5699](https://github.com/storybooks/storybook/pull/5699))\n* Use static versions.json file instead of hacking one in ([#5675](https://github.com/storybooks/storybook/pull/5675))"}}},"time":1551291194564},"type":"Object"}
Copy link
Member

Choose a reason for hiding this comment

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

revert?

@nkinser nkinser force-pushed the nk--add-modifier-for-styles-depending-on-hovered-day branch from 53dd10f to 3a5bfe6 Compare February 27, 2019 22:31
@nkinser nkinser force-pushed the nk--add-modifier-for-styles-depending-on-hovered-day branch from 3a5bfe6 to 99135fe Compare February 27, 2019 22:39
@nkinser nkinser merged commit b41c347 into react-dates:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor: new stuff Any feature or API addition.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants