-
-
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
Custom Input Icon--calendar position #627
Changes from 3 commits
0a2d7eb
3430bdf
3a13698
dc12667
8376028
8a62d98
05a0d96
f8c583c
10def22
e572cb4
2195730
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 |
---|---|---|
|
@@ -45,6 +45,7 @@ const propTypes = forbidExtraProps({ | |
readOnly: PropTypes.bool, | ||
showCaret: PropTypes.bool, | ||
showDefaultInputIcon: PropTypes.bool, | ||
showInputIconRight: PropTypes.bool, | ||
customInputIcon: PropTypes.node, | ||
customArrowIcon: PropTypes.node, | ||
customCloseIcon: PropTypes.node, | ||
|
@@ -87,6 +88,7 @@ const defaultProps = { | |
readOnly: false, | ||
showCaret: false, | ||
showDefaultInputIcon: false, | ||
showInputIconRight: false, | ||
customInputIcon: null, | ||
customArrowIcon: null, | ||
customCloseIcon: null, | ||
|
@@ -109,6 +111,7 @@ export default class DateRangePickerInput extends React.Component { | |
|
||
this.onClearDatesMouseEnter = this.onClearDatesMouseEnter.bind(this); | ||
this.onClearDatesMouseLeave = this.onClearDatesMouseLeave.bind(this); | ||
this.renderInputIcon = this.renderInputIcon.bind(this); | ||
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 doesn't need to be bound. |
||
} | ||
|
||
onClearDatesMouseEnter() { | ||
|
@@ -123,6 +126,18 @@ export default class DateRangePickerInput extends React.Component { | |
}); | ||
} | ||
|
||
renderInputIcon(inputIcon) { | ||
return (<button | ||
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. the return (
<button
type="button"
className="DateRangePickerInput__calendar-icon"
disabled={this.props.disabled}
aria-label={this.props.phrases.focusStartDate}
onClick={this.props.onArrowDown}
>
{inputIcon}
</button>
); Also, please destructure all props at the top of the function. |
||
type="button" | ||
className="DateRangePickerInput__calendar-icon" | ||
disabled={this.props.disabled} | ||
aria-label={this.props.phrases.focusStartDate} | ||
onClick={this.props.onArrowDown} | ||
> | ||
{inputIcon} | ||
</button>); | ||
} | ||
|
||
render() { | ||
const { isClearDatesHovered } = this.state; | ||
const { | ||
|
@@ -152,6 +167,7 @@ export default class DateRangePickerInput extends React.Component { | |
readOnly, | ||
showCaret, | ||
showDefaultInputIcon, | ||
showInputIconRight, | ||
customInputIcon, | ||
customArrowIcon, | ||
customCloseIcon, | ||
|
@@ -172,16 +188,9 @@ export default class DateRangePickerInput extends React.Component { | |
'DateRangePickerInput--rtl': isRTL, | ||
})} | ||
> | ||
{(showDefaultInputIcon || customInputIcon !== null) && ( | ||
<button | ||
type="button" | ||
className="DateRangePickerInput__calendar-icon" | ||
disabled={disabled} | ||
aria-label={phrases.focusStartDate} | ||
onClick={onArrowDown} | ||
> | ||
{inputIcon} | ||
</button> | ||
|
||
{(!showInputIconRight && (showDefaultInputIcon || customInputIcon !== null)) && ( | ||
this.renderInputIcon(inputIcon) | ||
)} | ||
|
||
<DateInput | ||
|
@@ -249,6 +258,11 @@ export default class DateRangePickerInput extends React.Component { | |
</div> | ||
</button> | ||
)} | ||
|
||
{(showInputIconRight && (showDefaultInputIcon || customInputIcon !== null)) && ( | ||
this.renderInputIcon(inputIcon) | ||
)} | ||
|
||
</div> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ const propTypes = forbidExtraProps({ | |
showClearDate: PropTypes.bool, | ||
customCloseIcon: PropTypes.node, | ||
showDefaultInputIcon: PropTypes.bool, | ||
showInputIconRight: PropTypes.bool, | ||
customInputIcon: PropTypes.node, | ||
isRTL: PropTypes.bool, | ||
onChange: PropTypes.func, | ||
|
@@ -51,6 +52,7 @@ const defaultProps = { | |
showCaret: false, | ||
showClearDate: false, | ||
showDefaultInputIcon: false, | ||
showInputIconRight: false, | ||
customCloseIcon: null, | ||
customInputIcon: null, | ||
isRTL: false, | ||
|
@@ -75,6 +77,7 @@ export default class SingleDatePickerInput extends React.Component { | |
|
||
this.onClearDateMouseEnter = this.onClearDateMouseEnter.bind(this); | ||
this.onClearDateMouseLeave = this.onClearDateMouseLeave.bind(this); | ||
this.renderInputIcon = this.renderInputIcon.bind(this); | ||
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. doesn't need to be bound |
||
} | ||
|
||
onClearDateMouseEnter() { | ||
|
@@ -89,6 +92,18 @@ export default class SingleDatePickerInput extends React.Component { | |
}); | ||
} | ||
|
||
renderInputIcon(inputIcon) { | ||
return (<button | ||
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. indentation and prop destructuring here also |
||
type="button" | ||
className="SingleDatePickerInput__calendar-icon" | ||
disabled={this.props.disabled} | ||
aria-label={this.props.phrases.focusStartDate} | ||
onClick={this.props.onFocus} | ||
> | ||
{inputIcon} | ||
</button>); | ||
} | ||
|
||
render() { | ||
const { isClearDateHovered } = this.state; | ||
const { | ||
|
@@ -104,6 +119,7 @@ export default class SingleDatePickerInput extends React.Component { | |
showCaret, | ||
showClearDate, | ||
showDefaultInputIcon, | ||
showInputIconRight, | ||
phrases, | ||
onClearDate, | ||
onChange, | ||
|
@@ -127,16 +143,8 @@ export default class SingleDatePickerInput extends React.Component { | |
'SingleDatePickerInput--rtl': isRTL, | ||
})} | ||
> | ||
{(showDefaultInputIcon || customInputIcon !== null) && ( | ||
<button | ||
type="button" | ||
className="SingleDatePickerInput__calendar-icon" | ||
disabled={disabled} | ||
aria-label={phrases.focusStartDate} | ||
onClick={onFocus} | ||
> | ||
{inputIcon} | ||
</button> | ||
{(!showInputIconRight && (showDefaultInputIcon || customInputIcon !== null)) && ( | ||
this.renderInputIcon(inputIcon) | ||
)} | ||
<DateInput | ||
id={id} | ||
|
@@ -174,6 +182,10 @@ export default class SingleDatePickerInput extends React.Component { | |
</div> | ||
</button> | ||
)} | ||
{(showInputIconRight && (showDefaultInputIcon || customInputIcon !== null)) && ( | ||
this.renderInputIcon(inputIcon) | ||
)} | ||
|
||
</div> | ||
); | ||
} | ||
|
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.
Let's avoid using terms like "Right" - in an RTL world, "after" is more appropriate.