Elffuss BraidHub

kikocis/continue public

0eda7431cd42 · 1.6 KiBRawPermalink
1import { ChevronDownIcon } from "@heroicons/react/24/outline";
2import { useState } from "react";
3
4interface CollapsibleContainerProps {
5 children: React.ReactNode;
6 maxHeight?: string;
7 className?: string;
8 collapsible?: boolean;
9}
10
11export function CollapsibleContainer({
12 children,
13 maxHeight = "max-h-40",
14 className = "",
15 collapsible = false,
16}: CollapsibleContainerProps) {
17 const [isExpanded, setIsExpanded] = useState(false);
18
19 // If not collapsible, just render children without any collapsible behavior
20 if (!collapsible) {
21 return <div className={className}>{children}</div>;
22 }
23
24 return (
25 <div className={`relative ${className}`}>
26 <div className={`overflow-hidden ${isExpanded ? "" : maxHeight}`}>
27 {children}
28 </div>
29
30 {!isExpanded && (
31 <div className="from-editor absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t to-transparent">
32 <div
33 onClick={() => setIsExpanded(true)}
34 className="group flex h-full cursor-pointer items-end justify-center pb-2"
35 >
36 <span title="Expand to show full content">
37 <ChevronDownIcon className="text-lightgray group-hover:text-foreground h-4 w-4" />
38 </span>
39 </div>
40 </div>
41 )}
42
43 {isExpanded && (
44 <div
45 onClick={() => setIsExpanded(false)}
46 className="group mt-2 flex cursor-pointer justify-center"
47 >
48 <span title="Collapse to compact view">
49 <ChevronDownIcon className="text-lightgray group-hover:text-foreground h-4 w-4 rotate-180" />
50 </span>
51 </div>
52 )}
53 </div>
54 );
55}