Created
August 5, 2017 03:01
-
-
Save sirgallifrey/2b68dad15e5a68007e5bc50acf510ca2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Input from './input'; | |
import Label from './label'; | |
import FormGroup from './form-group'; | |
export default function Field ({children, name, inline, ...props}) { | |
return ( | |
<FormGroup inline={ inline }> | |
<Label inline={ inline } htmlFor={ name }>{ label }</Label> | |
<Input inline={ inline } { ...props } id={ name }> | |
{ children } | |
</Input> | |
</FormGroup> | |
) | |
} |
This file contains hidden or 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
function FormGroup (props) { | |
return ( | |
<div className={`form-group ${inlineClass(props)} ${hasErroClass(props)}`}> | |
{props.children} | |
</div> | |
); | |
} | |
function inlineClass (props) { | |
return props.inline ? 'row' : ''; | |
} | |
function hasErrorClass (props) { | |
return props.meta && props.meta.touched && props.meta.error ? 'has-error' : ''; | |
} |
This file contains hidden or 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
function Input ({name, ...props}) { | |
return ( | |
<div className={inlineClass(props)}> | |
<input { ...props } className="form-control" /> | |
{ children } | |
</div> | |
); | |
} | |
function inlineClass(props) { | |
return props.inline ? 'col-md-10' : ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment