import { cx } from "@twind/core";
import React from "react";
function CounterDigit(props: { value: number; transitionDurationMs?: number }) {
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;
transitionDurationMs?: number;
className?: string;
postfix?: string;
}) {
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}
>
)}
);
}