Sha256: a35b9df24c60b3a15f7c6336512b44b96fdc424f6cda2aeb37148a9399ffc7c7

Contents?: true

Size: 1.36 KB

Versions: 30

Compression:

Stored size: 1.36 KB

Contents

/* @flow */
import React from 'react'
import classnames from 'classnames'
import {
  Body,
  Caption,
} from '../'

type TextInputProps = {
  className: String,
  dark: boolean,
  error?: String,
  name: String,
  label: String,
  onChange: (String) => void,
  placeholder: String,
  type: String,
  value: String | number,
  children: Node,
}

const TextInput = ({
  className,
  dark = false,
  error,
  name,
  label,
  onChange = () => {},
  placeholder,
  type = 'text',
  value,
  children = null,
}: TextInputProps) => {
  const css = classnames([
    `pb_text_input_kit${dark === true ? '_dark' : ''}`,
    className,
    error ? 'error' : null,
  ])

  return (
    <div className={css}>
      <Caption
          className="pb_text_input_kit_label"
          dark={dark}
          text={label}
      />
      <div className="text_input_wrapper">
        <If condition={children}>
          {children}
          <Else />
          <input
              className="text_input"
              name={name}
              onChange={onChange}
              placeholder={placeholder}
              type={type}
              value={value}
          />
          <If condition={error}>
            <Body
                dark={dark}
                status="negative"
                text={error}
            />
          </If>
        </If>
      </div>
    </div>
  )
}

export default TextInput

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
playbook_ui-4.13.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.13.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.12.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.11.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.11.0.pre.alpha3 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.11.0.pre.alpha.pre.2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.10.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.10.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.9.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.9.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.8.2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.8.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.7.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.7.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.6.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.6.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.5.2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.5.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.5.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-4.4.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx