Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
fix(stats): make outcome descrease is good by color
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Mar 8, 2019
1 parent cd67441 commit 7ad7eee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const Dynamics = ({ className, group, currency }: Props) => {
<Loader skeleton expectedRows={2} status={fetching}>
<div className={styles.diff}>
<Stat title="Income" value={incomeGrow} suffix="%" />
<Stat title="Outcome" value={outcomeGrow} suffix="%" />
<Stat title="Outcome" value={outcomeGrow} suffix="%" decreaseIsGood />
</div>
</Loader>
</Card>
Expand Down
12 changes: 10 additions & 2 deletions front/src/ui/components/chart/stat/Stat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ interface Props {
title: string
value: Option<number>
suffix?: string
decreaseIsGood?: boolean
}

export const Stat = ({ title, value, suffix }: Props) => {
export const Stat = ({
title,
value,
suffix,
decreaseIsGood = false,
}: Props) => {
if (value.nonEmpty()) {
const positive = value.get() > 0

const color = positive ? '#3f8600' : '#cf1322'
const green = !decreaseIsGood ? positive : !positive

const color = green ? '#3f8600' : '#cf1322'
const iconType = positive ? 'arrow-up' : 'arrow-down'

return (
Expand Down

0 comments on commit 7ad7eee

Please sign in to comment.