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 support for positioning month navigation under the calendar #1784

Merged
merged 7 commits into from
Sep 26, 2019

Conversation

caseklim
Copy link
Collaborator

Summary

Add a variation where the next and previous month navigation links can be positioned below the calendar months.

Screenshots

Default navigation

image

Custom navigation

image

@ljharb ljharb added the semver-minor: new stuff Any feature or API addition. label Sep 16, 2019
/>
)))
.add('with current week range selection', withInfo()(() => (
<DayPickerRangeControllerWrapper
onOutsideClick={action('DayPickerRangeController::onOutsideClick')}
onPrevMonthClick={action('DayPickerRangeController::onPrevMonthClick')}
onNextMonthClick={action('DayPickerRangeController::onNextMonthClick')}
startDateOffset={day => day.startOf('week')}
endDateOffset={day => day.endOf('week')}
startDateOffset={(day) => day.startOf('week')}
Copy link
Member

Choose a reason for hiding this comment

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

this repo hasn't upgraded to the latest styleguide yet, so i believe this change will cause the linter to fail. is your editor set up to eslint autofix, as opposed to (for example) directly running prettier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ljharb yep, it's set up to autofix 🤦‍♀ I noticed the CI failed immediately on several lint errors

Copy link
Member

Choose a reason for hiding this comment

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

odd; if it's using a local eslint then it shouldn't produce this change (but using a global one, it might)

either way, easy fix :-)

@coveralls
Copy link

coveralls commented Sep 16, 2019

Coverage Status

Coverage increased (+0.03%) to 85.036% when pulling 13fec10 on bottom-nav-position into c588a9d on master.

@@ -0,0 +1,2 @@
{
}
Copy link
Member

Choose a reason for hiding this comment

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

mistakenly added?

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.

Overall this looks great; very straightforward.

It doesn't really make sense to add tests for the styling, but it would be good to add tests that use this prop on all components where it's added, to ensure no regressions in the future.

@caseklim
Copy link
Collaborator Author

@ljharb added more variations to components that already had one for custom navigation, let me know if you think I should add others!

@@ -219,6 +230,12 @@ export default withStyles(({ reactDates: { color, zIndex } }) => ({
zIndex: zIndex + 2,
},

DayPickerNavigation__bottom: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ljharb I tried to avoid adding any styles that implicate layout to DayPickerNavigation for custom navigation, but this was the best I could think to come up with since any absolutely positioned children will be taken out of the flow—and then there won't be enough space under the calendar. any thoughts on this?

@ljharb
Copy link
Member

ljharb commented Sep 17, 2019

@caseklim sorry i wasn't clear; stories in this repo aren't tested variations, so they don't actually gate any merges afaik (the karma jobs are often flaky). we'd need actual unit tests to be able to reliably prevent regressions. More stories are great tho!

@@ -219,6 +230,12 @@ export default withStyles(({ reactDates: { color, zIndex } }) => ({
zIndex: zIndex + 2,
},

DayPickerNavigation__bottom: {
display: 'flex',
Copy link
Member

Choose a reason for hiding this comment

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

hmm - adding flexbox is a breaking change; it's not currently used anywhere in this repo, and react-dates has wider browser support than airbnb itself. is this something that could be overridden in an internal theme, and a different default selected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's only for this use case of bottom navigation, so it won't be added to any other uses. I tried the non-flexbox workaround and couldn't get it working 😭 do we have any instances of using a theme in this repo other than a bunch of props? I could add dayPickerNavigationStyles or something like that...

Copy link
Member

Choose a reason for hiding this comment

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

no, but airbnb uses its own theme and doesn't use this default one, afaik, so as long as there's any kind of workaround, that could go here and airbnb could use the flex styling.

i suppose since it's opt in, it wouldn't actually be a breaking change, but it would likely trigger bug reports that we'd have no way to fix :-/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmm it doesn't seem like this is something that would fit into a theme?
https://github.com/airbnb/react-dates/blob/master/src/theme/DefaultTheme.js

what do you think about dayPickerNavigationStyles? I was trying to avoid going through the hassle of adding another new prop but that's the only reasonable thing I can think to make it work in the default and non-default cases...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

went ahead and added that—let me know what you think :)

@caseklim
Copy link
Collaborator Author

@ljharb ahhh didn't see the unit tests before! will add to that

styles.DayPickerNavigation__bottom,
isDefaultNav && styles.DayPickerNavigation__bottomDefault,
] : []),
hasCustomStyles && customStyles,
Copy link
Member

Choose a reason for hiding this comment

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

:-/ this allows full customization of all CSS, which is typically something we've avoided allowing.

cc @majapw @noratarano; do you think there's a way we could solve this with theming, or find a non-flex fallback?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ahhh I see 😢 @majapw @noratarano happy to sit down with you in person on Thursday if that's easier to walk through the issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ljharb I chatted with @noratarano and we feel that using inline styles (renamed to inlineStyles vs. customStyles) is the best option here given the implementation and timeline constraints. wdyt of leaving this as-is? if you're okay with this I noticed that coverage dropped, I'll make sure to up that percentage by adding more tests.

Copy link
Member

Choose a reason for hiding this comment

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

It’s certainly not my call, but i think allowing unrestricted styling is a major philosophical departure from both external (and to a lesser extent, internal) policies thus far.

@caseklim caseklim force-pushed the bottom-nav-position branch 2 times, most recently from b49abe0 to a1bf0c4 Compare September 19, 2019 21:01
Copy link
Contributor

@noratarano noratarano left a comment

Choose a reason for hiding this comment

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

Seems like there's a conflict, but this looks great! 👍

@noratarano noratarano merged commit bf31594 into master Sep 26, 2019
@noratarano noratarano deleted the bottom-nav-position branch September 26, 2019 21:01
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.

4 participants