Download src/components/features/diff-viewer/accordion-panel.tsx from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/components/features/diff-viewer/accordion-panel.tsx
- Command line
-
hf download hf://SaylorTwift/openhands/src/components/features/diff-viewer/accordion-panel.tsx
-
curl -L -o accordion-panel.tsx https://huggingface.co/SaylorTwift/openhands/resolve/main/src/components/features/diff-viewer/accordion-panel.tsx
1.27 kB
| import type { ReactNode } from "react"; | |
| import { AnimatePresence, motion, useReducedMotion } from "framer-motion"; | |
| import { cn } from "#/utils/utils"; | |
| const ACCORDION_TRANSITION = { | |
| duration: 0.2, | |
| ease: "easeInOut" as const, | |
| }; | |
| interface AccordionPanelProps { | |
| open: boolean; | |
| children: ReactNode; | |
| testId?: string; | |
| className?: string; | |
| } | |
| /** | |
| * Height/opacity expand-collapse wrapper for Diffs / Commits accordion rows. | |
| * Honors prefers-reduced-motion by skipping animation. | |
| */ | |
| export function AccordionPanel({ | |
| open, | |
| children, | |
| testId, | |
| className, | |
| }: AccordionPanelProps) { | |
| const reduceMotion = useReducedMotion(); | |
| if (reduceMotion) { | |
| return open ? ( | |
| <div data-testid={testId} className={className}> | |
| {children} | |
| </div> | |
| ) : null; | |
| } | |
| return ( | |
| <AnimatePresence initial={false}> | |
| {open ? ( | |
| <motion.div | |
| key="accordion-panel" | |
| data-testid={testId} | |
| initial={{ height: 0, opacity: 0 }} | |
| animate={{ height: "auto", opacity: 1 }} | |
| exit={{ height: 0, opacity: 0 }} | |
| transition={ACCORDION_TRANSITION} | |
| className={cn("overflow-hidden", className)} | |
| > | |
| {children} | |
| </motion.div> | |
| ) : null} | |
| </AnimatePresence> | |
| ); | |
| } | |