Skip to content

Commit b781a3f

Browse files
committed
Migrate usage/storage page to shadcn+tailwind
1 parent 96bdc5a commit b781a3f

File tree

6 files changed

+357
-741
lines changed

6 files changed

+357
-741
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { TrackedLinkTW } from "@/components/ui/tracked-link";
2+
3+
const TRACKING_CATEGORY = "storage";
4+
5+
const links = [
6+
{
7+
title: "Documentation",
8+
url: "https://docs.thirdweb.com/storage",
9+
},
10+
{
11+
title: "How To Upload And Pin Files to IPFS",
12+
url: "https://blog.thirdweb.com/guides/how-to-upload-and-pin-files-to-ipfs-using-storage/",
13+
},
14+
];
15+
16+
const videos = [
17+
{
18+
title: "How To Easily Add IPFS Into Your Web3 App",
19+
url: "https://www.youtube.com/watch?v=4Nnu9Cy7SKc",
20+
},
21+
{
22+
title: "How to Upload Files to IPFS (Step by Step Guide)",
23+
url: "https://www.youtube.com/watch?v=wyYkpMgEVxE",
24+
},
25+
];
26+
27+
export function GuidesSection() {
28+
return (
29+
<div className="grid grid-cols-1 gap-6 md:grid-cols-2">
30+
<LinkSectionCard title="Guides" links={links} />
31+
<LinkSectionCard title="Videos" links={videos} />
32+
</div>
33+
);
34+
}
35+
36+
function LinkSectionCard(props: {
37+
title: string;
38+
links: { title: string; url: string }[];
39+
}) {
40+
return (
41+
<div className="flex min-h-[150px] flex-col rounded-lg border border-border p-4">
42+
<h2 className="mb-3 font-semibold text-xl tracking-tight">
43+
{props.title}
44+
</h2>
45+
<ul className="mt-auto flex flex-col gap-1.5">
46+
{props.links.map((link) => {
47+
return (
48+
<li key={link.url}>
49+
<TrackedLinkTW
50+
href={link.url}
51+
category={TRACKING_CATEGORY}
52+
className="inline-block text-muted-foreground hover:text-foreground"
53+
>
54+
{link.title}
55+
</TrackedLinkTW>
56+
</li>
57+
);
58+
})}
59+
</ul>
60+
</div>
61+
);
62+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
"use client";
2+
3+
import {
4+
type CodeEnvironment,
5+
CodeSegment,
6+
} from "@/components/blocks/code-segment.client";
7+
import { useState } from "react";
8+
9+
export function SDKSection() {
10+
const [codeEnvironment, setCodeEnvironment] =
11+
useState<CodeEnvironment>("javascript");
12+
13+
return (
14+
<div>
15+
<h2 className="mb-2 font-semibold text-lg tracking-tight">
16+
Integrate into your app
17+
</h2>
18+
19+
<CodeSegment
20+
snippet={storageSnippets}
21+
environment={codeEnvironment}
22+
setEnvironment={setCodeEnvironment}
23+
/>
24+
</div>
25+
);
26+
}
27+
28+
const storageSnippets = {
29+
react: `// Check out the latest docs here: https://portal.thirdweb.com/typescript/v5/storage
30+
31+
import { ThirdwebProvider } from "thirdweb/react";
32+
import { upload } from "thirdweb/storage";
33+
import { MediaRenderer } from "thirdweb/react";
34+
35+
// Wrap your app in ThirdwebProvider
36+
function Providers() {
37+
return (
38+
<ThirdwebProvider
39+
>
40+
<App />
41+
</ThirdwebProvider>
42+
);
43+
}
44+
45+
function UploadFiles() {
46+
const uploadData = async () => {
47+
const uri = await upload({
48+
client, // thirdweb client
49+
files: [
50+
new File(["hello world"], "hello.txt"),
51+
],
52+
});
53+
}
54+
55+
return <div> ... </div>
56+
}
57+
58+
// Supported types: image, video, audio, 3d model, html
59+
function ShowFiles() {
60+
return (
61+
<MediaRenderer src="ipfs://QmamvVM5kvsYjQJYs7x8LXKYGFkwtGvuRvqZsuzvpHmQq9/0" />
62+
);
63+
}`,
64+
javascript: `// Check out the latest docs here: https://portal.thirdweb.com/typescript/v5/storage
65+
66+
import { upload } from "thirdweb/storage";
67+
68+
// Here we get the IPFS URI of where our metadata has been uploaded
69+
const uri = await upload({
70+
client,
71+
files: [
72+
new File(["hello world"], "hello.txt"),
73+
],
74+
});
75+
76+
// This will log a URL like ipfs://QmWgbcjKWCXhaLzMz4gNBxQpAHktQK6MkLvBkKXbsoWEEy/0
77+
console.info(uri);
78+
79+
// Here we a URL with a gateway that we can look at in the browser
80+
const url = await download({
81+
client,
82+
uri,
83+
}).url;
84+
85+
// This will log a URL like https://ipfs.thirdwebstorage.com/ipfs/QmWgbcjKWCXhaLzMz4gNBxQpAHktQK6MkLvBkKXbsoWEEy/0
86+
console.info(url);`,
87+
88+
unity: `using Thirdweb;
89+
90+
// Reference the SDK
91+
var sdk = ThirdwebManager.Instance.SDK;
92+
93+
// Create data
94+
NFTMetadata meta = new NFTMetadata()
95+
{
96+
name = "Unity NFT",
97+
description = "Minted From Unity",
98+
image = "ipfs://QmbpciV7R5SSPb6aT9kEBAxoYoXBUsStJkMpxzymV4ZcVc",
99+
};
100+
string metaJson = Newtonsoft.Json.JsonConvert.SerializeObject(meta);
101+
102+
// Upload raw text or from a file path
103+
var response = await ThirdwebManager.Instance.SDK.storage.UploadText(metaJson);`,
104+
};

0 commit comments

Comments
 (0)