Sha256: 6c2cd8b6401761d68d42729d079b131a76e7070387972acb7e08c4dfb89e7347

Contents?: true

Size: 1.83 KB

Versions: 276

Compression:

Stored size: 1.83 KB

Contents

import React from 'react'
import classnames from 'classnames'

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

import Body from '../pb_body/_body'
import Title from '../pb_title/_title'

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

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

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

  return items
}

const ProgressPill = ({ active, dark, steps: step }: ProgressPillsProps) => (
  <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}
    >
      {title &&
        <div className="progress_pills_status">
          <Title
            dark={dark}
            size={4}
            tag="h4"
            text={title}
          />
          <Body
            color="light"
            dark={dark}
            text={value}
          />
        </div>}
      <div className="progress_pills">{showSteps(steps, active, dark)}</div>
    </div>
  )
}

export default ProgressPills

Version data entries

276 entries across 276 versions & 1 rubygems

Version Path
playbook_ui-13.12.0.pre.alpha.PLAY880cardkithighlightzindex1655 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1627 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1626 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1624 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1623 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1612 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1611 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1609 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1608 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1581 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1580 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1579 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1093typeaheadkitdocbug1577 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1574 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1567 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1558 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1556 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1051removinghighchartsdependency1551 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1550 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1543 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx