Sha256: 5f88f12ed25a90fec8fe231e8da9cc67d7632af74135efa2427a3748041a172c

Contents?: true

Size: 1.15 KB

Versions: 44

Compression:

Stored size: 1.15 KB

Contents

/* @flow */

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

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

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

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

type StatChangeProps = {
  change?: "increase" | "decrease" | "neutral",
  className?: String,
  id?: String,
  value?: String | Number,
}

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

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

export default StatChange

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-6.0.1.pre.alpha5 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-6.0.1.pre.alpha4 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-6.0.1.pre.alpha3 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-6.0.1.pre.alpha2 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-6.0.1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-6.0.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.1.pre.alpha4 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.1.pre.alpha3 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.1.pre.alpha2 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.1.pre.alpha1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.0 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.5.0.pre.alpha1 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_stat_change/_stat_change.jsx