Sha256: 39d3c1852e754c855b3de859213aa26e00911c6251d7cf785bf302a582798b7b

Contents?: true

Size: 1.64 KB

Versions: 87

Compression:

Stored size: 1.64 KB

Contents

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

import React, { forwardRef } from 'react'
import Body from '../pb_body/_body.jsx'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'

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

const Radio = ({
  aria = {},
  children,
  className,
  dark = false,
  data = {},
  error = false,
  id,
  label,
  name = 'radio_name',
  text = 'Radio Text',
  value = 'radio_text',
  onChange = () => {},
  ...props
}: RadioProps, ref) => {
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_radio_kit'), { error }, { dark }, globalProps(props), className)

  return (
    <label
        {...ariaProps}
        {...dataProps}
        className={classes}
        htmlFor={id}
    >
      <If condition={children}>
        {children}
        <Else />
        <input
            {...props}
            id={id}
            name={name}
            onChange={onChange}
            ref={ref}
            text={text}
            type="radio"
            value={value}
        />
      </If>
      <span className="pb_radio_button" />
      <Body
          dark={dark}
          status={error ? 'negative' : null}
          text={label}
      />
    </label>
  )
}

export default forwardRef(Radio)

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
playbook_ui-8.0.3 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.2.0.pre.alpha2 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.1.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.0.2 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.2.0.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.1.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.0.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.0.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.0.0.pre.alpha5 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.0.0.pre.alpha4 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-8.0.0.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.16.0.pre.alpha5 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.16.0.pre.alpha4 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.16.0.pre.alpha3 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.16.0.pre.alpha2 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.16.0.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.14.0.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.16.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.15.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-7.15.0 app/pb_kits/playbook/pb_radio/_radio.jsx