import classNames from 'classnames'; import { Icon, Icons } from 'react-basics'; import { useSpring, animated } from '@react-spring/web'; import { formatNumber } from 'lib/format'; import styles from './MetricCard.module.css'; export interface MetricCardProps { value: number; previousValue?: number; change?: number; label?: string; reverseColors?: boolean; format?: typeof formatNumber; showLabel?: boolean; showChange?: boolean; showPrevious?: boolean; className?: string; } export const MetricCard = ({ value = 0, change = 0, label, reverseColors = false, format = formatNumber, showLabel = true, showChange = false, showPrevious = false, className, }: MetricCardProps) => { const props = useSpring({ x: Number(value) || 0, from: { x: 0 } }); const changeProps = useSpring({ x: Number(change) || 0, from: { x: 0 } }); const prevProps = useSpring({ x: Number(value - change) || 0, from: { x: 0 } }); const positive = change * (reverseColors ? -1 : 1) >= 0; const negative = change * (reverseColors ? -1 : 1) < 0; return (