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 asChild?: boolean } export default function CardSidebar({ children, title, onRevealInFinderClick, onViewJsonClick, asChild, }: 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 (
{title}
{!asChild && (
setMore(!more)} >
)}
{more && (
{ onRevealInFinderClick && onRevealInFinderClick(title) setMore(false) }} > <> {title === 'Model' ? (
{openFolderTitle} Opens thread.json. Changes affect this thread only.
) : ( {openFolderTitle} )}
{ onViewJsonClick && onViewJsonClick(title) setMore(false) }} > <>
View as JSON Opens {title}.json.  Changes affect all new threads.
)}
{show && (
{children}
)}
) }