Sha256: a803a956add29c845d4e314dbdfa00476f1be4d988d4bf21ef58b501fdfad073

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

/* @flow */
/*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */

import React from 'react'
import Body from '../pb_body/_body.jsx'
import classnames from 'classnames'
import { globalProps } from '../utilities/globalProps.js'

type RadioProps = {
  className?: string,
  data?: string,
  error?: boolean,
  id?: string,
  label: string,
  name: string,
  value: string,
  checked?: boolean,
  dark?: boolean,
  text: string,
  children?: Node,
  onChange: (boolean)=>void,
}

const Radio = ({
  checked = false,
  children,
  className = '',
  dark = false,
  data,
  error = false,
  id,
  label,
  name,
  value,
  text,
  onChange = () => {},
  ...props
}: RadioProps) => {
  const errorClass = error ? 'error' : ''

  return (
    <label
        className={classnames('pb_radio_kit' + (dark === true ? '_dark ' : ' ') + errorClass + ' ' + className, globalProps(props))}
        htmlFor={id}
    >
      <If condition={children}>
        {children}
        <Else />
        <input
            {...props}
            checked={checked}
            data={data}
            name={name}
            onChange={onChange}
            text={text}
            type="radio"
            value={value}
        />
      </If>
      <span className="pb_radio_button" />
      <Body
          dark={dark}
          status={error ? 'negative' : null}
          text={label}
      />
    </label>
  )
}

export default Radio

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-6.2.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-6.2.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.0.0.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx