import { ReactNode } from "react"; import { Box, Group, Stack, Text, UnstyledButton } from "@mantine/core"; import Sparkline, { SparklineScale } from "./sparkline"; interface StatTileProps { label: ReactNode; value: ReactNode; valueColor?: string; delta?: number; spark?: number[]; sparkScale?: SparklineScale; caption?: ReactNode; onClick?: () => void; } export const StatTile = ({ label, value, valueColor, delta, spark, sparkScale, caption, onClick, }: StatTileProps) => { const content = ( {value} {delta !== undefined && delta !== 0 && ( 0 ? "green" : "red"}> {delta > 0 ? "+" : ""} {delta.toLocaleString()} )} {label} {caption && {caption}} {spark && spark.length > 0 && ( )} ); if (onClick) { return ( {content} ); } return content; }; export default StatTile;