-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): use dropdowns for overloads (#8630)
Co-authored-by: Almeida <[email protected]> Co-authored-by: iCrawl <[email protected]>
- Loading branch information
1 parent
0785353
commit 678ceaa
Showing
8 changed files
with
152 additions
and
28 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 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
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
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,17 +1,60 @@ | ||
import type { ApiFunctionJSON } from '@discordjs/api-extractor-utils'; | ||
import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit'; | ||
import { useState } from 'react'; | ||
import { VscChevronDown, VscVersions } from 'react-icons/vsc'; | ||
import { DocContainer } from '../DocContainer'; | ||
import { ParametersSection } from '../Sections'; | ||
|
||
export function Function({ data }: { data: ApiFunctionJSON }) { | ||
const [overloadIndex, setOverloadIndex] = useState(1); | ||
const overloadedData = data.mergedSiblings[overloadIndex - 1]!; | ||
const menu = useMenuState({ gutter: 8, sameWidth: true, fitViewport: true }); | ||
|
||
return ( | ||
<DocContainer | ||
name={`${data.name}${data.overloadIndex && data.overloadIndex > 1 ? ` (${data.overloadIndex})` : ''}`} | ||
kind={data.kind} | ||
excerpt={data.excerpt} | ||
summary={data.summary} | ||
typeParams={data.typeParameters} | ||
name={`${overloadedData.name}${ | ||
overloadedData.overloadIndex && overloadedData.overloadIndex > 1 ? ` (${overloadedData.overloadIndex})` : '' | ||
}`} | ||
kind={overloadedData.kind} | ||
excerpt={overloadedData.excerpt} | ||
summary={overloadedData.summary} | ||
typeParams={overloadedData.typeParameters} | ||
subHeading={ | ||
data.mergedSiblings.length > 1 ? ( | ||
<div className="flex flex-row place-items-center gap-2"> | ||
<MenuButton | ||
state={menu} | ||
className="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-600 dark:hover:bg-dark-500 dark:active:bg-dark-400 rounded p-3" | ||
> | ||
<div className="flex flex-row place-content-between place-items-center gap-2"> | ||
<VscVersions size={20} /> | ||
<div> | ||
<span className="font-semibold">{`Overload ${overloadIndex}`}</span> | ||
{` of ${data.mergedSiblings.length}`} | ||
</div> | ||
<VscChevronDown | ||
className={`transform transition duration-150 ease-in-out ${menu.open ? 'rotate-180' : 'rotate-0'}`} | ||
size={20} | ||
/> | ||
</div> | ||
</MenuButton> | ||
<Menu | ||
state={menu} | ||
className="dark:bg-dark-600 border-light-800 dark:border-dark-100 z-20 flex flex-col rounded border bg-white p-1" | ||
> | ||
{data.mergedSiblings.map((_, idx) => ( | ||
<MenuItem | ||
key={idx} | ||
className="hover:bg-light-700 active:bg-light-800 dark:bg-dark-600 dark:hover:bg-dark-500 dark:active:bg-dark-400 cursor-pointer rounded bg-white p-3 text-sm" | ||
onClick={() => setOverloadIndex(idx + 1)} | ||
>{`Overload ${idx + 1}`}</MenuItem> | ||
))} | ||
</Menu> | ||
</div> | ||
) : null | ||
} | ||
> | ||
<ParametersSection data={data.parameters} /> | ||
<ParametersSection data={overloadedData.parameters} /> | ||
</DocContainer> | ||
); | ||
} |
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
678ceaa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
discord-js – ./
discord-js-number-one.vercel.app
discord-js-discordjs.vercel.app
discord-js-git-main-discordjs.vercel.app
www.discordjs.dev
discordjs.dev