Sha256: 88daa1a8160460cff68568eadb8221e1816a3e48697125b045a1568ae51e0f10

Contents?: true

Size: 1.31 KB

Versions: 644

Compression:

Stored size: 1.31 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 | (() => void)},
  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

644 entries across 644 versions & 1 rubygems

Version Path
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2176 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnpowerhomeplaybookicons001alpha52175 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.18.0.pre.alpha.dependabotnpmandyarnpowerhomeplaybookicons001alpha52174 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2173 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2159 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.17.0.pre.alpha.nodealphaupgrade2157 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.18.0 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2130 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.PLAY12002127 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.powercentrainplaybookpt22125 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2107 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.PBNTR181stripedtable2103 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2100 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.PBNTR184betaflaginmenuyml2085 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.PBNTR178AdvancedTableDocs2072 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.17.0 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2060 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2038 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.play1141iconkitusinglibrary2037 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx
playbook_ui-13.16.0.pre.alpha.nodejsupgrade2036 app/pb_kits/playbook/pb_stat_value/_stat_value.tsx