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.8.0.pre.alpha.PLAY1016reactionbuttonemojibug1245 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.8.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.7.0.pre.alpha.play845allkitsbytypes1234 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.7.0.pre.alpha.play845allkitsbytypes1232 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.7.0.pre.alpha.play845allkitsbytypes1231 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.7.0.pre.alpha.play978makehighchartsadevdependencypoc1223 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.6.0.pre.alpha.play845allkitsbytypes1219 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.7.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.6.0.pre.alpha.tiptapreacthookformbug1210 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.6.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.5.0.pre.alpha.play984collapsiblekithidestooltips1203 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.5.0.pre.alpha.PLAY823globalpropoverflow1191 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.5.0.pre.alpha.PLAY823globalpropoverflow1188 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.5.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.4.0.pre.alpha.PLAY973Hash1181 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.4.0.pre.alpha.play961turnoffdeprecationwarnings1171 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.4.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.3.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.2.0.pre.alpha.PLAY986dateTimeRounding1150 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx
playbook_ui-13.2.0 app/pb_kits/playbook/pb_progress_pills/_progress_pills.tsx