Skip to content

Commit 2490b2d

Browse files
authored
Merge pull request #8 from doinel1a/chore/optimizations-2025-03-02
chore/optimizations 2025 03 02
2 parents 1338a9b + 991c326 commit 2490b2d

File tree

9 files changed

+386
-19
lines changed

9 files changed

+386
-19
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@t3-oss/env-nextjs": "^0.12.0",
3636
"@tanstack/react-query": "^5.66.11",
3737
"@vercel/analytics": "^1.5.0",
38+
"burner-connector": "^0.0.11",
3839
"class-variance-authority": "^0.7.1",
3940
"clsx": "^2.1.1",
4041
"framer-motion": "^12.4.7",

pnpm-lock.yaml

Lines changed: 337 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/counter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function Counter() {
1818
<Button
1919
className='w-10 rounded-full'
2020
data-testid='increase-count'
21-
onClick={() => setCount((previousCount) => previousCount + 1)}
21+
onPress={() => setCount((previousCount) => previousCount + 1)}
2222
>
2323
+ 1
2424
</Button>
@@ -30,7 +30,7 @@ export default function Counter() {
3030
<Button
3131
className='w-10 rounded-full'
3232
data-testid='decrease-count'
33-
onClick={() => setCount((previousCount) => previousCount - 1)}
33+
onPress={() => setCount((previousCount) => previousCount - 1)}
3434
>
3535
- 1
3636
</Button>

src/components/providers/web3.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
'use client';
22

3-
import React from 'react';
3+
import React, { useMemo } from 'react';
44

55
import type { PropsWithChildren } from 'react';
66

7-
import { getDefaultConfig, getDefaultWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit';
8-
import { argentWallet, ledgerWallet, trustWallet } from '@rainbow-me/rainbowkit/wallets';
7+
import {
8+
darkTheme,
9+
getDefaultConfig,
10+
getDefaultWallets,
11+
lightTheme,
12+
RainbowKitProvider
13+
} from '@rainbow-me/rainbowkit';
14+
import { ledgerWallet, trustWallet } from '@rainbow-me/rainbowkit/wallets';
915
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
16+
import { rainbowkitBurnerWallet } from 'burner-connector';
17+
import { useTheme } from 'next-themes';
1018
import { WagmiProvider } from 'wagmi';
1119
import { mainnet, sepolia } from 'wagmi/chains';
1220

@@ -21,7 +29,7 @@ const wagmiConfig = getDefaultConfig({
2129
...defaultWallets,
2230
{
2331
groupName: 'More',
24-
wallets: [argentWallet, trustWallet, ledgerWallet]
32+
wallets: [trustWallet, ledgerWallet, rainbowkitBurnerWallet]
2533
}
2634
],
2735
chains: [mainnet, sepolia],
@@ -33,10 +41,21 @@ const queryClient = new QueryClient();
3341
type TWeb3Provider = PropsWithChildren;
3442

3543
export default function Web3Provider({ children }: TWeb3Provider) {
44+
const { resolvedTheme } = useTheme();
45+
const isDarkTheme = useMemo(() => resolvedTheme === 'dark', [resolvedTheme]);
46+
3647
return (
3748
<WagmiProvider config={wagmiConfig}>
3849
<QueryClientProvider client={queryClient}>
39-
<RainbowKitProvider>{children}</RainbowKitProvider>
50+
<RainbowKitProvider
51+
theme={
52+
isDarkTheme
53+
? darkTheme({ borderRadius: 'small' })
54+
: lightTheme({ borderRadius: 'small' })
55+
}
56+
>
57+
{children}
58+
</RainbowKitProvider>
4059
</QueryClientProvider>
4160
</WagmiProvider>
4261
);

src/components/switch-chain/chains-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function ChainsList({
3434
<Button
3535
color='secondary'
3636
className='w-full items-center justify-start'
37-
onClick={() => onSwitchChain(chain.id)}
37+
onPress={() => onSwitchChain(chain.id)}
3838
>
3939
{chain.name}
4040
</Button>

src/components/ui/theme-toggle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function ThemeToggle() {
2626
data-testid='theme-toggle'
2727
variant='bordered'
2828
isIconOnly
29-
onClick={() => setIsDropdownOpen((previousState) => !previousState)}
29+
onPress={() => setIsDropdownOpen((previousState) => !previousState)}
3030
>
3131
<Sun className='h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0' />
3232
<MoonStar className='absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100' />

src/components/wallet/dropdown/details/ens-name.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ type TENSName = {
1616
};
1717

1818
export default function ENSName({ address }: TENSName) {
19-
const { isFetching, data: ensName } = useEnsName({
19+
const {
20+
isFetching,
21+
isFetched,
22+
data: ensName
23+
} = useEnsName({
2024
chainId: mainnet.id,
2125
address: address
2226
});
2327

2428
return (
2529
<DropdownMenuLabel>
26-
<Label property='ENS' value={ensName ?? 'N / A'} isLoading={isFetching && !ensName} />
30+
<Label property='ENS' value={ensName ?? 'N / A'} isLoading={isFetching && !isFetched} />
2731
</DropdownMenuLabel>
2832
);
2933
}

src/components/wallet/dropdown/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function WalletDropdown() {
5858

5959
const { address } = useAccount();
6060
const displayAddress = useMemo(
61-
() => `${address?.slice(0, 8)}...${address?.slice(-8)}`,
61+
() => `${address?.slice(0, 6)}...${address?.slice(-6)}`,
6262
[address]
6363
);
6464

@@ -72,7 +72,8 @@ export default function WalletDropdown() {
7272
<Button
7373
ref={dropdownTriggerReference}
7474
color='default'
75-
onClick={() => setIsDropdownOpen((previousState) => !previousState)}
75+
className='w-32'
76+
onPress={() => setIsDropdownOpen((previousState) => !previousState)}
7677
>
7778
{displayAddress}
7879
</Button>

src/components/wallet/index.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import React from 'react';
77
import type { ComponentProps } from 'react';
88

99
import { Button } from '@heroui/button';
10+
import { Skeleton } from '@heroui/skeleton';
1011
import { useConnectModal } from '@rainbow-me/rainbowkit';
1112
import { useAccount } from 'wagmi';
1213

@@ -17,16 +18,20 @@ import WalletDropdown from './dropdown';
1718
type TWallet = ComponentProps<'button'>;
1819

1920
export default function Wallet({ className }: TWallet) {
20-
const { isConnected } = useAccount();
21+
const { isConnected, isDisconnected } = useAccount();
2122
const { openConnectModal } = useConnectModal();
2223

2324
if (isConnected) {
2425
return <WalletDropdown />;
2526
}
2627

27-
return (
28-
<Button color='primary' className={cn(className)} onClick={openConnectModal}>
29-
Connect Wallet
30-
</Button>
31-
);
28+
if (isDisconnected) {
29+
return (
30+
<Button color='primary' className={cn('w-32', className)} onPress={openConnectModal}>
31+
Connect Wallet
32+
</Button>
33+
);
34+
}
35+
36+
return <Skeleton className='h-10 w-32 rounded-md' />;
3237
}

0 commit comments

Comments
 (0)