Sha256: edd7bf2edf1731274678919726df896dc13b722f53dfe7513eda7301a8d07a03
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
/* @flow */ import React from 'react' import classnames from 'classnames' import Body from '../pb_body/_body.jsx' import Icon from '../pb_icon/_icon.jsx' type StatChangeProps = { change?: 'increase' | 'decrease' | 'neutral', className?: String, id?: String, value?: String | Number } const statChangeCSS = ({}: StatChangeProps, status) => { const statusStyle = status !== '' ? `_${status}` : '' return 'pb_stat_change_kit' + statusStyle } const StatChange = (props: StatChangeProps) => { const { change='neutral', className, id, value, } = props const status = (function(change) { switch(change) { case 'increase': return 'positive'; case 'decrease': return 'negative'; default: return 'neutral'; } })(change) const icon = (function(change) { switch(change) { case 'increase': return 'arrow-up'; case 'decrease': return 'arrow-down'; default: return null; } })(change) const displayIcon = function(icon) { if (icon) { return ( <span> <Icon icon={icon} fixed_width={true} /> </span> ) } } const displayValue = function(status, value) { if (value) { return ( <Body status={status}> {displayIcon(icon)} {value} </Body> ) } } return ( <div id={id} className={classnames(statChangeCSS(props, status), className)}> {displayValue(status, value)} </div> ) } export default StatChange
Version data entries
3 entries across 3 versions & 1 rubygems