Sha256: e71dfaa32edacdaafb549096095901fb6a45ea5aac675270cbde236738d98d72

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { Body, Caption } from '../'
import type { InputCallback } from '../types.js'
import { globalProps } from '../utilities/globalProps.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,
  resize: 'none' | 'both' | 'horizontal' | 'vertical',
  onChange?: InputCallback<HTMLTextAreaElement>,
}

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

  return (
    <div className={classnames(textareaClass, className, errorClass, resizeClass, globalProps(props))}>
      <Caption
          dark={dark}
          text={label}
      />
      <If condition={children}>
        {children}
        <Else />
        <textarea
            {...props}
            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-6.1.0.pre.alpha5 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.1.0.pre.alpha4 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.1.0.pre.alpha3 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.1.0.pre.alpha2 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.1.0.pre.alpha1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.1.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.0.1.pre.alpha6 app/pb_kits/playbook/pb_textarea/_textarea.jsx