Sha256: e2ab37a42e0e553280a7af772cf555a537398026215de1cfa6c2c69d460273e3

Contents?: true

Size: 1.81 KB

Versions: 43

Compression:

Stored size: 1.81 KB

Contents

/* @flow */

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

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

import { spacing } from '../utilities/spacing.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 = {},
    className,
    data = {},
    id,
    steps = 3,
    title,
    value,
    dark = false,
  } = props
  const darkClass = dark ? '_dark' : ''

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

  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

43 entries across 43 versions & 1 rubygems

Version Path
playbook_ui-6.0.1.pre.alpha5 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-6.0.1.pre.alpha4 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-6.0.1.pre.alpha3 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-6.0.1.pre.alpha2 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-6.0.1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-6.0.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.1.pre.alpha4 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.1.pre.alpha3 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.1.pre.alpha2 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.1.pre.alpha1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.5.0.pre.alpha1 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_progress_pills/_progress_pills.jsx