()
| 392 | |
| 393 | // ─── Main Component ────────────────────────────────────────────────────────── |
| 394 | const Header = () => { |
| 395 | const location = useLocation(); |
| 396 | const isToolsPage = location.pathname.startsWith('/tools'); |
| 397 | |
| 398 | const langCollection = useMemo(() => createListCollection({ items: ['JS', 'TS'] }), []); |
| 399 | const styleCollection = useMemo(() => createListCollection({ items: ['CSS', 'TW'] }), []); |
| 400 | |
| 401 | const { languagePreset, setLanguagePreset, stylePreset, setStylePreset } = useOptions(); |
| 402 | const [isDrawerOpen, setDrawerOpen] = useState(false); |
| 403 | const { toggleSearch } = useSearch(); |
| 404 | const stars = useStars(); |
| 405 | |
| 406 | const starCountRef = useRef(null); |
| 407 | const prefsTimeoutRef = useRef(null); |
| 408 | const toolsTimeoutRef = useRef(null); |
| 409 | const [prefsOpen, setPrefsOpen] = useState(false); |
| 410 | const [toolsOpen, setToolsOpen] = useState(false); |
| 411 | |
| 412 | const closeDrawer = useCallback(() => setDrawerOpen(false), []); |
| 413 | |
| 414 | const handlePrefsEnter = useCallback(() => { |
| 415 | if (prefsTimeoutRef.current) clearTimeout(prefsTimeoutRef.current); |
| 416 | setPrefsOpen(true); |
| 417 | }, []); |
| 418 | |
| 419 | const handlePrefsLeave = useCallback(() => { |
| 420 | prefsTimeoutRef.current = setTimeout(() => setPrefsOpen(false), PREFS_CLOSE_DELAY); |
| 421 | }, []); |
| 422 | |
| 423 | const handleToolsEnter = useCallback(() => { |
| 424 | if (toolsTimeoutRef.current) clearTimeout(toolsTimeoutRef.current); |
| 425 | setToolsOpen(true); |
| 426 | }, []); |
| 427 | |
| 428 | const handleToolsLeave = useCallback(() => { |
| 429 | toolsTimeoutRef.current = setTimeout(() => setToolsOpen(false), PREFS_CLOSE_DELAY); |
| 430 | }, []); |
| 431 | |
| 432 | const openGitHub = useCallback(() => window.open(GITHUB_URL, '_blank'), []); |
| 433 | |
| 434 | return ( |
| 435 | <Box zIndex={100} className="main-nav"> |
| 436 | <Flex className="nav-items" h={20} alignItems="center" justifyContent="space-between" px={4}> |
| 437 | <RouterLink to="/" className="logo"> |
| 438 | <Image src={Logo} alt="Logo" className="cursor-target" /> |
| 439 | </RouterLink> |
| 440 | |
| 441 | <IconButton |
| 442 | aria-label="Open Menu" |
| 443 | size="md" |
| 444 | display={{ md: 'none' }} |
| 445 | onClick={() => setDrawerOpen(true)} |
| 446 | bg="transparent" |
| 447 | color={colors.accent} |
| 448 | _hover={{ bg: colors.bgElevated }} |
| 449 | > |
| 450 | <MenuIcon size="1.3em" /> |
| 451 | </IconButton> |
nothing calls this directly
no test coverage detected