import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import StyledTextarea from './styled-textarea'
import cx from 'classnames'
import InputContainer from 'utils/input-container'
import {
SmallSuccess,
SmallAlert,
SmallBlocked,
SmallError
} from 'icons'
class Textarea extends PureComponent {
renderStatusIcon () {
switch (this.props.type) {
case 'success':
return <SmallSuccess />
case 'alert':
return <SmallAlert />
case 'blocked':
return <SmallBlocked />
case 'error':
return <SmallError />
default:
return null
}
}
render () {
const {
name,
placeholder,
maxLength,
disabled,
width,
height,
value,
onChange,
...rest
} = this.props
return (
<InputContainer {...rest} height='auto'>
<StyledTextarea
width={width}
height={height}
>
<div className='elementContainer'>
<textarea
{...this.props}
id={name}
name={name}
maxLength={maxLength}
placeholder={placeholder}
disabled={disabled}
value={value}
onChange={onChange}
/>
{this.renderStatusIcon()}
</div>
</StyledTextarea>
</InputContainer>
)
}
}
Textarea.propTypes = {
placeholder: PropTypes.string,
maxLength: PropTypes.number,
message: PropTypes.string,
className: PropTypes.string,
disabled: PropTypes.bool,
width: PropTypes.string,
height: PropTypes.string,
type: PropTypes.string,
label: PropTypes.string,
name: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func
}
export { Textarea }
|