mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 04:51:51 +00:00
40 lines
867 B
TypeScript
40 lines
867 B
TypeScript
"use client";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
interface ExpandableSectionProps {
|
|
isExpanded: boolean;
|
|
children: React.ReactNode;
|
|
className?: string;
|
|
contentClassName?: string;
|
|
}
|
|
|
|
/**
|
|
* Animated expandable section using CSS grid for smooth height transitions.
|
|
* Animates from height 0 to auto content height.
|
|
*/
|
|
export function ExpandableSection({
|
|
isExpanded,
|
|
children,
|
|
className,
|
|
contentClassName,
|
|
}: ExpandableSectionProps) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"grid transition-[grid-template-rows] duration-300 ease-in-out",
|
|
isExpanded ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
|
|
className,
|
|
)}
|
|
>
|
|
<div className="overflow-hidden">
|
|
<div
|
|
className={cn("pt-4", contentClassName, !isExpanded && "invisible")}
|
|
>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|