Skip to content

Commit

Permalink
Add borderless option to the DayPicker variations
Browse files Browse the repository at this point in the history
  • Loading branch information
Maja Wichrowska committed Nov 30, 2017
1 parent 1f35698 commit 2bf6476
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ The following is a list of other *OPTIONAL* props you may provide to the `DayPic
renderCalendarInfo: PropTypes.func,
onOutsideClick: PropTypes.func,
keepOpenOnDateSelect: PropTypes.bool,
noBorder: PropTypes.bool,
// navigation related props
navPrev: PropTypes.node,
Expand Down
12 changes: 9 additions & 3 deletions src/components/DayPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const propTypes = forbidExtraProps({
daySize: nonNegativeInteger,
isRTL: PropTypes.bool,
verticalHeight: nonNegativeInteger,
noBorder: PropTypes.bool,

// navigation props
navPrev: PropTypes.node,
Expand Down Expand Up @@ -102,6 +103,7 @@ export const defaultProps = {
daySize: DAY_SIZE,
isRTL: false,
verticalHeight: null,
noBorder: false,

// navigation props
navPrev: null,
Expand Down Expand Up @@ -688,6 +690,7 @@ class DayPicker extends React.Component {
phrases,
verticalHeight,
dayAriaLabelFormat,
noBorder,
} = this.props;

const numOfWeekHeaders = this.isVertical() ? 1 : numberOfMonths;
Expand Down Expand Up @@ -748,6 +751,7 @@ class DayPicker extends React.Component {
this.isVertical() && withPortal && styles.DayPicker_portal__vertical,
dayPickerStyle,
!hasSetHeight && styles.DayPicker__hidden,
!noBorder && styles.DayPicker__withBorder,
)}
>
<OutsideClickHandler onOutsideClick={onOutsideClick}>
Expand Down Expand Up @@ -780,7 +784,6 @@ class DayPicker extends React.Component {
this.isVertical() && styles.DayPicker_transitionContainer__vertical,
verticalScrollable && styles.DayPicker_transitionContainer__verticalScrollable,
transitionContainerStyle,

)}
ref={this.setTransitionContainerRef}
>
Expand Down Expand Up @@ -844,8 +847,6 @@ export default withStyles(({ reactDates: { color, zIndex } }) => ({

DayPicker__horizontal: {
background: color.background,
boxShadow: '0 2px 6px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.07)',
borderRadius: 3,
},

DayPicker__verticalScrollable: {
Expand All @@ -856,6 +857,11 @@ export default withStyles(({ reactDates: { color, zIndex } }) => ({
visibility: 'hidden',
},

DayPicker__withBorder: {
boxShadow: '0 2px 6px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.07)',
borderRadius: 3,
},

DayPicker_portal__horizontal: {
boxShadow: 'none',
position: 'absolute',
Expand Down
4 changes: 4 additions & 0 deletions src/components/DayPickerRangeController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const propTypes = forbidExtraProps({
initialVisibleMonth: PropTypes.func,
hideKeyboardShortcutsPanel: PropTypes.bool,
daySize: nonNegativeInteger,
noBorder: PropTypes.bool,

navPrev: PropTypes.node,
navNext: PropTypes.node,
Expand Down Expand Up @@ -121,6 +122,7 @@ const defaultProps = {
renderCalendarInfo: null,
firstDayOfWeek: null,
verticalHeight: null,
noBorder: false,

// accessibility
onBlur() {},
Expand Down Expand Up @@ -904,6 +906,7 @@ export default class DayPickerRangeController extends React.Component {
weekDayFormat,
dayAriaLabelFormat,
verticalHeight,
noBorder,
} = this.props;

const { currentMonth, phrases, visibleDays } = this.state;
Expand Down Expand Up @@ -943,6 +946,7 @@ export default class DayPickerRangeController extends React.Component {
weekDayFormat={weekDayFormat}
dayAriaLabelFormat={dayAriaLabelFormat}
verticalHeight={verticalHeight}
noBorder={noBorder}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/DayPickerSingleDateController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const propTypes = forbidExtraProps({
hideKeyboardShortcutsPanel: PropTypes.bool,
daySize: nonNegativeInteger,
verticalHeight: nonNegativeInteger,
noBorder: PropTypes.bool,

navPrev: PropTypes.node,
navNext: PropTypes.node,
Expand Down Expand Up @@ -102,6 +103,7 @@ const defaultProps = {
firstDayOfWeek: null,
daySize: DAY_SIZE,
verticalHeight: null,
noBorder: false,

navPrev: null,
navNext: null,
Expand Down Expand Up @@ -590,6 +592,7 @@ export default class DayPickerSingleDateController extends React.Component {
showKeyboardShortcuts,
weekDayFormat,
verticalHeight,
noBorder,
} = this.props;

const { currentMonth, visibleDays } = this.state;
Expand Down Expand Up @@ -626,6 +629,7 @@ export default class DayPickerSingleDateController extends React.Component {
weekDayFormat={weekDayFormat}
dayAriaLabelFormat={dayAriaLabelFormat}
verticalHeight={verticalHeight}
noBorder={noBorder}
/>
);

Expand Down
5 changes: 4 additions & 1 deletion stories/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ storiesOf('DayPicker', module)
))
.addWithInfo('with custom week day format', () => (
<DayPicker
weekDayFormat='ddd'
weekDayFormat="ddd"
/>
))
.addWithInfo('noBorder', () => (
<DayPicker noBorder />
));

0 comments on commit 2bf6476

Please sign in to comment.