Files
talk/client/coral-ui/components/TextField.js
T
2017-02-15 11:50:21 -08:00

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;