Sha256: ce19d1868d3fccf7cf5a2b7bc375d398da70bd1c58bb54b64f3f4f0c9f90020c

Contents?: true

Size: 1.38 KB

Versions: 30

Compression:

Stored size: 1.38 KB

Contents

/* @flow */

import React from 'react'
import Body from '../pb_body/_body.jsx'
import Icon from '../pb_icon/_icon.jsx'
import classnames from 'classnames'
import { spacing } from '../utilities/spacing.js'

type CheckboxProps = {
  checked?: Boolean,
  dark?: Boolean,
  error?: Boolean,
  name: String,
  text: String,
  value: String,
  children: Node,
  onChange: (Boolean) => void,
}

const Checkbox = (props: CheckboxProps) => {
  const {
    checked = false,
    dark = false,
    error = false,
    name = '',
    text = '',
    value = '',
    children = null,
    onChange = () => {},
  } = props

  return (
    <label
        className={classnames('pb_checkbox_kit' +
        (dark === true ? '_dark' : '') +
        (error === true ? ' error' : ''), spacing(props))

      }
    >
      <If condition={children}>
        {children}
        <Else />
        <input
            defaultChecked={checked}
            name={name}
            onChange={onChange}
            type="checkbox"
            value={value}
        />
      </If>

      <span className="pb_checkbox_checkmark">
        <Icon
            className="check_icon"
            fixedWidth
            icon="check"
        />
      </span>
      <Body
          className="pb_checkbox_label"
          dark={dark}
          status={error ? 'negative' : null}
      >
        {text}
      </Body>
    </label>
  )
}

export default Checkbox

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha8 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha7 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.3.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha6 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha5 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.3.0 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha4 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha3 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0.pre.alpha2 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.2.0 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.1.0 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.0.3 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx
playbook_ui-5.0.2 app/pb_kits/playbook/pb_checkbox/_checkbox.jsx