import { cn } from 'ui' interface SparkBarProps { value: number max?: number type?: 'horizontal' | 'vertical' labelTop?: string labelTopClass?: string labelBottom?: string labelBottomClass?: string barClass?: string bgClass?: string borderClass?: string } export const SparkBar = ({ max = 100, value = 0, barClass = 'bg-foreground', bgClass = '', type = 'vertical', borderClass = '', labelBottom = '', labelBottomClass = 'tabular-nums', labelTop = '', labelTopClass = '', }: SparkBarProps) => { if (type === 'horizontal') { const width = Number((value / max) * 100) const widthCss = `${width}%` const hasLabels = labelBottom || labelTop return (
{hasLabels && (

0 && 'max-w-[75%]', labelBottomClass )} > {labelBottom}

{labelTop}

)}
) } else { const totalHeight = 35 let height = Number((value / max) * totalHeight) if (height < 2) height = 2 return (
) } } export default SparkBar