import type { MantineTheme } from "@mantine/core"; import { Button } from "@mantine/core"; import React from "react"; interface ExpandableLinkProps { href: string; children: React.ReactNode; } export default function ExpandableLink({ href, children, }: ExpandableLinkProps) { const childContent = children?.toString() || ""; const firstChar = childContent.charAt(0); const [isExpanded, setIsExpanded] = React.useState(true); const timerRef = React.useRef(null); React.useEffect(() => { timerRef.current = window.setTimeout(() => { setIsExpanded(false); timerRef.current = null; }, 3000); return () => { if (timerRef.current) { clearTimeout(timerRef.current); } }; }, []); const handleMouseEnter = () => { if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; } setIsExpanded(true); }; const handleMouseLeave = () => { timerRef.current = window.setTimeout(() => { setIsExpanded(false); timerRef.current = null; }, 3000); }; const fullTextRef = React.useRef(null); const [fullTextWidth, setFullTextWidth] = React.useState(0); React.useEffect(() => { const measureText = () => { if (fullTextRef.current) { setFullTextWidth(fullTextRef.current.scrollWidth); } }; measureText(); window.addEventListener("resize", measureText); return () => { window.removeEventListener("resize", measureText); }; }, []); return ( ); }