Sha256: c696d471714a3df4334772c3d91a4cc762bb6848847f2a503cbccb38e0348426

Contents?: true

Size: 1.61 KB

Versions: 44

Compression:

Stored size: 1.61 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { Body, Caption } from '../'
import type { InputCallback } from '../types.js'
import { spacing } from '../utilities/spacing.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, spacing(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

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-6.0.1.pre.alpha5 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.0.1.pre.alpha4 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.0.1.pre.alpha3 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.0.1.pre.alpha2 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.0.1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-6.0.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.1.pre.alpha4 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.1.pre.alpha3 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.1.pre.alpha2 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.1.pre.alpha1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.5.0.pre.alpha1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_textarea/_textarea.jsx