-
-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,7 @@ class CalendarMonthGrid extends React.Component { | |
isFocused, | ||
isRTL, | ||
styles, | ||
theme: { reactDates: theme }, | ||
phrases, | ||
dayAriaLabelFormat, | ||
transitionDuration, | ||
|
@@ -272,7 +273,10 @@ class CalendarMonthGrid extends React.Component { | |
const isVerticalScrollable = orientation === VERTICAL_SCROLLABLE; | ||
const isHorizontal = orientation === HORIZONTAL_ORIENTATION; | ||
|
||
const calendarMonthWidth = getCalendarMonthWidth(daySize); | ||
const calendarMonthWidth = getCalendarMonthWidth( | ||
daySize, | ||
theme.spacing.calendarMonthHorizontalPadding, | ||
); | ||
|
||
const width = isVertical || isVerticalScrollable | ||
? calendarMonthWidth | ||
|
@@ -363,7 +367,14 @@ class CalendarMonthGrid extends React.Component { | |
CalendarMonthGrid.propTypes = propTypes; | ||
CalendarMonthGrid.defaultProps = defaultProps; | ||
|
||
export default withStyles(({ reactDates: { color, zIndex } }) => ({ | ||
export default withStyles(({ | ||
reactDates: { | ||
color, | ||
noScrollBarOnVerticalScrollable, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
spacing, | ||
zIndex, | ||
}, | ||
}) => ({ | ||
CalendarMonthGrid: { | ||
background: color.background, | ||
textAlign: 'left', | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I think this makes sense in the theme. |
||
}, | ||
|
||
CalendarMonthGrid__vertical: { | ||
|
@@ -386,6 +397,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 commentThe 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? |
||
'-webkitOverflowScrolling': 'touch', | ||
'::-webkit-scrollbar': { | ||
'-webkit-appearance': 'none', | ||
display: 'none', | ||
}, | ||
}, | ||
}, | ||
|
||
CalendarMonthGrid_month__horizontal: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ import { | |
} from '../constants'; | ||
|
||
const MONTH_PADDING = 23; | ||
const DAY_PICKER_PADDING = 9; | ||
const PREV_TRANSITION = 'prev'; | ||
const NEXT_TRANSITION = 'next'; | ||
const MONTH_SELECTION_TRANSITION = 'month_selection'; | ||
|
@@ -173,8 +172,10 @@ class DayPicker extends React.Component { | |
focusedDate = props.getFirstFocusableDay(currentMonth); | ||
} | ||
|
||
const { reactDates: { spacing: { calendarMonthHorizontalPadding } } } = props.theme; | ||
|
||
const translationValue = props.isRTL && this.isHorizontal() | ||
? -getCalendarMonthWidth(props.daySize) | ||
? -getCalendarMonthWidth(props.daySize, calendarMonthHorizontalPadding) | ||
: 0; | ||
|
||
this.hasSetInitialVisibleMonth = !props.hidden; | ||
|
@@ -183,7 +184,7 @@ class DayPicker extends React.Component { | |
monthTransition: null, | ||
translationValue, | ||
scrollableMonthMultiple: 1, | ||
calendarMonthWidth: getCalendarMonthWidth(props.daySize), | ||
calendarMonthWidth: getCalendarMonthWidth(props.daySize, calendarMonthHorizontalPadding), | ||
focusedDate: (!props.hidden || props.isFocused) ? focusedDate : null, | ||
nextFocusedDate: null, | ||
showKeyboardShortcuts: props.showKeyboardShortcuts, | ||
|
@@ -240,6 +241,7 @@ class DayPicker extends React.Component { | |
showKeyboardShortcuts, | ||
onBlur, | ||
renderMonthText, | ||
theme: { reactDates: { spacing: calendarMonthHorizontalPadding } }, | ||
} = nextProps; | ||
const { currentMonth } = this.state; | ||
|
||
|
@@ -260,7 +262,8 @@ class DayPicker extends React.Component { | |
|
||
if (nextProps.daySize !== daySize) { | ||
this.setState({ | ||
calendarMonthWidth: getCalendarMonthWidth(nextProps.daySize), | ||
calendarMonthWidth: | ||
getCalendarMonthWidth(nextProps.daySize, calendarMonthHorizontalPadding), | ||
}); | ||
} | ||
|
||
|
@@ -899,6 +902,7 @@ class DayPicker extends React.Component { | |
isFocused, | ||
isRTL, | ||
styles, | ||
theme, | ||
phrases, | ||
verticalHeight, | ||
dayAriaLabelFormat, | ||
|
@@ -907,6 +911,8 @@ class DayPicker extends React.Component { | |
verticalBorderSpacing, | ||
} = this.props; | ||
|
||
const { reactDates: { spacing: { dayPickerHorizontalPadding } } } = theme; | ||
|
||
const isHorizontal = this.isHorizontal(); | ||
|
||
const numOfWeekHeaders = this.isVertical() ? 1 : numberOfMonths; | ||
|
@@ -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 commentThe 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 commentThe 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: |
||
// Adding `1px` because of whitespace between 2 inline-block | ||
const fullHorizontalWidth = wrapperHorizontalWidth + calendarInfoPanelWidth + 1; | ||
|
||
|
@@ -1093,7 +1100,12 @@ DayPicker.propTypes = propTypes; | |
DayPicker.defaultProps = defaultProps; | ||
|
||
export { DayPicker as PureDayPicker }; | ||
export default withStyles(({ reactDates: { color, font, zIndex } }) => ({ | ||
|
||
export default withStyles(({ | ||
reactDates: { | ||
color, font, noScrollBarOnVerticalScrollable, spacing, zIndex, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. +1, see #1298 (comment) |
||
}, | ||
}) => ({ | ||
DayPicker: { | ||
background: color.background, | ||
position: 'relative', | ||
|
@@ -1147,15 +1159,15 @@ export default withStyles(({ reactDates: { color, font, zIndex } }) => ({ | |
}, | ||
|
||
DayPicker_weekHeaders__horizontal: { | ||
marginLeft: 9, | ||
marginLeft: spacing.dayPickerHorizontalPadding, | ||
}, | ||
|
||
DayPicker_weekHeader: { | ||
color: color.placeholderText, | ||
position: 'absolute', | ||
top: 62, | ||
zIndex: zIndex + 2, | ||
padding: '0 13px', | ||
padding: `0 ${spacing.calendarMonthHorizontalPadding}px`, | ||
textAlign: 'left', | ||
}, | ||
|
||
|
@@ -1210,5 +1222,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 commentThe reason will be displayed to describe this comment to others. Learn more. also parens here? |
||
'-webkitOverflowScrolling': 'touch', | ||
'::-webkit-scrollbar': { | ||
'-webkit-appearance': 'none', | ||
display: 'none', | ||
}, | ||
}, | ||
}, | ||
}))(DayPicker); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
const CALENDAR_MONTH_PADDING = 9; | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This makes way more sense :P |
||
} |
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 ithorizontalMonthPadding
to align withverticalSpacing
andverticalHeight
props.