Skip to content

Commit 9dc8a9d

Browse files
committed
update
1 parent 9584885 commit 9dc8a9d

File tree

8 files changed

+405
-9
lines changed

8 files changed

+405
-9
lines changed

apps/dashboard/src/@/components/blocks/wallet-address.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ function WalletAvatar(props: {
191191
className="size-6"
192192
/>
193193
) : (
194-
<Blobbie address={props.address} size={24} />
194+
<Blobbie
195+
address={props.address}
196+
style={{
197+
width: "24px",
198+
height: "24px",
199+
}}
200+
/>
195201
)}
196202
</div>
197203
);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { THIRDWEB_CLIENT } from "@/lib/client";
5+
import { Suspense } from "react";
6+
import { sepolia } from "thirdweb/chains";
7+
import { Account, Blobbie, ThirdwebProvider } from "thirdweb/react";
8+
import { shortenAddress } from "thirdweb/utils";
9+
10+
export default function Page() {
11+
return (
12+
<ThirdwebProvider>
13+
<div className="flex h-full w-full flex-col items-center gap-3">
14+
<div>
15+
<div>Let&apos;s rebuild a basic ConnectButton-details component</div>
16+
<BasicConnectedButton />
17+
</div>
18+
</div>
19+
</ThirdwebProvider>
20+
);
21+
}
22+
23+
const BasicConnectedButton = () => {
24+
const roundUpBalance = (num: number) => Math.round(num * 10) / 10;
25+
return (
26+
<Account
27+
address="0x12345674b599ce99958242b3D3741e7b01841DF3"
28+
client={THIRDWEB_CLIENT}
29+
>
30+
<Button className="flex h-12 w-40 flex-row justify-start gap-3 px-2">
31+
<Suspense
32+
fallback={
33+
<Blobbie
34+
address="0x12345674b599ce99958242b3D3741e7b01841DF3"
35+
className="h-10 w-10 rounded-full"
36+
/>
37+
}
38+
>
39+
<Account.Avatar className="h-10 w-10 rounded-full" />
40+
</Suspense>
41+
<div className="flex flex-col items-start">
42+
<Suspense fallback={<Account.Address formatFn={shortenAddress} />}>
43+
<Account.Name />
44+
</Suspense>
45+
<Suspense fallback={"skeleton"}>
46+
<Account.Balance chain={sepolia} formatFn={roundUpBalance} />
47+
</Suspense>
48+
</div>
49+
</Button>
50+
</Account>
51+
);
52+
};

packages/thirdweb/src/exports/react.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,6 @@ export type {
199199
// Site Embed and Linking
200200
export { SiteEmbed } from "../react/web/ui/SiteEmbed.js";
201201
export { SiteLink } from "../react/web/ui/SiteLink.js";
202+
203+
// Account
204+
export { Account } from "../react/web/ui/prebuilt/Account/index.js";

packages/thirdweb/src/react/web/ui/ConnectWallet/Blobbie.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ const COLOR_OPTIONS = [
2525
* A unique gradient avatar based on the provided address.
2626
* @param props The component props.
2727
* @param props.address The address to generate the gradient with.
28-
* @param props.size The size of each side of the square avatar (in pixels)
28+
* @param props.style The CSS style for the component - excluding `backgroundImage`
29+
* @param props.className The className for the component
2930
*/
30-
export function Blobbie(props: { address: Address; size: number }) {
31+
export function Blobbie(props: {
32+
address: Address;
33+
style?: Omit<React.CSSProperties, "backgroundImage">;
34+
className?: string;
35+
}) {
3136
const id = useId();
3237
const colors = useMemo(
3338
() =>
@@ -41,10 +46,10 @@ export function Blobbie(props: { address: Address; size: number }) {
4146
<div
4247
id={id}
4348
style={{
44-
width: `${props.size}px`,
45-
height: `${props.size}px`,
49+
...props.style,
4650
backgroundImage: `radial-gradient(ellipse at left bottom, ${colors[0]}, ${colors[1]})`,
4751
}}
52+
className={props.className}
4853
/>
4954
);
5055
}

packages/thirdweb/src/react/web/ui/ConnectWallet/Details.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,15 @@ export const ConnectedWalletDetails: React.FC<{
229229
}}
230230
/>
231231
) : (
232-
activeAccount && <Blobbie address={activeAccount.address} size={35} />
232+
activeAccount && (
233+
<Blobbie
234+
address={activeAccount.address}
235+
style={{
236+
width: "35px",
237+
height: "35px",
238+
}}
239+
/>
240+
)
233241
)}
234242
</Container>
235243
<Container
@@ -419,7 +427,10 @@ function DetailsModal(props: {
419427
activeAccount && (
420428
<Blobbie
421429
address={activeAccount.address}
422-
size={Number(iconSize.xxl)}
430+
style={{
431+
width: `${iconSize.xxl}px`,
432+
height: `${iconSize.xxl}px`,
433+
}}
423434
/>
424435
)
425436
)}

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ export function WalletRow(props: {
171171
border: `1px solid ${theme.colors.borderColor}`,
172172
}}
173173
>
174-
<Blobbie address={props.address} size={Number(iconSize.md)} />
174+
<Blobbie
175+
address={props.address}
176+
style={{ width: `${iconSize.md}px`, height: `${iconSize.md}px` }}
177+
/>
175178
</Container>
176179
)}
177180

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ function LinkedProfile({
148148
overflow: "hidden",
149149
}}
150150
>
151-
<Blobbie address={profile.details.address} size={32} />
151+
<Blobbie
152+
address={profile.details.address}
153+
style={{
154+
width: "32px",
155+
height: "32px",
156+
}}
157+
/>
152158
</Container>
153159
) : profile.type === "passkey" ? (
154160
<FingerPrintIcon size={iconSize.lg} />

0 commit comments

Comments
 (0)