The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
import { useState } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { ChevronRight, HelpCircle } from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import { cn } from './cn'
import { Tooltip } from './Tooltip'
interface Props {
title: string
icon?: LucideIcon
help?: string
collapsible?: boolean
defaultOpen?: boolean
/** Given together: the caller keeps whether the section is open, so it can
* outlive the panel this section sits in. Without them the section keeps
* it itself and starts from `defaultOpen` on every mount. */
open?: boolean
onOpenChange?: (open: boolean) => void
right?: React.ReactNode
children: React.ReactNode
}
export function Section({ title, icon: Icon, help, collapsible = true, defaultOpen = true, open: heldOpen, onOpenChange, right, children }: Props) {
const [ownOpen, setOwnOpen] = useState(defaultOpen)
const open = heldOpen ?? ownOpen
const toggle = () => {
if (!collapsible) return
if (onOpenChange) onOpenChange(!open)
else setOwnOpen(!open)
}
return (
<div className="border-b border-white/[0.05] last:border-b-0">
<div className="flex items-center justify-between py-2.5">
<button onClick={toggle} className={cn('flex items-center gap-1.5 group', !collapsible && 'cursor-default')}>
{collapsible && (
<ChevronRight size={13} className={cn('text-gray-600 transition-transform', open && 'rotate-90')} />
)}
{Icon && <Icon size={13} className="text-gray-500" />}
<span className="t-label text-gray-400 group-hover:text-gray-300">{title}</span>
{help && (
<Tooltip content={help}>
<HelpCircle size={12} className="text-gray-600 hover:text-gray-400" />
</Tooltip>
)}
</button>
{right}
</div>
<AnimatePresence initial={false}>
{open && (
<motion.div
initial={{ height: 0, opacity: 0 }}
animate={{ height: 'auto', opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
transition={{ duration: 0.18 }}
className="overflow-hidden"
>
<div className="pb-3 space-y-3">{children}</div>
</motion.div>
)}
</AnimatePresence>
</div>
)
}