Sha256: eba71a156270ccb809750c007de1ff62aad31ccfca601a5e17332affac72e6b1

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

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

import { globalProps } from '../utilities/globalProps'
import { buildHtmlProps } from '../utilities/props'
import Title from '../pb_title/_title'

type StatValueProps = {
  className?: string,
  htmlOptions?: {[key: string]: string | number | boolean | Function},
  id?: string,
  unit?: string,
  value: string | number,
}

const StatValue = (props: StatValueProps): React.ReactElement => {
  const {
    className,
    htmlOptions = {},
    id,
    unit,
    value = 0,
  } = props

  const htmlProps = buildHtmlProps(htmlOptions)

  const displayValue = function(value: string | number) {
    if (value || value === 0) {
      return (
        <Title
            size={1}
            tag="span"
            text={`${value}`}
        />
      )
    }
  }

  const displayUnit = function(unit: string) {
    if (unit) {
      return (
        <Title
            size={3}
            tag="span"
            text={unit}
        />
      )
    }
  }

  return (
    <div
        className={classnames('pb_stat_value_kit', globalProps(props), className)}
        id={id}
        {...htmlProps}
    >
      <div className="pb_stat_value_wrapper">
        {displayValue(value)}
        &nbsp;
        {displayUnit(unit)}
      </div>
    </div>
  )
}

export default StatValue

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
playbook_ui-13.14.0.pre.alpha.PLAY1109bugdisplaypropblocksfontcolor1784 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.14.0.pre.alpha.play1106filter1751 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.14.0.pre.alpha.play1106filter1748 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.14.0 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.13.0.pre.alpha.PLAY1097linterenhancedelement1728 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.13.0.pre.alpha.play10221678 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.13.0.pre.alpha.PLAY1090csstokens1675 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.13.0.pre.alpha.play900startratingasinput1657 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.13.0 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.12.0.pre.alpha.play10281596 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx