moving v2 to top level

This commit is contained in:
2024-12-17 09:19:21 -07:00
parent 5f0b3554dc
commit 576ee02afb
468 changed files with 79 additions and 15430 deletions

View File

@@ -0,0 +1,36 @@
"use client";
import { ReactNode, Dispatch, SetStateAction, useState, useRef } from "react";
export function Expandable({
children,
ExpandableElement,
defaultExpanded = false,
}: {
children: ReactNode;
ExpandableElement: (props: {
setIsExpanded: Dispatch<SetStateAction<boolean>>;
isExpanded: boolean;
}) => ReactNode;
defaultExpanded?: boolean;
}) {
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
const expandRef = useRef<HTMLDivElement | null>(null);
return (
<>
<ExpandableElement
setIsExpanded={setIsExpanded}
isExpanded={isExpanded}
/>
<div
ref={expandRef}
className={` overflow-hidden transition-all `}
style={{
maxHeight: isExpanded ? expandRef?.current?.scrollHeight : "0",
}}
>
{children}
</div>
</>
);
}