fork refine

This commit is contained in:
Stefan Pejcic
2024-02-05 10:23:04 +01:00
parent 3fffde9a8f
commit 8496a83edb
3634 changed files with 715528 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
import React from "react";
import { useInView } from "framer-motion";
import { useAnimatedCounter } from "../../hooks/use-animated-counter";
type CountingNumberProps = {
className?: string;
from?: number;
to: number;
duration?: number;
format?: (value: number) => string;
once?: boolean;
};
export const CountingNumber: React.FC<CountingNumberProps> = ({
className,
from,
to,
format,
duration = 1,
once = true,
}) => {
const ref = React.useRef<HTMLSpanElement>(null);
const inView = useInView(ref, { once });
const counter = useAnimatedCounter(inView ? to : from ?? 0, from, duration);
return (
<span ref={ref} className={className}>
{format ? format(counter) : counter}
</span>
);
};