Skip to content

Commit da5968e

Browse files
committed
Added prop and tests for custom arrow icon
1 parent 0bd7072 commit da5968e

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

src/components/DateRangePicker.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const defaultProps = {
4242
showClearDates: false,
4343
showDefaultInputIcon: false,
4444
customInputIcon: null,
45+
customArrowIcon: null,
4546
disabled: false,
4647
required: false,
4748
reopenPickerOnClearDates: false,
@@ -256,6 +257,7 @@ export default class DateRangePicker extends React.Component {
256257
showClearDates,
257258
showDefaultInputIcon,
258259
customInputIcon,
260+
customArrowIcon,
259261
disabled,
260262
required,
261263
phrases,
@@ -288,6 +290,7 @@ export default class DateRangePicker extends React.Component {
288290
showCaret={!withPortal && !withFullScreenPortal}
289291
showDefaultInputIcon={showDefaultInputIcon}
290292
customInputIcon={customInputIcon}
293+
customArrowIcon={customArrowIcon}
291294
disabled={disabled}
292295
required={required}
293296
reopenPickerOnClearDates={reopenPickerOnClearDates}

src/components/DateRangePickerInput.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const propTypes = {
3636
showCaret: PropTypes.bool,
3737
showDefaultInputIcon: PropTypes.bool,
3838
customInputIcon: PropTypes.node,
39+
customArrowIcon: PropTypes.node,
3940

4041
// i18n
4142
phrases: PropTypes.shape({
@@ -69,6 +70,7 @@ const defaultProps = {
6970
showCaret: false,
7071
showDefaultInputIcon: false,
7172
customInputIcon: null,
73+
customArrowIcon: null,
7274

7375
// i18n
7476
phrases: {
@@ -125,10 +127,12 @@ export default class DateRangePickerInput extends React.Component {
125127
showCaret,
126128
showDefaultInputIcon,
127129
customInputIcon,
130+
customArrowIcon,
128131
phrases,
129132
} = this.props;
130133

131134
const inputIcon = customInputIcon || (<CalendarIcon />);
135+
const arrowIcon = customArrowIcon || (<RightArrow />);
132136

133137
return (
134138
<div
@@ -160,7 +164,7 @@ export default class DateRangePickerInput extends React.Component {
160164
/>
161165

162166
<div className="DateRangePickerInput__arrow">
163-
<RightArrow />
167+
{arrowIcon}
164168
</div>
165169

166170
<DateInput

src/components/DateRangePickerInputController.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const propTypes = {
4141
onDatesChange: PropTypes.func,
4242

4343
customInputIcon: PropTypes.node,
44+
customArrowIcon: PropTypes.node,
4445

4546
// i18n
4647
phrases: PropTypes.shape({
@@ -75,6 +76,7 @@ const defaultProps = {
7576
onDatesChange() {},
7677

7778
customInputIcon: null,
79+
customArrowIcon: null,
7880

7981
// i18n
8082
phrases: {
@@ -197,6 +199,7 @@ export default class DateRangePickerInputWithHandlers extends React.Component {
197199
showCaret,
198200
showDefaultInputIcon,
199201
customInputIcon,
202+
customArrowIcon,
200203
disabled,
201204
required,
202205
phrases,
@@ -224,6 +227,7 @@ export default class DateRangePickerInputWithHandlers extends React.Component {
224227
showCaret={showCaret}
225228
showDefaultInputIcon={showDefaultInputIcon}
226229
customInputIcon={customInputIcon}
230+
customArrowIcon={customArrowIcon}
227231
phrases={phrases}
228232
onStartDateChange={this.onStartDateChange}
229233
onStartDateFocus={this.onStartDateFocus}

stories/DateRangePicker.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ const TestCustomInputIcon = () => (
7575
</span>
7676
);
7777

78+
const TestCustomArrowIcon = () => (
79+
<span
80+
style={{
81+
border: '1px solid #dce0e0',
82+
backgroundColor: '#fff',
83+
color: '#484848',
84+
padding: '3px',
85+
}}
86+
>
87+
->
88+
</span>
89+
);
90+
7891
class TestWrapper extends React.Component {
7992
constructor(props) {
8093
super(props);
@@ -258,4 +271,9 @@ storiesOf('DateRangePicker', module)
258271
<DateRangePickerWrapper
259272
customInputIcon={<TestCustomInputIcon />}
260273
/>
274+
))
275+
.addWithInfo('with custom arrow icon', () => (
276+
<DateRangePickerWrapper
277+
customArrowIcon={<TestCustomArrowIcon />}
278+
/>
261279
));

test/components/DateRangePickerInput_spec.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ describe('DateRangePickerInput', () => {
107107
});
108108
});
109109

110+
describe('props.customArrowIcon is a React Element', () => {
111+
it('has custom icon', () => {
112+
const wrapper = shallow(
113+
<DateRangePickerInput
114+
customArrowIcon={<span className="custom-arrow-icon" />}
115+
/>);
116+
expect(wrapper.find('.DateRangePickerInput__calendar-icon .custom-arrow-icon'));
117+
});
118+
});
119+
110120
describe('#onClearDatesMouseEnter', () => {
111121
it('sets state.isClearDatesHovered to true', () => {
112122
const wrapper = shallow(<DateRangePickerInput />);

0 commit comments

Comments
 (0)