Changesets · Branches · Tags · Compare
| Changeset | c850f17d743975f4a83c1b5a175e9c983ea0b63c729ae18fe4978b51e032d180 |
|---|---|
| Author | Nate <sestinj@gmail.com> · 2025-07-04 22:19 -07:00 |
| Committer | Nate <sestinj@gmail.com> · 2025-07-04 22:19 -07:00 |
| Parents | f93f67ceefea |
2 files changed
added gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/CollapsibleContainer.tsx +48 −0
| @@ -0,0 +1,48 @@ | ||
| 1 | +import { ChevronDownIcon } from "@heroicons/react/24/outline"; | |
| 2 | +import { useState } from "react"; | |
| 3 | + | |
| 4 | +interface CollapsibleContainerProps { | |
| 5 | + children: React.ReactNode; | |
| 6 | + maxHeight?: string; | |
| 7 | + className?: string; | |
| 8 | +} | |
| 9 | + | |
| 10 | +export 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="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 h-4 w-4" /> | |
| 31 | + </span> | |
| 32 | + </div> | |
| 33 | + </div> | |
| 34 | + )} | |
| 35 | + | |
| 36 | + {isExpanded && ( | |
| 37 | + <div | |
| 38 | + onClick={() => setIsExpanded(false)} | |
| 39 | + className="mt-2 flex cursor-pointer justify-center" | |
| 40 | + > | |
| 41 | + <span title="Collapse to compact view"> | |
| 42 | + <ChevronDownIcon className="text-lightgray h-4 w-4 rotate-180" /> | |
| 43 | + </span> | |
| 44 | + </div> | |
| 45 | + )} | |
| 46 | + </div> | |
| 47 | + ); | |
| 48 | +} |
modified gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx +2 −3
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | import Spinner from "../../gui/Spinner"; |
| 14 | 14 | import { isTerminalCodeBlock } from "../utils"; |
| 15 | 15 | import { ApplyActions } from "./ApplyActions"; |
| 16 | +import { CollapsibleContainer } from "./CollapsibleContainer"; | |
| 16 | 17 | import { CopyButton } from "./CopyButton"; |
| 17 | 18 | import { CreateFileButton } from "./CreateFileButton"; |
| 18 | 19 | import { FileInfo } from "./FileInfo"; |
| @@ -299,9 +300,7 @@ | ||
| 299 | 300 | </div> |
| 300 | 301 | </div> |
| 301 | 302 | |
| 302 | - {isExpanded && ( | |
| 303 | - <div className="overflow-hidden overflow-y-auto">{children}</div> | |
| 304 | - )} | |
| 303 | + {isExpanded && <CollapsibleContainer>{children}</CollapsibleContainer>} | |
| 305 | 304 | </div> |
| 306 | 305 | ); |
| 307 | 306 | } |