Sha256: 6ef6f7bf4f534f588276583739da807de7095c186eaea5a16002c32fc44e63f6

Contents?: true

Size: 1.24 KB

Versions: 98

Compression:

Stored size: 1.24 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'

import { buildCss } from '../utilities/props'
import { Body, Icon } from '../'
import { globalProps } from '../utilities/globalProps.js'

const statusMap = {
  increase: 'positive',
  decrease: 'negative',
}

const iconMap = {
  increase: 'arrow-up',
  decrease: 'arrow-down',
}

type StatChangeProps = {
  change?: "increase" | "decrease" | "neutral",
  className?: string,
  icon?: string,
  id?: string,
  value?: string | number,
}

const StatChange = (props: StatChangeProps) => {
  const { change = 'neutral', className, icon, id, value } = props
  const status = statusMap[change] || 'neutral'
  let returnedIcon = iconMap[change]
  if (icon) {
    returnedIcon = icon
  }

  return (
    <If condition={value}>
      <div
          className={classnames(
          buildCss('pb_stat_change_kit', status),
          globalProps(props),
          className
        )}
          id={id}
      >
        <Body status={status}>
          <If condition={returnedIcon}>
            <Icon
                fixed_width
                icon={returnedIcon}
            />
            {' '}
          </If>
          {`${value}%`}
        </Body>
      </div>
    </If>
  )
}

export default StatChange

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
playbook_ui-9.19.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.19.0.pre.alphafonts app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.18.0.flow.bin.alpha app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.18.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.17.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.17.0.pre.decouple.website2 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.16.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.15.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.15.0.pre.decouple.website1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.14.1.alpha.radio.alignment app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.14.1.alpha.highcharts9 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.14.1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.13.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.12.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.12.0.pre.text.addon app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.11.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.10.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.10.0.pre.date.time.stacked.1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.10.0.pre.alpha2 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-9.10.0.pre.alpha1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx