Elffuss BraidHub

kikocis/continue public

0cdb3e901c09 · 1.4 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}
9
10export function CollapsibleContainer({
11 children,
12 maxHeight = "max-h-40",
13 className = "",
14}: CollapsibleContainerProps) {
15 const [isExpanded, setIsExpanded] = useState(false);
16
17 return (
18 <div className={`relative ${className}`}>
19 <div className={`overflow-hidden ${isExpanded ? "" : maxHeight}`}>
20 {children}
21 </div>
22
23 {!isExpanded && (
24 <div className="from-editor absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t to-transparent">
25 <div
26 onClick={() => setIsExpanded(true)}
27 className="group flex h-full cursor-pointer items-end justify-center pb-2"
28 >
29 <span title="Expand to show full content">
30 <ChevronDownIcon className="text-lightgray group-hover:text-foreground h-4 w-4" />
31 </span>
32 </div>
33 </div>
34 )}
35
36 {isExpanded && (
37 <div
38 onClick={() => setIsExpanded(false)}
39 className="group mt-2 flex cursor-pointer justify-center"
40 >
41 <span title="Collapse to compact view">
42 <ChevronDownIcon className="text-lightgray group-hover:text-foreground h-4 w-4 rotate-180" />
43 </span>
44 </div>
45 )}
46 </div>
47 );
48}