const percentageFormat = new Intl.NumberFormat('en-US', { currency: 'USD', maximumFractionDigits: 2, }) export function percentage(ratio: number): string { return percentageFormat.format(ratio * 100) + '%' } export function clamp(min: number, val: number, max: number): number { return Math.max(min, Math.min(max, val)) } export function Percentage( { ratio, ...props }: & { ratio: number } & JSX.HTMLAttributes, ) { return ( {percentage(ratio)} ) }