"use client"; import { useRef } from "react"; import { motion } from "framer-motion"; import { IoCartOutline } from "react-icons/io5"; import { IconButton } from "@/components/IconButton"; import { useCart } from "./CartContext"; export function CartButton({ className }: { className?: string }) { const { itemCount, setDrawerOpen } = useCart(); const hasItems = itemCount > 0; // If the component mounts with items already in the cart (e.g. navigating // between pages), start fully visible so there's no fade-in on every page. const mountedWithItems = useRef(hasItems); return ( setDrawerOpen(true)} aria-label="Open cart" className="text-lg"> {itemCount} ); }