All files / molecule/stepper/src/Step settings.js

100% Statements 20/20
96.55% Branches 28/29
100% Functions 2/2
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40    1x 1x 1x   1x                       58x 46x 34x 8x 26x 6x   20x     1x 58x 24x 12x 12x              
import {BASE_CLASS, DESIGN} from '../settings.js'
 
export const BASE_CLASS_STEP = `${BASE_CLASS}Step`
export const BASE_CLASS_STEP_LABEL = `${BASE_CLASS_STEP}Label`
export const BASE_CLASS_STEP_ICON = `${BASE_CLASS_STEP}Icon`
 
export const getIcon = ({
  design,
  visited,
  current,
  step,
  icon,
  iconContext,
  visitedIcon,
  visitedIconContext,
  currentIcon,
  currentIconContext
}) => {
  if (design === DESIGN.COMPRESSED) return null
  else if (design === DESIGN.BASIC) return null
  else if (visited && !current) {
    return visitedIcon || visitedIconContext || step
  } else if (current && !visited) {
    return currentIcon || currentIconContext || step
  }
  return icon || iconContext || step
}
 
export const getLabel = ({label, steps, step, design, current}) => {
  if (design === DESIGN.DEFAULT) return label
  if (design === DESIGN.BASIC) return label
  Eif (design === DESIGN.COMPRESSED)
    return (
      <>
        <span>{`${step}/${steps}`}</span>
        {label && <span>:&nbsp;{label}</span>}
      </>
    )
}