Skip to content

Commit

Permalink
Add Framer Motion and prepare animated counter component
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Nov 22, 2024
1 parent b934de9 commit 512bec0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
28 changes: 28 additions & 0 deletions app/components/AnimatedCounter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use client";

import { AnimatePresence, motion } from "framer-motion";

interface Props {
value: number;
}

export const AnimatedCounter = ({ value }: Props) => {
const digits = String(value).split("");

return (
<AnimatePresence mode="popLayout">
{digits.map((digit, index) => (
<motion.span
key={index + digit}
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
transition={{ duration: 0.3, ease: "easeOut" }}
className="relative inline-block text-center"
>
{digit}
</motion.span>
))}
</AnimatePresence>
);
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"d3": "^7.8.5",
"date-fns": "^3.6.0",
"drizzle-orm": "^0.33.0",
"framer-motion": "12.0.0-alpha.1",
"lucide-react": "^0.381.0",
"next": "^15.0.3",
"react": "19.0.0-rc.1",
Expand Down
43 changes: 31 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 512bec0

Please sign in to comment.