mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
|
|
import { ChevronRight, type LucideIcon } from "lucide-react";
|
||
|
|
import { useState, type ReactNode } from "react";
|
||
|
|
import { cn } from "../lib/utils";
|
||
|
|
import {
|
||
|
|
Collapsible,
|
||
|
|
CollapsibleContent,
|
||
|
|
CollapsibleTrigger,
|
||
|
|
} from "@/components/ui/collapsible";
|
||
|
|
|
||
|
|
interface SidebarSectionProps {
|
||
|
|
label: string;
|
||
|
|
icon?: LucideIcon;
|
||
|
|
children: ReactNode;
|
||
|
|
defaultOpen?: boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function SidebarSection({
|
||
|
|
label,
|
||
|
|
children,
|
||
|
|
defaultOpen = true,
|
||
|
|
}: SidebarSectionProps) {
|
||
|
|
const [open, setOpen] = useState(defaultOpen);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Collapsible open={open} onOpenChange={setOpen}>
|
||
|
|
<CollapsibleTrigger className="flex items-center gap-1 w-full px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors">
|
||
|
|
<ChevronRight
|
||
|
|
className={cn(
|
||
|
|
"h-3 w-3 transition-transform",
|
||
|
|
open && "rotate-90"
|
||
|
|
)}
|
||
|
|
/>
|
||
|
|
{label}
|
||
|
|
</CollapsibleTrigger>
|
||
|
|
<CollapsibleContent>
|
||
|
|
<div className="flex flex-col gap-0.5 mt-0.5">{children}</div>
|
||
|
|
</CollapsibleContent>
|
||
|
|
</Collapsible>
|
||
|
|
);
|
||
|
|
}
|