All files / components/textarea index.js

0% Statements 0/78
0% Branches 0/46
0% Functions 0/13
0% Lines 0/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84                                                                                                                                                                       
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 }