From bb97a00273d93fff7f3eba408b79d6d3ba36cd2e Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Fri, 18 Apr 2025 17:05:46 +0200 Subject: [PATCH] Styling changes --- web/src/components/hero.tsx | 23 +++---- .../magicui/interactive-hover-button.tsx | 1 + web/src/components/magicui/number-ticker.tsx | 67 +++++++++++++++++++ 3 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 web/src/components/magicui/number-ticker.tsx diff --git a/web/src/components/hero.tsx b/web/src/components/hero.tsx index 22dbc793..1e5201ea 100644 --- a/web/src/components/hero.tsx +++ b/web/src/components/hero.tsx @@ -27,6 +27,7 @@ import Link from "next/link" import { useEffect, useRef, useState } from "react" import { AuroraText } from "./magicui/aurora-text" import { InteractiveHoverButton } from "./magicui/interactive-hover-button" +import { NumberTicker } from "./magicui/number-ticker" import { HoverCard, HoverCardContent, HoverCardTrigger } from "./ui/hover-card" interface IconCardProps { @@ -206,7 +207,6 @@ export function HeroSection({ totalIcons, stars }: { totalIcons: number; stars:
-

Your definitive source for @@ -216,8 +216,8 @@ export function HeroSection({ totalIcons, stars }: { totalIcons: number; stars:

- A collection of {totalIcons} curated icons for services, applications and tools, designed - specifically for dashboards and app directories. + A collection of curated icons + for services, applications and tools, designed specifically for dashboards and app directories.

@@ -232,7 +232,7 @@ export function HeroSection({ totalIcons, stars }: { totalIcons: number; stars:
- +
) @@ -265,9 +265,10 @@ export default function GiveUsAStarButton({ stars }: { stars: string | number }) What is Starring?

- Starring a repository on GitHub is like bookmarking it.
It helps you keep track of projects you find interesting and shows - appreciation to the project maintainers.
You can star a repository by clicking the 'Star' button, usually found in the - top-right corner of the repository's page on GitHub. + Starring a repository on GitHub is like bookmarking it. +
It helps you keep track of projects you find interesting and shows appreciation to the project maintainers. +
You can star a repository by clicking the 'Star' button, usually found in the top-right corner of the repository's page + on GitHub.

@@ -477,17 +478,11 @@ function SearchInput({ searchQuery, setSearchQuery, totalIcons }: SearchInputPro autoFocus type="search" placeholder={`Find any of ${totalIcons} icons by name or category...`} - className="pl-10 h-10 md:h-12 rounded-lg w-full border-muted-foreground/20 focus:ring-rose-500/20 text-sm md:text-base" + className="pl-10 h-10 md:h-12 rounded-lg w-full border-border focus:border-primary/20 text-sm md:text-base" value={searchQuery} onChange={(e) => setSearchQuery(e.target.value)} /> - ) } diff --git a/web/src/components/magicui/interactive-hover-button.tsx b/web/src/components/magicui/interactive-hover-button.tsx index a8432139..dcea5c23 100644 --- a/web/src/components/magicui/interactive-hover-button.tsx +++ b/web/src/components/magicui/interactive-hover-button.tsx @@ -10,6 +10,7 @@ export const InteractiveHoverButton = React.forwardRef { + value: number; + startValue?: number; + direction?: "up" | "down"; + delay?: number; + decimalPlaces?: number; +} + +export function NumberTicker({ + value, + startValue = 0, + direction = "up", + delay = 0, + className, + decimalPlaces = 0, + ...props +}: NumberTickerProps) { + const ref = useRef(null); + const motionValue = useMotionValue(direction === "down" ? value : startValue); + const springValue = useSpring(motionValue, { + damping: 30, + stiffness: 100, + }); + const isInView = useInView(ref, { once: true, margin: "0px" }); + + useEffect(() => { + if (isInView) { + const timer = setTimeout(() => { + motionValue.set(direction === "down" ? startValue : value); + }, delay * 1000); + return () => clearTimeout(timer); + } + }, [motionValue, isInView, delay, value, direction, startValue]); + + useEffect( + () => + springValue.on("change", (latest) => { + if (ref.current) { + ref.current.textContent = Intl.NumberFormat("en-US", { + minimumFractionDigits: decimalPlaces, + maximumFractionDigits: decimalPlaces, + }).format(Number(latest.toFixed(decimalPlaces))); + } + }), + [springValue, decimalPlaces], + ); + + return ( + + {startValue} + + ); +}