index.js
25 lines
| 1 | import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; |
| 2 | import {toUniqueId} from '../../utils'; |
| 3 | |
| 4 | import './style.scss'; |
| 5 | |
| 6 | const TextControl = ({label = null, value = '', onChange = null, icon = null, type = 'text'}) => { |
| 7 | const id = toUniqueId(label); |
| 8 | |
| 9 | return ( |
| 10 | <div className="give-donor-dashboard-text-control"> |
| 11 | {label && ( |
| 12 | <label className="give-donor-dashboard-text-control__label" htmlFor={id}> |
| 13 | {label} |
| 14 | </label> |
| 15 | )} |
| 16 | <div className="give-donor-dashboard-text-control__input"> |
| 17 | {icon && <FontAwesomeIcon icon={icon} />} |
| 18 | <input id={id} type={type} value={value} onChange={(evt) => onChange(evt.target.value)} /> |
| 19 | </div> |
| 20 | </div> |
| 21 | ); |
| 22 | }; |
| 23 | |
| 24 | export default TextControl; |
| 25 |