Sha256: 6b4d7b9aa52e884a61de08e689a6911c340e47c290cbea0c1f877ccae5e5f43b

Contents?: true

Size: 1.79 KB

Versions: 644

Compression:

Stored size: 1.79 KB

Contents

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } 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?: { [key: string]: string },
  className?: string,
  data?: { [key: string]: string },
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
  id?: string,
  statChange?: {
    change? : 'increase' | 'decrease' | 'neutral',
    value?: string | number
  },
  statLabel?: string,
  statValue?: {
    unit?: string,
    value?: string | number
  }
}

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

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

  return (
    <div
        {...ariaProps}
        {...dataProps}
        {...htmlProps}
        className={classes}
        id={id}
    >
      { statLabel && 
        <Body color="light">{statLabel}</Body>
      }
      { statValue && 
        <StatValue
            unit={statValue.unit}
            value={statValue.value}
        />
      }
      { statChange && 
        <StatChange
            change={statChange.change}
            value={statChange.value}
        />
      }
    </div>
  )
}

export default DashboardValue

Version data entries

644 entries across 644 versions & 1 rubygems

Version Path
playbook_ui-13.14.0.pre.alpha.play1120lintdatepicker1797 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.tsx
playbook_ui-13.15.0 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.tsx
playbook_ui-13.13.0.pre.alpha.play10821727 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.tsx
playbook_ui-13.13.0.pre.alpha.play10821726 app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.tsx