Skip to content

Commit

Permalink
Playground: Examples for Wallet components (#5692)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces a new `Wallet` navigation link and implements a new `Wallet` page with components for displaying wallet icons and names, enhancing the user interface for crypto wallet applications.

### Detailed summary
- Added a new navigation link for `Wallet`.
- Created `page.tsx` for the `Wallet` section with metadata and layout.
- Implemented `APIHeader` for the `Wallet` page.
- Added three components: `WalletIconBasic`, `WalletNameBasic`, and `WalletNameFormat` in `wallet-examples.tsx`.
- Each component includes a description and code example for usage.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Dec 14, 2024
1 parent 5be197b commit 2b5080d
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
49 changes: 49 additions & 0 deletions apps/playground-web/src/app/connect/ui/wallet/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { APIHeader } from "@/components/blocks/APIHeader";
import {
WalletIconBasic,
WalletNameBasic,
WalletNameFormat,
} from "@/components/headless-ui/wallet-examples";

import ThirdwebProvider from "@/components/thirdweb-provider";
import { metadataBase } from "@/lib/constants";
import type { Metadata } from "next";

export const metadata: Metadata = {
metadataBase,
title: "Wallet Components",
description:
"Boost your crypto wallet applications with our React headless UI components, optimized for digital asset management. These flexible, unstyled elements simplify cryptocurrency operations while granting developers complete control over the user interface design.",
};

export default function Page() {
return (
<ThirdwebProvider>
<main className="container px-0 pb-20">
<APIHeader
title="Wallet Components"
description={
<>
Boost your crypto wallet applications with our React headless UI
components, optimized for digital asset management. These
flexible, unstyled elements simplify cryptocurrency operations
while granting developers complete control over the user interface
design.
</>
}
docsLink="https://portal.thirdweb.com/react/v5/connecting-wallets/ui-components"
heroLink="/headless-ui-header.png"
/>
<section className="space-y-8">
<WalletIconBasic />
</section>
<section className="space-y-8">
<WalletNameBasic />
</section>
<section className="space-y-8">
<WalletNameFormat />
</section>
</main>
</ThirdwebProvider>
);
}
4 changes: 4 additions & 0 deletions apps/playground-web/src/app/navLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export const navLinks: SidebarLink[] = [
name: "Chain",
href: "/connect/ui/chain",
},
{
name: "Wallet",
href: "/connect/ui/wallet",
},
],
},
];
109 changes: 109 additions & 0 deletions apps/playground-web/src/components/headless-ui/wallet-examples.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"use client";

import { WalletIcon, WalletName, WalletProvider } from "thirdweb/react";
import { CodeExample } from "../code/code-example";

export function WalletIconBasic() {
return (
<>
<div className="space-y-2">
<h2 className="font-semibold text-2xl tracking-tight sm:text-3xl">
WalletIcon
</h2>
<p className="max-w-[600px] text-lg">
Show the icon of a crypto wallet
</p>
</div>

<CodeExample
preview={
<WalletProvider id="io.metamask">
<WalletIcon
className="h-20 w-20 rounded-full"
loadingComponent={<span>Loading...</span>}
/>
</WalletProvider>
}
code={`import { WalletProvider, WalletIcon } from "thirdweb/react";
function App() {
return (
<WalletProvider id="io.metamask">
<WalletIcon
className="h-20 w-20 rounded-full"
loadingComponent={<span>Loading...</span>}
/>
</WalletProvider>
)
}`}
lang="tsx"
/>
</>
);
}

export function WalletNameBasic() {
return (
<>
<div className="mt-8 space-y-2">
<h2 className="font-semibold text-2xl tracking-tight sm:text-3xl">
WalletName
</h2>
<p className="max-w-[600px] text-lg">
Show the name of a crypto wallet
</p>
</div>

<CodeExample
preview={
<WalletProvider id="io.metamask">
<WalletName loadingComponent={<span>Loading...</span>} />
</WalletProvider>
}
code={`import { WalletProvider, WalletName } from "thirdweb/react";
function App() {
return (
<WalletProvider id="io.metamask">
<WalletName loadingComponent={<span>Loading...</span>} />
</WalletProvider>
)
}`}
lang="tsx"
/>
</>
);
}

export function WalletNameFormat() {
return (
<>
<div className="mt-8 space-y-2">
<p className="max-w-[600px] text-lg">
Transform the wallet name using the <b>formatFn</b> prop.
</p>
</div>

<CodeExample
preview={
<WalletProvider id="io.metamask">
<WalletName formatFn={(str: string) => `${str} Wallet`} />
</WalletProvider>
}
code={`import { WalletProvider, WalletName } from "thirdweb/react";
function App() {
return (
<WalletProvider id="io.metamask">
<WalletName
loadingComponent={<span>Loading...</span>}
formatFn={(str: string) => \`\${str} Wallet\`}
/>
</WalletProvider>
)
}`}
lang="tsx"
/>
</>
);
}

0 comments on commit 2b5080d

Please sign in to comment.