-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from neplextech/docgen
fix: render new types
- Loading branch information
Showing
12 changed files
with
384 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,66 @@ | ||
import { Button, cn } from '@edge-ui/react'; | ||
import { Root as Collapsible, CollapsibleTrigger, CollapsibleContent } from '@radix-ui/react-collapsible'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
import { useState } from 'react'; | ||
import { ChevronDown, ChevronUp } from 'lucide-react'; | ||
import { Button, cn } from "@edge-ui/react"; | ||
import { | ||
Root as Collapsible, | ||
CollapsibleTrigger, | ||
CollapsibleContent, | ||
} from "@radix-ui/react-collapsible"; | ||
import Link from "next/link"; | ||
import { useRouter } from "next/router"; | ||
import { useState } from "react"; | ||
import { ChevronDown, ChevronUp } from "lucide-react"; | ||
|
||
interface IProps { | ||
name: string; | ||
data: { name: string; type: string; lib: string }[]; | ||
link?: (name: string) => string; | ||
icon?: React.ReactNode; | ||
name: string; | ||
data: { name: string; type: string; lib: string }[]; | ||
link?: (name: string) => string; | ||
icon?: React.ReactNode; | ||
} | ||
|
||
export function DocsItemList({ data, name, link, icon }: IProps) { | ||
const router = useRouter(); | ||
const [open, setOpen] = useState(true); | ||
const router = useRouter(); | ||
const [open, setOpen] = useState(true); | ||
|
||
return ( | ||
<Collapsible open={open} onOpenChange={setOpen}> | ||
<CollapsibleTrigger className="w-full" asChild> | ||
<Button className="w-full font-bold justify-between rounded-bl-none rounded-tr-none" variant="outline"> | ||
<span className="flex items-center gap-3"> | ||
{icon} {name} | ||
</span>{' '} | ||
{open ? <ChevronUp /> : <ChevronDown />} | ||
</Button> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent className="border-l pl-5"> | ||
{data.map((item) => { | ||
const linker = ( | ||
<h1 | ||
className={cn( | ||
'text-base font-normal text-muted-foreground cursor-pointer', | ||
item.lib === router.query.package && item.name === router.query.target && item.type === router.query.type ? 'font-medium text-secondary' : '' | ||
)} | ||
> | ||
{item.name} | ||
</h1> | ||
); | ||
return ( | ||
<Collapsible open={open} onOpenChange={setOpen}> | ||
<CollapsibleTrigger className="w-full" asChild> | ||
<Button | ||
className="w-full font-bold justify-between rounded-bl-none rounded-tr-none" | ||
variant="outline" | ||
> | ||
<span className="flex items-center gap-3"> | ||
{icon} {name} | ||
</span>{" "} | ||
{open ? <ChevronUp /> : <ChevronDown />} | ||
</Button> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent className="border-l pl-5"> | ||
{data.map((item) => { | ||
const linker = ( | ||
<h1 | ||
className={cn( | ||
"text-base font-normal text-muted-foreground cursor-pointer", | ||
item.lib === router.query.package && | ||
item.name === router.query.target && | ||
item.type === router.query.type | ||
? "font-medium text-secondary" | ||
: "" | ||
)} | ||
> | ||
{item.name} | ||
</h1> | ||
); | ||
|
||
return ( | ||
<div key={item.name} className="hover:bg-secondary"> | ||
{link ? <Link href={link(encodeURIComponent(item.name))}>{linker}</Link> : linker} | ||
</div> | ||
); | ||
})} | ||
</CollapsibleContent> | ||
</Collapsible> | ||
); | ||
return ( | ||
<div key={item.name} className="hover:bg-secondary"> | ||
{link ? ( | ||
<Link href={link(encodeURIComponent(item.name))}>{linker}</Link> | ||
) : ( | ||
linker | ||
)} | ||
</div> | ||
); | ||
})} | ||
</CollapsibleContent> | ||
</Collapsible> | ||
); | ||
} |
Oops, something went wrong.