-
-
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): show union members of type aliases (#10001)
* feat(website): show union members of type aliases * refactor: suggestions from code review * Apply suggestions from code review --------- Co-authored-by: Noel <[email protected]>
- Loading branch information
Showing
3 changed files
with
125 additions
and
48 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
apps/website/src/components/documentation/section/UnionMembersSection.tsx
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Excerpt, type ApiTypeAlias, type ExcerptToken } from '@discordjs/api-extractor-model'; | ||
import { VscSymbolArray } from '@react-icons/all-files/vsc/VscSymbolArray'; | ||
import { useMemo } from 'react'; | ||
import { ExcerptText } from '~/components/ExcerptText'; | ||
import { DocumentationSection } from './DocumentationSection'; | ||
|
||
export type UnionMember = ExcerptToken[]; | ||
|
||
export function UnionMembersSection({ | ||
item, | ||
members, | ||
}: { | ||
readonly item: ApiTypeAlias; | ||
readonly members: UnionMember[]; | ||
}) { | ||
const unionMembers = useMemo( | ||
() => | ||
members.map((member, idx) => ( | ||
<div className="flex flex-row place-items-center gap-4" key={`union-${idx}`}> | ||
<span className="break-all font-mono space-y-2"> | ||
<ExcerptText | ||
excerpt={new Excerpt(member, { startIndex: 0, endIndex: member.length })} | ||
apiPackage={item.getAssociatedPackage()!} | ||
/> | ||
</span> | ||
</div> | ||
)), | ||
[item, members], | ||
); | ||
|
||
return ( | ||
<DocumentationSection icon={<VscSymbolArray size={20} />} padded title="Union Members"> | ||
<div className="flex flex-col gap-4">{unionMembers}</div> | ||
</DocumentationSection> | ||
); | ||
} |
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
a44ada6
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 – ./apps/website
discord-js-number-one.vercel.app
discord-js-discordjs.vercel.app
discord-js-git-main-discordjs.vercel.app
www.discordjs.dev
discordjs.dev
discord.js.org