-
-
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
[vertical scrollable] add spacing and scrollbar theme #1298
Conversation
a6b7134
to
5cfcda4
Compare
src/components/CalendarMonthGrid.jsx
Outdated
@@ -260,6 +260,7 @@ class CalendarMonthGrid extends React.Component { | |||
isFocused, | |||
isRTL, | |||
styles, | |||
theme, |
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.
theme: { reactDates: theme }
?
src/components/CalendarMonthGrid.jsx
Outdated
export default withStyles(({ reactDates: { color, zIndex } }) => ({ | ||
export default withStyles(({ | ||
reactDates: { | ||
color, noScrollBarOnVerticalScrollable, spacing, zIndex, |
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.
each of these needs to be on its own line, if the entire object literal can't fit on one line
64ac9b1
to
2242529
Compare
2242529
to
bc4cae4
Compare
Taking a look now! |
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.
This looks phenom @amhunt!
So I think that the calendarmonth padding should be a prop---but I think I'm making an assumption that it works a certain way when I say that. If you were to set that value to 0 what would it look like? What is the interplay between the month padding and picker padding?
export default withStyles(({ | ||
reactDates: { | ||
color, | ||
noScrollBarOnVerticalScrollable, |
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.
QQ: can you investigate as to whether the scrollbar is an issue on the VERTICAL_ORIENTATION
as well? It may make sense to have noScrollBarOnVertical
be the option
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.
It isn't/if there were an issue, it could be managed outside of the vertical calendar (because the largest div for the vertical calendar is the outermost div, whereas the smaller surrounding div in VERTICAL_SCROLLABLE is the one that's causing the scrollbar to appear).
src/components/CalendarMonthGrid.jsx
Outdated
const calendarMonthWidth = getCalendarMonthWidth(daySize); | ||
const calendarMonthWidth = getCalendarMonthWidth( | ||
daySize, | ||
theme.spacing.calendarMonthHorizontalPadding, |
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.
This is the reason why calendarMonthHorizontalPadding
seems like it could be a prop instead of a theme variable. I get that it's only related to CSS---but because it also influences the animations and open source consumers have asked for this as well, I would maybe make this one a prop. We could call it horizontalMonthPadding
to align with verticalSpacing
and verticalHeight
props.
@@ -376,7 +387,7 @@ export default withStyles(({ reactDates: { color, zIndex } }) => ({ | |||
|
|||
CalendarMonthGrid__horizontal: { | |||
position: 'absolute', | |||
left: 9, | |||
left: spacing.dayPickerHorizontalPadding, |
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 this makes sense in the theme.
@@ -956,7 +962,8 @@ class DayPicker extends React.Component { | |||
: 0; | |||
|
|||
const firstVisibleMonthIndex = this.getFirstVisibleIndex(); | |||
const wrapperHorizontalWidth = (calendarMonthWidth * numberOfMonths) + (2 * DAY_PICKER_PADDING); | |||
const wrapperHorizontalWidth = (calendarMonthWidth * numberOfMonths) | |||
+ (2 * dayPickerHorizontalPadding); |
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.
What do we use this for?
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.
This is the width of the calendar for horizontal orientation. So if the outside padding of the dayPicker is 9 and the calendarMonth padding is 13, then the width of the horizontal calendar would be: 2*9 + 2*((2*13) + width_of_calendar_without_padding)
. Does that answer your question?
src/components/DayPicker.jsx
Outdated
|
||
export default withStyles(({ | ||
reactDates: { | ||
color, font, noScrollBarOnVerticalScrollable, spacing, zIndex, |
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.
nit: I'd prefer these to be on their own lines (for ease of rebasing in the future)
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.
+1, see #1298 (comment)
export default function getCalendarMonthWidth(daySize) { | ||
return (7 * (daySize + 1)) + (2 * (CALENDAR_MONTH_PADDING + 1)); | ||
export default function getCalendarMonthWidth(daySize, calendarMonthPadding) { | ||
return (7 * daySize) + (2 * calendarMonthPadding) + 1; |
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.
This makes way more sense :P
1a98b60
to
d775e60
Compare
@majapw updated :) I made the horizontalMonthPadding a prop. I also removed three styles that didn't have corresponding style objects in My one remaining question - how should I handle the default case? I just set it as default 13 at all levels - or should it be default 13 at the top level and then a required prop below? |
src/components/CalendarMonthGrid.jsx
Outdated
@@ -386,6 +400,13 @@ export default withStyles(({ reactDates: { color, zIndex } }) => ({ | |||
CalendarMonthGrid__vertical_scrollable: { | |||
margin: '0 auto', | |||
overflowY: 'scroll', | |||
...noScrollBarOnVerticalScrollable && { |
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 we add parens here to make it clear that the entire thing is spread, not just the first conditional?
src/components/DayPicker.jsx
Outdated
@@ -260,7 +264,8 @@ class DayPicker extends React.Component { | |||
|
|||
if (nextProps.daySize !== daySize) { | |||
this.setState({ | |||
calendarMonthWidth: getCalendarMonthWidth(nextProps.daySize), | |||
calendarMonthWidth: | |||
getCalendarMonthWidth(nextProps.daySize, horizontalMonthPadding), |
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.
this should be instead formatted like this:
calendarMonthWidth: getCalendarMonthWidth(
nextProps.daySize,
horizontalMonthPadding,
),
src/components/DayPicker.jsx
Outdated
@@ -1210,5 +1231,12 @@ export default withStyles(({ reactDates: { color, font, zIndex } }) => ({ | |||
right: 0, | |||
left: 0, | |||
overflowY: 'scroll', | |||
...noScrollBarOnVerticalScrollable && { |
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 parens here?
d775e60
to
1e674d0
Compare
1e674d0
to
0ec2d72
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.
Love it! :) Thank you so much @amhunt for being patient!
@@ -187,9 +189,7 @@ class CalendarMonth extends React.Component { | |||
<div | |||
{...css( | |||
styles.CalendarMonth, | |||
orientation === HORIZONTAL_ORIENTATION && styles.CalendarMonth__horizontal, | |||
orientation === VERTICAL_ORIENTATION && styles.CalendarMonth__vertical, | |||
verticalScrollable && styles.CalendarMonth__verticalScrollable, |
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.
Hey @amhunt Did these get intentionally removed?
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.
Ah I see below that they don't actually exist :x
This adds three new theme variables, primarily aimed at the vertical scrollable configuration.
I also rewrote the
getCalendarMonthWidth
function because it was using the wrong value (9 instead of 13 in the default case).@majapw @ljharb