Sha256: c3be8a8be821ab59e8ddc9787354190b8729a065d7c6be9428e06de69be351ad

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { Body, Caption } from '../'
import { type InputCallback } from '../types.js'

type TextareaProps = {
  className?: String,
  children?: Array<React.ReactChild>,
  data?: String,
  error?: String,
  id?: String,
  object?: String,
  method?: String,
  label?: String,
  placeholder?: String,
  value?: String,
  name?: String,
  rows?: Number,
  dark?: Boolean,
  onChange?: InputCallback,
}

const Textarea = ({
  className,
  children,
  dark = false,
  error,
  label,
  name,
  onChange = () => {},
  placeholder,
  rows = 4,
  value,
}: TextareaProps) => {
  const textareaClass = `pb_textarea_kit${dark ? '_dark' : ''}`
  const errorClass = error ? 'error' : null

  return (
    <div className={classnames(textareaClass, className, errorClass)}>
      <Caption
          dark={dark}
          text={label}
      />
      <If condition={children}>
        {children}
        <Else />
        <textarea
            className={textareaClass}
            name={name}
            onChange={onChange}
            placeholder={placeholder}
            rows={rows}
            value={value}
        />
        <If condition={error}>
          <Body
              dark={dark}
              status="negative"
              text={error}
          />
        </If>
      </If>
    </div>
  )
}

export default Textarea

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
playbook_ui-4.2.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-4.1.2 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-4.1.1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-4.1.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-4.0.1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-4.0.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-3.5.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx