import { ReactNode, useState } from 'react' import { ChevronDownIcon, MoreVerticalIcon, FolderOpenIcon, Code2Icon, } from 'lucide-react' import { twMerge } from 'tailwind-merge' import { useClickOutside } from '@/hooks/useClickOutside' interface Props { children: ReactNode title: string onRevealInFinderClick: (type: string) => void onViewJsonClick: (type: string) => void } export default function CardSidebar({ children, title, onRevealInFinderClick, onViewJsonClick, }: Props) { const [show, setShow] = useState(true) const [more, setMore] = useState(false) const [menu, setMenu] = useState(null) const [toggle, setToggle] = useState(null) useClickOutside(() => setMore(false), null, [menu, toggle]) let openFolderTitle: string = 'Open Containing Folder' if (isMac) { openFolderTitle = 'Reveal in Finder' } else if (isWindows) { openFolderTitle = 'Reveal in File Explorer' } return (
setMore(!more)} >
{more && (
{ onRevealInFinderClick(title) setMore(false) }} > {openFolderTitle}
{ onViewJsonClick(title) setMore(false) }} > View as JSON
)}
{show && (
{children}
)}
) }