// @flow
import * as React from "react";
import cn from "classnames";
import { Card, Text, Header, Icon } from "../";
type Props = {|
+className?: string,
/**
* The % amount by which your total has increased
*/
+movement: number,
/**
* The main number displayed within the Card
*/
+total: string,
/**
* The text label displayed within the Card
*/
+label: string,
/**
* The layout to render
*/
+layout?: 1 | 2,
/**
* A Chart to be included at the bottom of layout 2
*/
+chart?: React.Node,
|};
/**
* Used for dispaying an individual statistic/number with 2 potential layouts
*/
function StatsCard({
className,
movement,
total,
label,
layout = 1,
chart,
}: Props): React.Node {
const classes = cn(className);
const movementString = `${movement > 0 ? "+" : ""}${movement}%`;
const movementColor = !movement ? "yellow" : movement > 0 ? "green" : "red";
if (layout === 2) {
return (
{movementString}
{total}
{label}
{chart && {chart}
}
);
}
return (
{movementString}
0 ? "chevron-up" : "chevron-down"
}
/>
{label}
);
}
StatsCard.displayName = "StatsCard";
export default StatsCard;