mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 22:01:13 +08:00
27 lines
742 B
JavaScript
27 lines
742 B
JavaScript
import React, {PropTypes} from 'react';
|
|
import styles from './TextField.css';
|
|
|
|
const TextField = ({className, showErrors = false, errorMsg, label, ...props}) => (
|
|
<div className={`${styles.textField} ${className ? className : ''}`}>
|
|
<label htmlFor={props.id}>
|
|
{label}
|
|
</label>
|
|
<input
|
|
className={showErrors && errorMsg ? styles.error : ''}
|
|
name={props.id}
|
|
{...props}
|
|
/>
|
|
{showErrors && errorMsg && <span className={styles.errorMsg}><span className={styles.attention}>!</span>{errorMsg}</span>}
|
|
</div>
|
|
);
|
|
|
|
TextField.propTypes = {
|
|
label: PropTypes.string,
|
|
value: PropTypes.string,
|
|
onChange: PropTypes.func,
|
|
errorMsg: PropTypes.string,
|
|
type: PropTypes.string
|
|
};
|
|
|
|
export default TextField;
|