import React from "react"; import { cx } from "twind/core"; function CounterDigit(props: { value: number; transitionDurationMs?: number | undefined }) { const { value, transitionDurationMs = 1500 } = props; const rads = -(Math.floor(value) % 1_000_000) * 2 * Math.PI * 0.1; return ( {Array.from({ length: 10 }).map((_, i) => ( {i} ))} ); } const Spacer = () => ; const CounterText = (props: { children: React.ReactNode }) => ( {props.children} ); export function Counter(props: { value: number; digits: number; fractionDigits?: number | undefined; transitionDurationMs?: number | undefined; className?: string | undefined; postfix?: string | undefined; }) { const { value, digits, fractionDigits = 0, transitionDurationMs, className, postfix } = props; return ( {Array.from({ length: digits }) .flatMap((_, i) => [ i > 0 && i % 3 === 0 ? : null, , ]) .reverse()} {fractionDigits > 0 && ( <> . {Array.from({ length: fractionDigits }) .flatMap((_, i) => [ i > 0 && i % 3 === 0 ? : null, , ])} )} {postfix && ( <> {postfix} )} ); }