Sha256: 50fa5fa5c206428b9034686a2bf57cd4dd04316c7068ebb83d3af7d93fe8c67c

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

/* @flow */

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

import {
  Body,
  StatChange,
  StatValue,
} from '../'

type DashboardValueProps = {
  align?: 'left' | 'center' | 'right',
  className?: String,
  id?: String,
  statChange?: {
    change?: String,
    value?: String | Number
  },
  statLabel?: String,
  statValue?: {
    unit?: String,
    value?: String | Number
  }
}

const dashboardValueCSS = ({
  align='left',

}: DashboardValueProps) => {

  const alignStyle = align !== '' ? `_${align}` : ''

  return 'pb_dashboard_value_kit' + alignStyle
}

const DashboardValue = (props: DashboardValueProps) => {
  const {
    align='left',
    className,
    id,
    statChange,
    statLabel,
    statValue,
  } = props

  return (
    <div id={id} className={classnames(dashboardValueCSS(props), className)}>
      <If condition={statLabel}>
        <Body color="light">{statLabel}</Body>
      </If>
      <If condition={statValue}>
        <StatValue value={statValue.value} unit={statValue.unit} />
      </If>
      <If condition={statChange}>
        <StatChange change={statChange.change} value={statChange.value} />
      </If>
    </div>
  )
}

export default DashboardValue

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
playbook_ui-3.1.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-3.0.1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-3.0.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-2.9.9 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx