import * as React from "react"
import { injectGlobal } from "styled-components"

// tslint:disable-next-line:no-unused-expression
injectGlobal`
  textarea {
    box-shadow: none;
    -webkit-appearance: none;
    background-color: rgb(247, 247, 247);
    color: rgb(51, 51, 51);
    box-sizing: border-box;
    line-height: 1.5rem;
    border-radius: 5px;
    border-width: 1px;
    border-style: solid;
    border-color: rgb(221, 221, 221);
    height: 120px;
    margin: 0px;
    width: 100%;
    resize: none;

    padding: 8px 13px;
    font-size: 1rem;

  }
`

export const Textarea: React.SFC<React.TextareaHTMLAttributes<{}>> = (
  props
) => {
  return (
    <div style={{ position: "relative" }}>
      <textarea {...props} value={props.value} className={"lanna"} />
      <span style={{ position: "absolute", right: 10, bottom: 10, display: "flex", alignItems: "center", fontSize: "1.1rem", color: "#bcbcbc" }}>
        {`${( props.value || "" ).toString().length} / ${props.maxLength}`}
      </span>
    </div>
  )
}

Textarea.defaultProps = {
  value: "",
  maxLength: 999
}

export default Textarea
