Skip to content

TextField - 'errorColor' prop #915

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

Merged
merged 1 commit into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export default class InputsScreen extends Component {
placeholder="Underline colors & error"
onChangeText={this.onChangeText}
error={this.state.error}
underlineColor={{focus: Colors.purple50, error: Colors.yellow60}}
underlineColor={{focus: Colors.purple50, error: Colors.orange60}}
errorColor={Colors.orange60}
/>

<TextField
Expand Down
9 changes: 7 additions & 2 deletions src/components/textField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export default class TextField extends BaseInput {
* should the input component support error messages
*/
enableErrors: PropTypes.bool,
/**
* input error message's text color
*/
errorColor: PropTypes.string,
/**
* should the input expand to another text area modal
*/
Expand Down Expand Up @@ -475,14 +479,15 @@ export default class TextField extends BaseInput {
}

renderError(visible) {
const {enableErrors, useTopErrors} = this.getThemeProps();
const {enableErrors, useTopErrors, errorColor} = this.getThemeProps();
const textColor = errorColor ? {color: errorColor} : undefined;
const positionStyle = useTopErrors ? this.styles.topLabel : this.styles.bottomLabel;
const error = this.getErrorMessage();

if (visible && enableErrors) {
return (
<Text
style={[this.styles.errorMessage, this.styles.label, positionStyle]}
style={[this.styles.errorMessage, this.styles.label, positionStyle, textColor]}
accessible={!_.isEmpty(error) && !useTopErrors}
>
{error}
Expand Down