Skip to content

Commit 0e5d120

Browse files
[Documentation] Refactor: Update tsdoc references (#5374)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on refactoring the `NFT` component and its related functionalities to improve performance, enhance control over fetching logic, and simplify usage by removing the need for `React.Suspense`. It also introduces new props for better loading and error handling. ### Detailed summary - Deleted several test files and an unused `NFT.tsx` file. - Introduced `NFTProvider`, `NFTMedia`, `NFTName`, and `NFTDescription` components. - Added `loadingComponent` and `fallbackComponent` props for better handling of loading states and errors. - Updated references in tests to use new component structure. - Renamed and adjusted documentation comments to reflect new functionality. - Improved sidebar organization by updating links and names for consistency. - Enhanced utility functions and hooks for better NFT data fetching and context management. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent f368793 commit 0e5d120

File tree

68 files changed

+645
-1149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+645
-1149
lines changed

.changeset/tall-pots-live.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
# Breaking change
6+
7+
We are making the following changes to the NFT component to provide better performance and fine-grain control over their internal fetching logic.
8+
Moreover, you no longer have to wrap React.Suspense around said components!
9+
10+
### Old
11+
12+
```tsx
13+
<NFT>
14+
<React.Suspense fallback={"Loading stuff..."}>
15+
<NFT.Media />
16+
<NFT.Name />
17+
<NFT.Description />
18+
</React.Suspense>
19+
</NFT>
20+
```
21+
22+
### New
23+
24+
The new version comes with 2 new props: `loadingComponent` and `fallbackComponent`.
25+
Basically, `loadingComponent` takes in a component and show it _while the internal fetching is being done_
26+
`fallbackComponent` takes in a component and show it _once the data is failed to be resolved_
27+
28+
```tsx
29+
<NFTProvider contract={contract} tokenId={0n}>
30+
<NFTMedia
31+
loadingComponent={<span>Loading NFT Image</span>}
32+
fallbackComponent={<span>Failed to load NFT</span>}
33+
/>
34+
<NFTDescription
35+
loadingComponent={<span>Loading NFT Description</span>}
36+
fallbackComponent={<span>Failed to load NFT Description</span>}
37+
/>
38+
</NFT>
39+
```

apps/portal/src/app/contracts/sidebar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export const sidebar: SideBar = {
239239
],
240240
},
241241
{
242-
name: "Misc",
242+
name: "Miscellaneous",
243243
links: [
244244
{
245245
name: "TransferableERC20",
@@ -283,7 +283,7 @@ export const sidebar: SideBar = {
283283
],
284284
},
285285
{
286-
name: "Misc",
286+
name: "Miscellaneous",
287287
links: [
288288
{
289289
name: "RoyaltyERC721",
@@ -327,7 +327,7 @@ export const sidebar: SideBar = {
327327
],
328328
},
329329
{
330-
name: "Misc",
330+
name: "Miscellaneous",
331331
links: [
332332
{
333333
name: "RoyaltyERC1155",

apps/portal/src/app/react-native/v5/getting-started/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We recommend starting a new thirdweb React Native project using our CLI, which s
99
In your CLI, run:
1010

1111
```bash
12-
npx thirdweb create --legacy-peer-deps --react-native
12+
npx thirdweb create app --react-native
1313
```
1414

1515
or clone the [expo-starter](https://github.com/thirdweb-dev/expo-starter) repo using git.

apps/portal/src/app/react-native/v5/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Many of the components and hooks in the React Native SDK use a [`client`](/types
6060
If you want to get started quickly run:
6161

6262
```bash
63-
npx thirdweb create --legacy-peer-deps --react-native
63+
npx thirdweb create app --react-native
6464
```
6565

6666
or clone the [expo-starter](https://github.com/thirdweb-dev/expo-starter) repo using git.

apps/portal/src/app/react/v5/getting-started/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can get started by creating a new project or adding thirdweb to an existing
99
You can quickly create a new project with the thirdweb CLI
1010

1111
```bash
12-
npx thirdweb create app --legacy-peer-deps
12+
npx thirdweb create app
1313
```
1414

1515
or clone the the Next.js or Vite starter repo:

apps/portal/src/app/react/v5/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Follow this [guide](/react/v5/getting-started) to get started with the React SDK
5252
You can quickly create a new project with the thirdweb CLI
5353

5454
```bash
55-
npx thirdweb create app --legacy-peer-deps
55+
npx thirdweb create app
5656
```
5757

5858
or clone the the Next.js or Vite starter repo:

apps/portal/src/app/react/v5/sidebar.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,29 @@ export const sidebar: SideBar = {
320320
links: [
321321
{
322322
name: "UI Components",
323-
links: ["ClaimButton", "TransactionButton", "MediaRenderer"].map(
324-
(name) => ({
325-
name,
326-
href: `${slug}/${name}`,
327-
icon: <CodeIcon />,
328-
}),
329-
),
323+
links: [
324+
...["ClaimButton", "TransactionButton", "MediaRenderer"].map(
325+
(name) => ({
326+
name,
327+
href: `${slug}/${name}`,
328+
icon: <CodeIcon />,
329+
}),
330+
),
331+
{
332+
name: "NFT",
333+
isCollapsible: true,
334+
links: [
335+
"NFTProvider",
336+
"NFTMedia",
337+
"NFTName",
338+
"NFTDescription",
339+
].map((name) => ({
340+
name,
341+
href: `${slug}/${name}`,
342+
icon: <CodeIcon />,
343+
})),
344+
},
345+
],
330346
},
331347
{
332348
name: "Reading State",

apps/portal/src/app/references/components/TDoc/utils/getSidebarLinkgroups.ts

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const tagsToGroup = {
2626
"@connectWallet": "Connect Wallet",
2727
"@appURI": "App URI",
2828
"@storage": "Storage",
29-
"@others": "Others",
29+
"@others": "Miscellaneous",
3030
"@wallet": "Wallets",
3131
"@walletConfig": "WalletConfig",
3232
"@theme": "Theme",
@@ -40,20 +40,25 @@ const tagsToGroup = {
4040
"@chain": "Chain",
4141
"@social": "Social API",
4242
"@modules": "Modules",
43+
"@client": "Client",
4344
} as const;
4445

4546
type TagKey = keyof typeof tagsToGroup;
4647

4748
const sidebarGroupOrder: TagKey[] = [
49+
"@client",
4850
"@wallet",
4951
"@abstractWallet",
5052
"@locale",
51-
"@chain",
52-
"@contract",
5353
"@networkConnection",
5454
"@walletConfig",
5555
"@walletConnection",
5656
"@walletUtils",
57+
"@chain",
58+
"@contract",
59+
"@transaction",
60+
"@social",
61+
"@auth",
5762
"@nft",
5863
"@buyCrypto",
5964
"@nftDrop",
@@ -64,18 +69,15 @@ const sidebarGroupOrder: TagKey[] = [
6469
"@metadata",
6570
"@permissionControl",
6671
"@platformFees",
67-
"@auth",
6872
"@storage",
6973
"@smartWallet",
7074
"@connectWallet",
7175
"@appURI",
7276
"@extension",
73-
"@transaction",
7477
"@rpc",
75-
"@utils",
76-
"@social",
7778
"@modules",
7879
"@theme",
80+
"@utils",
7981
"@others",
8082
];
8183

@@ -191,6 +193,7 @@ export function getSidebarLinkGroups(doc: TransformedDoc, path: string) {
191193
name: name,
192194
href: getLink(`${path}/${key}`),
193195
links: [{ name: "Extensions", links: extensionLinkGroups }],
196+
isCollapsible: false,
194197
});
195198
} else {
196199
linkGroups
@@ -245,7 +248,12 @@ export function getSidebarLinkGroups(doc: TransformedDoc, path: string) {
245248

246249
// sort into groups
247250
for (const d of nonExtensions) {
248-
const [tag] = getCustomTag(d) || [];
251+
let [tag] = getCustomTag(d) || [];
252+
// for ungrouped functions - put it in utils
253+
// useful for re-exports that we can't tag
254+
if (!tag) {
255+
tag = "@others";
256+
}
249257

250258
if (tag) {
251259
if (!groups[tag]) {
@@ -257,16 +265,6 @@ export function getSidebarLinkGroups(doc: TransformedDoc, path: string) {
257265
}
258266
}
259267

260-
// If a group only has one item, do not create a group for it and add it to noGroups
261-
for (const _tag in groups) {
262-
const tag = _tag as TagKey;
263-
const links = groups[tag];
264-
if (links && links.length === 1 && links[0]) {
265-
ungroupedLinks.push(links[0]);
266-
delete groups[tag];
267-
}
268-
}
269-
270268
// throw error if we don't know where to put the group in sidebar ( because this leads to it not being added in sidebar at all )
271269
for (const tag of Object.keys(groups)) {
272270
if (!sidebarGroupOrder.includes(tag as TagKey)) {
@@ -314,6 +312,7 @@ export function getSidebarLinkGroups(doc: TransformedDoc, path: string) {
314312
name: name,
315313
links: links,
316314
href: getLink(`${path}/${key}`),
315+
isCollapsible: false,
317316
});
318317
}
319318
}
@@ -326,26 +325,10 @@ export function getSidebarLinkGroups(doc: TransformedDoc, path: string) {
326325
createSubGroups("hooks", doc.hooks);
327326
}
328327

329-
if (doc.classes) {
330-
createSubGroups("classes", doc.classes);
331-
}
332-
333328
if (doc.functions) {
334329
createSubGroups("functions", doc.functions);
335330
}
336331

337-
if (doc.variables) {
338-
createSubGroups("variables", doc.variables);
339-
}
340-
341-
if (doc.types) {
342-
createSubGroups("types", doc.types);
343-
}
344-
345-
if (doc.enums) {
346-
createSubGroups("enums", doc.enums);
347-
}
348-
349332
return linkGroups;
350333
}
351334

apps/portal/src/app/references/components/TDoc/utils/subgroups.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const subgroups = {
2-
components: "Components",
3-
hooks: "Hooks",
2+
components: "UI Components",
3+
hooks: "React Hooks",
44
classes: "Classes",
5-
functions: "Functions",
5+
functions: "Core Functions",
66
variables: "Variables",
77
types: "Types",
88
enums: "Enums",

apps/portal/src/app/references/typescript/[version]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createMetadata } from "@doc";
55
export default getTDocLayout({
66
getDoc: fetchTypeScriptDoc,
77
packageSlug: "typescript",
8-
sdkTitle: "TypeScript SDK",
8+
sdkTitle: "Connect SDK",
99
});
1010

1111
export const metadata = createMetadata({

apps/portal/src/app/unity/v5/thirdwebmanager/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This section allows you to define the default preferences for the SDK:
4646
- `Show Debug Logs`: Whether to show thirdweb SDK debug logs.
4747
- `Opt Out Usage Analytics`: Whether to opt out of Connect usage analytics, such as the number of wallets connected to your game.
4848

49-
### Misc
49+
### Miscellaneous
5050

5151
<DocImage src={thirdwebmanager_misc} />
5252

apps/portal/src/components/others/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function DocSidebarNonCollapsible(props: {
151151
{href ? (
152152
<Link
153153
className={cn(
154-
"block font-medium text-base text-f-100 hover:text-accent-500",
154+
"block font-semibold text-base text-f-100 hover:text-accent-500",
155155
isCategoryActive && "!text-accent-500",
156156
)}
157157
href={href}

packages/thirdweb/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@
10551055

10561056
<NFT contract={contract} tokenId={0n}>
10571057
<Suspense fallback={"Loading media..."}>
1058-
<NFT.Media />
1058+
<NFTMedia />
10591059
</Suspense>
10601060
</NFT>;
10611061
```

packages/thirdweb/scripts/typedoc.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import TypeDoc from "typedoc";
44
const jsonOut = "typedoc/documentation.json";
55

66
const app = await TypeDoc.Application.bootstrapWithPlugins({
7-
entryPoints: ["src/exports/**/*.ts", "src/extensions/modules/**/index.ts"],
7+
entryPoints: [
8+
"src/exports/**/*.ts",
9+
"src/extensions/modules/**/index.ts",
10+
"src/react/web/ui/prebuilt/NFT/index.ts",
11+
],
812
exclude: [
913
"src/exports/*.native.ts",
1014
"src/exports/**/*.native.ts",

packages/thirdweb/src/client/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export type ThirdwebClient = {
9898
*
9999
* const client = createThirdwebClient({ secretKey: "..." });
100100
* ```
101+
* @client
101102
*/
102103
export function createThirdwebClient(
103104
options: CreateThirdwebClientOptions,

packages/thirdweb/src/exports/react.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,23 @@ export {
173173
type CreateDirectListingButtonProps,
174174
} from "../react/web/ui/prebuilt/thirdweb/CreateDirectListingButton/index.js";
175175

176+
// NFT rendering components
176177
export {
177-
NFT,
178+
NFTProvider,
179+
type NFTProviderProps,
180+
} from "../react/web/ui/prebuilt/NFT/provider.js";
181+
export {
182+
NFTName,
183+
type NFTNameProps,
184+
} from "../react/web/ui/prebuilt/NFT/name.js";
185+
export {
186+
NFTDescription,
187+
type NFTDescriptionProps,
188+
} from "../react/web/ui/prebuilt/NFT/description.js";
189+
export {
190+
NFTMedia,
178191
type NFTMediaProps,
179-
} from "../react/web/ui/prebuilt/NFT/NFT.js";
192+
} from "../react/web/ui/prebuilt/NFT/media.js";
180193

181194
export { useConnectionManager } from "../react/core/providers/connection-manager.js";
182195

packages/thirdweb/src/extensions/erc721/lazyMinting/read/getBatchesToReveal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface BatchToReveal {
2525
* @param options.contract {@link ThirdwebContract} - The NFT contract instance.
2626
* @returns A promise resolving to an array of unrevealed batches.
2727
*
28-
* @note Use the `batchId` and corresponding password for each batch to reveal it with `reveal`. {@see reveal}
28+
* Use the `batchId` and corresponding password for each batch to reveal it with `reveal`. {@see reveal}
2929
* @extension ERC721
3030
* @example
3131
* ```ts

packages/thirdweb/src/extensions/modules/common/checkModulesCompatibility.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import {
1818
FN_SELECTOR as getModuleConfigSelector,
1919
} from "../__generated__/IModule/read/getModuleConfig.js";
2020

21+
/**
22+
* Check if the given modules are compatible with the given core contract
23+
* @param options
24+
* @modules
25+
*/
2126
export async function checkModulesCompatibility(options: {
2227
coreBytecode: string;
2328
moduleBytecodes: string[];

packages/thirdweb/src/extensions/prebuilts/deploy-pack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export type DeployPackContractOptions = Prettify<
7373
* },
7474
* });
7575
* ```
76+
* @extension DEPLOY
7677
*/
7778
export async function deployPackContract(options: DeployPackContractOptions) {
7879
const { chain, client, account, params } = options;

0 commit comments

Comments
 (0)