'use client'; import { useState, useRef, type ReactNode } from 'react'; interface ActivityTooltipProps { appName: string; tooltipDescription: string; tooltipNetworkNote?: string; appUrl?: string; children: ReactNode; } export function ActivityTooltip({ appName, tooltipDescription, tooltipNetworkNote, appUrl, children, }: ActivityTooltipProps) { const [open, setOpen] = useState(false); const timeoutRef = useRef>(undefined); const tooltipId = `tooltip-${appName.replace(/\s+/g, '-').toLowerCase()}`; function handleEnter() { clearTimeout(timeoutRef.current); setOpen(true); } function handleLeave() { timeoutRef.current = setTimeout(() => setOpen(false), 150); } return ( /* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- tooltip trigger delegates focus/keyboard to the interactive child */ {children} {open && ( /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- tooltip must track mouse to stay open when user moves to it */ {appName}
{tooltipDescription} {tooltipNetworkNote && ( <>
{tooltipNetworkNote} )} {appUrl && ( <>
View on {new URL(appUrl).hostname} → )}
)}
); }