Created
August 1, 2018 16:42
-
-
Save grantglidewell/b5a452420c1ddd26c0e9d29670ec2bf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class NumberFieldType extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
numberInput: "" | |
}; | |
} | |
render() { | |
const { numberInput } = this.state; | |
return ( | |
<article | |
className={`${styles.NumberFieldType} ${ | |
numberInput.length > this.props.charCount ? styles.Error : "" | |
}`} | |
> | |
<div className={styles.NumberFieldTypeLabel}> | |
<label>{this.props.label}</label> | |
<span> | |
{numberInput.length}/{this.props.charCount} | |
</span> | |
</div> | |
<Input type="number" onChange={this.onChange} value={numberInput} /> | |
</article> | |
); | |
} | |
onChange = evt => { | |
this.setState({ | |
numberInput: evt.target.value | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment