import * as React from 'react' import { Theme } from '@material-ui/core' import { withStyles } from '@material-ui/styles' interface Props { changes: Array classes: { [s: string]: any } nameOfCompareMessage: string } function changeAmount(props: Props) { const additions = props.changes.map(change => (change.added === true ? change.count || 0 : 0)).reduce((a, b) => a + b) const deletions = props.changes .map(change => (change.removed === true ? change.count || 0 : 0)) .reduce((a, b) => a + b) if (additions === 0 && deletions === 0) { return null } return ( Comparing with {props.nameOfCompareMessage} message:  + {additions} line{additions === 1 ? '' : 's'} ,{' '} - {deletions} line{deletions === 1 ? '' : 's'} ) } const style = (theme: Theme) => ({ additions: { color: 'rgb(10, 255, 10)', }, deletions: { color: 'rgb(255, 10, 10)', }, }) export default withStyles(style)(changeAmount)