import { useEffect, useState } from "react"; import { ShortcutItem, Notification } from "../types"; function prettyName(s: string | undefined): string { if (!s) { return ""; } return s.replaceAll("/", " / "); } export function TopBar({ pageName, unsavedChanges, notifications, shortcutItems, onClick, lhs, rhs, }: { pageName?: string; unsavedChanges: boolean; notifications: Notification[]; shortcutItems: ShortcutItem[]; onClick: () => void; lhs?: React.ReactNode; rhs?: React.ReactNode; }) { const [menuExpanded, setMenuExpanded] = useState(false); useEffect(() => { function closer() { setMenuExpanded(false); } document.addEventListener("click", closer); return () => { document.removeEventListener("click", closer); }; }, []); return (