Sha256: a1c9163938e6d89211683d27293d32dba72b6c2c25ed61a12f352c037a124a29

Contents?: true

Size: 1.06 KB

Versions: 153

Compression:

Stored size: 1.06 KB

Contents

/* @flow */

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

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

type StatValueProps = {
  className?: string,
  id?: string,
  unit?: string,
  value: string | number
}

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

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

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

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

export default StatValue

Version data entries

153 entries across 153 versions & 1 rubygems

Version Path
playbook_ui-11.8.0 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.7.0.pre.alpha.table1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.7.0 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.6.0.pre.alpha.fontawesome app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.5.0.pre.alpha.fontawesome app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.7.0.pre.alpha.pre.guagechart1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.6.0 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.5.0.pre.alpha.datepicker1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.6.0.pre.alpha.rubocopperf1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.6.1.pre.alpha.rubocop.pre.performance1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.5.0.pre.alpha.pre.rubocop app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.6.0.pre.alpha.momenttz1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.5.0 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.4.0.pre.alpha.rubytheme2 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.4.0.pre.alpha.rubytheme1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.4.0 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.3.0.pre.alpha2 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.3.0.pre.alpha1 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.3.0 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx
playbook_ui-11.2.7 app/pb_kits/playbook/pb_stat_value/_stat_value.jsx