Files
ohif-viewer/platform/ui/src/components/Input/Input.jsx
T

57 lines
1.3 KiB
React
Raw Normal View History

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 =
'shadow transition duration-300 appearance-none border rounded w-full py-2 px-3 text-sm text-white hover:border-gray-500 leading-tight focus:border-gray-500 focus:outline-none';
2020-03-12 13:26:31 -03:00
const transparentClasses = {
true: 'bg-transparent',
false: '',
};
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-03-12 13:26:31 -03:00
transparent = true,
type = 'text',
value,
onChange,
2020-03-19 19:58:13 -03:00
onFocus,
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]
)}
type={type}
value={value}
onChange={onChange}
2020-03-19 19:58:13 -03:00
onFocus={onFocus}
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-02-13 19:43:20 -03:00
};
export default Input;