Skip to content

Commit

Permalink
Improve accordion animations
Browse files Browse the repository at this point in the history
  • Loading branch information
cdedreuille committed Jul 16, 2024
1 parent a033b96 commit 28d155a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/frontpage/components/docs/sidebar/docs-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { cn } from '@repo/utils';
import { VersionSelector } from './version-selector';
import { usePathname, useSelectedLayoutSegment } from 'next/navigation';
import { getVersion } from '../../../lib/get-version';
import { getFlatTree } from '../../../lib/get-flat-tree';

type Tree = TreeProps[] | null | undefined;

Expand All @@ -22,8 +23,12 @@ export const NavDocs: FC<NavDocsProps> = ({ listOfTrees }) => {
const slug: string[] = segment ? segment.split('/') : [];
const activeVersion = getVersion(slug);
const selectedTree = listOfTrees.find((t) => t.name === activeVersion.id);

const [parentAccordion, setParentAccordion] = useState<string[] | null>(null);
// const flatTree = getFlatTree({
// tree: listOfTrees,
// });

// console.log(flatTree);

useEffect(() => {
// Find the active item in the tree and set the parent accordion to open
Expand Down Expand Up @@ -122,7 +127,7 @@ const Level2 = ({ lvl2 }: { lvl2: TreeProps }) => {
/>
</button>
</Accordion.Trigger>
<Accordion.Content>
<Accordion.Content className="data-[state=open]:animate-accordion-down data-[state=closed]:animate-accordion-up overflow-hidden">
<ul>
{lvl2.children?.map((lvl3) => {
return <Level3 key={lvl3.pathSegment} lvl3={lvl3} />;
Expand Down

0 comments on commit 28d155a

Please sign in to comment.