Sha256: 25e8e4d36bf5c9798974690ec4cbd0da9b78bee7959b5d3316c57336f0c0e7c1

Contents?: true

Size: 1.58 KB

Versions: 105

Compression:

Stored size: 1.58 KB

Contents

/* @flow */

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

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

105 entries across 105 versions & 1 rubygems

Version Path
playbook_ui-10.23.0.pre.alpha1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.22.1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.22.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.1.pre.alpha1 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx
playbook_ui-10.21.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx