Sha256: b84fe4fcef15fd575e575ecd64173261ec0e02e524f3049e94fca544492c0cc8

Contents?: true

Size: 1.79 KB

Versions: 48

Compression:

Stored size: 1.79 KB

Contents

/* @flow */

import React from 'react'
import { Body, Title } from '../'
import classnames from 'classnames'

import {
  buildAriaProps,
  buildCss,
  buildDataProps,
} from '../utilities/props'

import { globalProps } from '../utilities/globalProps.js'

type ProgressPillsProps = {
  active?: number,
  aria?: object,
  className?: string,
  data?: object,
  id?: string,
  steps?: number,
  title?: string,
  value?: string,
  dark?: boolean,
}

const showSteps = (steps, active, dark) => {
  const items = []

  for (let step = 1; step <= steps; step++) {
    items.push(ProgressPill({ step, active, dark }))
  }

  return items
}

const ProgressPill = ({ active, dark, step }: ProgressPillProps) => (
  <div
      className={`pb_progress_pill${step <= active ? '_active' : '_inactive'}${
      dark ? ' dark' : ''
    }`}
      key={step}
  />
)

const ProgressPills = (props: ProgressPillsProps) => {
  const {
    active = 0,
    aria = { hidden: true },
    className,
    data = {},
    id,
    steps = 3,
    title,
    value,
    dark = false,
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_progress_pills_kit'), globalProps(props), className)

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >

      <If condition={title}>
        <div className="progress_pills_status">
          <Title
              dark={dark}
              size={4}
              tag="h4"
              text={title}
          />
          <Body
              color="light"
              dark={dark}
              text={value}
          />
        </div>
      </If>
      <div className="progress_pills">{showSteps(steps, active, dark)}</div>
    </div>
  )
}

export default ProgressPills

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
playbook_ui-9.19.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.19.0.pre.alphafonts app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.18.0.flow.bin.alpha app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.18.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.17.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.17.0.pre.decouple.website2 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.16.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.15.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.15.0.pre.decouple.website1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.14.1.alpha.radio.alignment app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.14.1.alpha.highcharts9 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.14.1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.13.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.12.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.12.0.pre.text.addon app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.11.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.10.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.10.0.pre.date.time.stacked.1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.10.0.pre.alpha2 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-9.10.0.pre.alpha1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx