Skip to content

Commit

Permalink
Merge pull request #1895 from rhays-turo/f/support_no_nav_buttons_in_…
Browse files Browse the repository at this point in the history
…DayPickerSingleDateController

feature(DayPickerSingleDateController) Add support for noNavButtons (match DayPickerRangeController support)
  • Loading branch information
nkinser committed Jan 13, 2020
2 parents 9ebad7f + 89a5c97 commit 72f3c1f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/DayPickerSingleDateController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const propTypes = forbidExtraProps({
navNext: PropTypes.node,
renderNavPrevButton: PropTypes.func,
renderNavNextButton: PropTypes.func,
noNavButtons: PropTypes.bool,

onPrevMonthClick: PropTypes.func,
onNextMonthClick: PropTypes.func,
Expand Down Expand Up @@ -131,6 +132,7 @@ const defaultProps = {
navNext: null,
renderNavPrevButton: null,
renderNavNextButton: null,
noNavButtons: false,

onPrevMonthClick() {},
onNextMonthClick() {},
Expand Down Expand Up @@ -608,6 +610,7 @@ export default class DayPickerSingleDateController extends React.PureComponent {
navNext,
renderNavPrevButton,
renderNavNextButton,
noNavButtons,
onOutsideClick,
onShiftTab,
onTab,
Expand Down Expand Up @@ -666,6 +669,7 @@ export default class DayPickerSingleDateController extends React.PureComponent {
navNext={navNext}
renderNavPrevButton={renderNavPrevButton}
renderNavNextButton={renderNavNextButton}
noNavButtons={noNavButtons}
renderMonthText={renderMonthText}
renderWeekHeaderElement={renderWeekHeaderElement}
renderCalendarDay={renderCalendarDay}
Expand Down
6 changes: 6 additions & 0 deletions stories/DayPickerSingleDateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,10 @@ storiesOf('DayPickerSingleDateController', module)
onNextMonthClick={action('DayPickerSingleDateController::onNextMonthClick')}
verticalBorderSpacing={16}
/>
)))
.add('with no nav buttons', withInfo()(() => (
<DayPickerSingleDateControllerWrapper
onOutsideClick={action('DayPickerSingleDateController::onOutsideClick')}
noNavButtons
/>
)));
13 changes: 13 additions & 0 deletions test/components/DayPickerSingleDateController_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import moment from 'moment';

import DayPicker from '../../src/components/DayPicker';
import DayPickerSingleDateController from '../../src/components/DayPickerSingleDateController';
import DayPickerNavigation from '../../src/components/DayPickerNavigation';

import toISODateString from '../../src/utils/toISODateString';
import toISOMonthString from '../../src/utils/toISOMonthString';
Expand Down Expand Up @@ -1564,5 +1565,17 @@ describe('DayPickerSingleDateController', () => {
expect(dayPicker.props().initialVisibleMonth().isSame(today, 'day')).to.equal(true);
});
});

describe('noNavButtons prop', () => {
it('renders navigation button', () => {
const wrapper = shallow(<DayPickerSingleDateController />).dive().dive();
expect(wrapper.find(DayPickerNavigation)).to.have.lengthOf(1);
});

it('does not render navigation button when noNavButtons prop applied', () => {
const wrapper = shallow(<DayPickerSingleDateController noNavButtons />).dive().dive();
expect(wrapper.find(DayPickerNavigation)).to.have.lengthOf(0);
});
});
});
});

0 comments on commit 72f3c1f

Please sign in to comment.