Sha256: 5697d9ee84625c27b92b7983ed4d712334b10fd2bb2433eb49d46de3bf30f85a

Contents?: true

Size: 1.68 KB

Versions: 16

Compression:

Stored size: 1.68 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'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps'

type RadioProps = {
  aria?: object,
  alignment?: String,
  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 = {},
  alignment = '',
  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), alignment, 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

16 entries across 16 versions & 1 rubygems

Version Path
playbook_ui-11.1.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-11.1.1.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-11.0.0.pre.alpha.2 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-11.0.0.pre.alpha.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.27.0.pre.lazysizes1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.27.0.pre.datepicker1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0.pre.alpha5 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0.pre.rc1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0.pre.alpha.sticky1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0.pre.alpha.display1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0.pre.alpha3 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.25.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.26.0.pre.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.25.0 app/pb_kits/playbook/pb_radio/_radio.jsx