Sha256: 28c9bfb948be9b5d66c8efd13f7849250690dc1bbabd123a614795b567edd6d2

Contents?: true

Size: 1.59 KB

Versions: 53

Compression:

Stored size: 1.59 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 from '../pb_body/_body'
import StatChange from '../pb_stat_change/_stat_change'
import StatValue from '../pb_stat_value/_stat_value'

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),
    globalProps(props),
    className
  )

  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

53 entries across 53 versions & 1 rubygems

Version Path
playbook_ui-10.23.0.pre.cachetest app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0.pre.alpha.lightbox.2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0.pre.alpha.lightbox app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0.pre.alpha.rg1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0.pre.alpha.jg1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0.pre.alpha.na1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0.pre.alpha.jd1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.20.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.19.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.19.0.pre.lightbox app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.18.2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.19.0.pre.popover.alpha1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.18.1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.18.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.17.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.16.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.15.1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.15.1.pre.alpha.rubocop.deps app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.15.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.14.1.pre.alpha2 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx