Sha256: b82d36273a2554f73457f7f9f157aa7a468886c4db35fdd46b46413171465cab

Contents?: true

Size: 1.31 KB

Versions: 31

Compression:

Stored size: 1.31 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { spacing } from '../utilities/spacing.js'
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 {
    className,
    id,
    statChange,
    statLabel,
    statValue,
  } = props

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

export default DashboardValue

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha8 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha7 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.3.0.pre.alpha1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.4.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha6 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha5 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.3.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha4 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha3 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0.pre.alpha2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.2.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.1.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-5.0.3 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx