|
1 | 1 | import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"; |
2 | 2 | import { useCallback, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from "react"; |
| 3 | +import { Collapsible, CollapsiblePanel } from "~/components/ui/collapsible"; |
3 | 4 | import { cn } from "~/lib/utils"; |
4 | 5 | import { ApprovalBadge } from "./ApprovalBadge"; |
5 | 6 | import { StatusBadge, type ToolStatusKind } from "./StatusBadge"; |
@@ -151,29 +152,33 @@ export function ToolCard(props: ToolCardProps) { |
151 | 152 | /> |
152 | 153 | )} |
153 | 154 | </HeaderRow> |
154 | | - {anyBody && isOpen && ( |
155 | | - <div className={cn("overflow-hidden border-t border-border/20", bodyClassName)}> |
156 | | - {showPreview && bodyAvailable && ( |
157 | | - <div className="relative"> |
158 | | - <div |
159 | | - ref={previewRef} |
160 | | - className="overflow-hidden" |
161 | | - style={{ maxHeight: `${bodyMaxPreviewPx}px` }} |
162 | | - > |
163 | | - {body} |
164 | | - </div> |
165 | | - {showFullCtaVisible && <ShowFullButton onClick={expandFully} />} |
166 | | - </div> |
167 | | - )} |
168 | | - {showExpanded && ( |
169 | | - <> |
170 | | - {expandedBodyAvailable ? expandedBody : body} |
171 | | - {bodyAvailable && ( |
172 | | - <HideButton onClick={() => setState(bodyAvailable ? "preview" : "collapsed")} /> |
| 155 | + {anyBody && ( |
| 156 | + <Collapsible open={isOpen}> |
| 157 | + <CollapsiblePanel> |
| 158 | + <div className={cn("border-t border-border/20", bodyClassName)}> |
| 159 | + {showPreview && bodyAvailable && ( |
| 160 | + <div className="relative"> |
| 161 | + <div |
| 162 | + ref={previewRef} |
| 163 | + className="overflow-hidden" |
| 164 | + style={{ maxHeight: `${bodyMaxPreviewPx}px` }} |
| 165 | + > |
| 166 | + {body} |
| 167 | + </div> |
| 168 | + {showFullCtaVisible && <ShowFullButton onClick={expandFully} />} |
| 169 | + </div> |
| 170 | + )} |
| 171 | + {showExpanded && ( |
| 172 | + <> |
| 173 | + {expandedBodyAvailable ? expandedBody : body} |
| 174 | + {bodyAvailable && ( |
| 175 | + <HideButton onClick={() => setState(bodyAvailable ? "preview" : "collapsed")} /> |
| 176 | + )} |
| 177 | + </> |
173 | 178 | )} |
174 | | - </> |
175 | | - )} |
176 | | - </div> |
| 179 | + </div> |
| 180 | + </CollapsiblePanel> |
| 181 | + </Collapsible> |
177 | 182 | )} |
178 | 183 | </div> |
179 | 184 | ); |
|
0 commit comments