2020-02-13 19:43:20 -03:00
|
|
|
import React from 'react';
|
2020-03-12 13:26:31 -03:00
|
|
|
import PropTypes from 'prop-types';
|
2020-02-13 19:43:20 -03:00
|
|
|
import Label from '../Label';
|
2020-03-12 13:26:31 -03:00
|
|
|
import classnames from 'classnames';
|
|
|
|
|
|
|
|
|
|
const baseInputClasses =
|
2020-06-26 12:34:43 -03:00
|
|
|
'shadow transition duration-300 appearance-none border border-primary-main hover:border-gray-500 focus:border-gray-500 focus:outline-none rounded w-full py-2 px-3 mt-2 text-sm text-white leading-tight focus:outline-none';
|
2020-03-12 13:26:31 -03:00
|
|
|
|
|
|
|
|
const transparentClasses = {
|
|
|
|
|
true: 'bg-transparent',
|
2020-06-26 12:34:43 -03:00
|
|
|
false: 'bg-black',
|
2020-03-12 13:26:31 -03:00
|
|
|
};
|
2020-02-13 19:43:20 -03:00
|
|
|
|
2020-02-13 20:14:59 -03:00
|
|
|
const Input = ({
|
|
|
|
|
label,
|
|
|
|
|
containerClassName = '',
|
2020-02-14 19:46:37 -03:00
|
|
|
labelClassName = '',
|
2020-02-13 20:14:59 -03:00
|
|
|
className = '',
|
2020-06-26 12:34:43 -03:00
|
|
|
transparent = false,
|
2020-03-12 13:26:31 -03:00
|
|
|
type = 'text',
|
|
|
|
|
value,
|
|
|
|
|
onChange,
|
2020-03-19 19:58:13 -03:00
|
|
|
onFocus,
|
2020-07-02 17:53:38 -03:00
|
|
|
autoFocus,
|
|
|
|
|
onKeyPress,
|
2020-03-12 13:26:31 -03:00
|
|
|
...otherProps
|
2020-02-13 20:14:59 -03:00
|
|
|
}) => {
|
2020-03-12 13:26:31 -03:00
|
|
|
return (
|
|
|
|
|
<div className={classnames('flex flex-col flex-1', containerClassName)}>
|
|
|
|
|
<Label className={labelClassName} text={label}></Label>
|
|
|
|
|
<input
|
|
|
|
|
className={classnames(
|
|
|
|
|
className,
|
|
|
|
|
baseInputClasses,
|
|
|
|
|
transparentClasses[transparent]
|
|
|
|
|
)}
|
2020-07-02 17:53:38 -03:00
|
|
|
autoFocus
|
2020-03-12 13:26:31 -03:00
|
|
|
type={type}
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={onChange}
|
2020-03-19 19:58:13 -03:00
|
|
|
onFocus={onFocus}
|
2020-07-02 17:53:38 -03:00
|
|
|
onKeyPress={onKeyPress}
|
2020-03-12 13:26:31 -03:00
|
|
|
{...otherProps}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2020-02-13 19:43:20 -03:00
|
|
|
);
|
2020-02-13 20:14:59 -03:00
|
|
|
};
|
|
|
|
|
|
2020-03-12 13:26:31 -03:00
|
|
|
Input.propTypes = {
|
|
|
|
|
label: PropTypes.string,
|
|
|
|
|
containerClassName: PropTypes.string,
|
|
|
|
|
labelClassName: PropTypes.string,
|
|
|
|
|
className: PropTypes.string,
|
|
|
|
|
transparent: PropTypes.bool,
|
|
|
|
|
type: PropTypes.string,
|
|
|
|
|
value: PropTypes.any,
|
|
|
|
|
onChange: PropTypes.func,
|
2020-03-19 19:58:13 -03:00
|
|
|
onFocus: PropTypes.func,
|
2020-07-02 17:53:38 -03:00
|
|
|
autoFocus: PropTypes.bool,
|
|
|
|
|
onKeyPress: PropTypes.func,
|
2020-02-13 19:43:20 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Input;
|