Sha256: 8392cae9ee79a34ed9af4cd535925c9a546d0e4556252bb41287d39be47ab5f7

Contents?: true

Size: 1.48 KB

Versions: 37

Compression:

Stored size: 1.48 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'
import {
  Body,
  StatChange,
  StatValue,
} from '../'

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

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

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_dashboard_value_kit', align), className, globalProps(props))

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        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

37 entries across 37 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.7.0.pre.alpha1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.7.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.6.1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.0.pre.alpha10 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.6.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.5.2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha12 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha11 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha10 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha9 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.5.1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-6.5.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha8 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha7 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha6 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha5 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha4 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha3 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-7.0.1.pre.alpha2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx