1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-05 20:15:31 -04:00

refactor: replace react-countup with @number-flow/react

This commit is contained in:
2026-04-30 10:36:33 -04:00
parent b2416ff0db
commit 62d632f909
26 changed files with 419 additions and 450 deletions
+6 -10
View File
@@ -1,8 +1,8 @@
"use client";
import NumberFlow from "@number-flow/react";
import { useEffect, useState } from "react";
import { CountUp } from "@/components/count-up";
import { incrementViews } from "@/lib/server/views";
const ViewCounter = ({ slug }: { slug: string }) => {
@@ -25,16 +25,12 @@ const ViewCounter = ({ slug }: { slug: string }) => {
return <span title="Error getting views! :(">?</span>;
}
if (views === null) {
return <span className="motion-safe:animate-pulse">0</span>;
}
return (
<span
title={`${Intl.NumberFormat(process.env.NEXT_PUBLIC_SITE_LOCALE).format(views)} ${views === 1 ? "view" : "views"}`}
>
<CountUp start={0} end={views} delay={0} duration={1.5} />
</span>
<NumberFlow
className={views === null ? "motion-safe:animate-pulse" : undefined}
locales={process.env.NEXT_PUBLIC_SITE_LOCALE}
value={views ?? 0}
/>
);
};