import { useEffect, useRef, useState } from 'react' import { ShortcutsDialog } from './ShortcutsDialog' interface Props { onOpenPathMapping: () => void /** Open the menu above the button — for a button at the bottom of the window. */ up?: boolean } /** Overflow menu for low-frequency, collection-level settings. Currently holds * path remapping and the shortcut list; the natural home for future advanced * settings. The shortcuts dialog is owned here, since nothing else opens it. */ export function SettingsMenu({ onOpenPathMapping, up = false }: Props) { const [open, setOpen] = useState(false) const [showShortcuts, setShowShortcuts] = useState(false) const ref = useRef(null) useEffect(() => { if (!open) return const onDoc = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false) } document.addEventListener('mousedown', onDoc) return () => document.removeEventListener('mousedown', onDoc) }, [open]) const item = 'flex w-full flex-col items-start rounded px-2 py-1.5 text-left hover:bg-ink-800' return (
{open && (
)} {showShortcuts && setShowShortcuts(false)} />}
) }