Skip to content

Commit

Permalink
wip: collapsible button
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed May 10, 2024
1 parent 8fc7a09 commit 6f78f60
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/site/src/components/DocumentOutline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import classNames from 'classnames';
import throttle from 'lodash.throttle';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { DocumentChartBarIcon } from '@heroicons/react/24/outline';
import { ChevronRightIcon } from '@heroicons/react/24/solid';
import * as Collapsible from '@radix-ui/react-collapsible';


const SELECTOR = [1, 2, 3, 4].map((n) => `main h${n}`).join(', ');
const HIGHLIGHT_CLASS = 'highlight';
Expand Down Expand Up @@ -247,6 +250,7 @@ export const DocumentOutline = ({
return <nav suppressHydrationWarning>{children}</nav>;
}
return (
<Collapsible.Root>
<nav
ref={outlineRef}
aria-label="Document Outline"
Expand All @@ -260,12 +264,25 @@ export const DocumentOutline = ({
maxHeight: `calc(100vh - ${top + 20}px)`,
}}
>
<div className="mb-4 text-sm leading-6 uppercase text-slate-900 dark:text-slate-100">
<div className="mb-4 flex flex-row text-sm gap-2 rounded-lg leading-6 uppercase text-slate-900 dark:text-slate-100">
In this article
</div>

<Collapsible.Trigger asChild>
<button className="self-center flex-none rounded-md group hover:bg-slate-300/30 focus:outline outline-blue-200 outline-2">
<ChevronRightIcon
className="transition-transform duration-300 group-data-[state=open]:rotate-90 text-text-slate-700 dark:text-slate-100"
height="1.5rem"
width="1.5rem"
/>
</button>
</Collapsible.Trigger>
</div>
<Collapsible.Content className="CollapsibleContent">
<Headings headings={headings} activeId={activeId} highlight={highlight} selector={selector} />
{children}
</Collapsible.Content>
</nav>
</Collapsible.Root>
);
};

Expand Down

0 comments on commit 6f78f60

Please sign in to comment.