Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / @skava/ui   js

Repository URL to install this package:

Version: 4.2.0-a11y.0 

/ src / components / molecules / MeterBar / renderProps.tsx

import React from 'react'
import { ProgressBar } from 'atoms/ProgressBar'
import { getBarCountPosition } from './deps'
import { MeterBarWrap, MeterCount } from './styled'
import { MeterBarProps } from './typings'

/**
 * rendering meter bar count
 */
function renderCount(props: MeterBarProps) {
  const { value, numberAlignType } = props
  return (
    <MeterCount orderArrange={getBarCountPosition(numberAlignType)}>
      {value}
    </MeterCount>
  )
}

/**
 * rendering progress bar
 */
function renderProgressBar(props: MeterBarProps) {
  // IMPORTANT: these props need to be actual numbers for this to work!!
  //            this fails if any of these props are strings
  const { value, min, max, meterWidth } = props
  // NOTE: the value needs to adjusted by the min & max limits
  const adjustedValue = value > max ? max : value < min ? min : value - min
  console.log('-- renderProgressBar: ', min, max, value, adjustedValue)
  const meterProps = {
    barWidth: meterWidth,
    currentValue: adjustedValue,
    totalValue: max,
  }
  return <ProgressBar {...meterProps} />
}

/**
 * rendering main wrapper of the meter bar
 */
function renderWrapper(props: MeterBarProps) {
  const { children } = props
  return <MeterBarWrap>{children}</MeterBarWrap>
}

export { renderCount, renderProgressBar, renderWrapper }