Skip to content

Commit 74e76bf

Browse files
feat: update account page to display faucet, activity and iexec account (#99)
* feat: update account page to display faucet, activity and iexec account * feat: rename Faucet and Manage iExec Account file * feat: add dropdown menu to Navbar and update account management UI * refactor: format options parameter in truncateAddress function for improved readability * feat: update style * feat: add @clerk/themes dependency and integrate shadcn theme in Faucet component * feat: enhance account layout with wallet connection prompt and improved error handling * refactor: remove unused Breadcrumb components from Account and Faucet modules * refactor: rename 'iExec Account' to 'Account' for consistency across components * refactor: update wallet connection rendering in account layout * feat: add fallback redirect URL for SignIn component in Faucet module * chore: update package-lock * chore: update package-lock * feat: implement ManageIexecAccount component with wallet and account management features * feat: rename ManageIexecAccount component * fix: update Navbar button to toggle menu instead of linking to account
1 parent 594dcd1 commit 74e76bf

File tree

17 files changed

+9785
-8192
lines changed

17 files changed

+9785
-8192
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
},
2020
"dependencies": {
2121
"@clerk/clerk-react": "^5.51.0",
22+
"@clerk/themes": "^2.4.40",
2223
"@fontsource-variable/anybody": "^5.2.6",
2324
"@fontsource-variable/mulish": "^5.2.6",
2425
"@fontsource/space-mono": "^5.2.8",
2526
"@hookform/resolvers": "^5.2.1",
2627
"@icons-pack/react-simple-icons": "^13.7.0",
2728
"@multiformats/multiaddr": "^12.5.1",
2829
"@radix-ui/react-dialog": "^1.1.14",
30+
"@radix-ui/react-dropdown-menu": "^2.1.16",
2931
"@radix-ui/react-label": "^2.1.7",
3032
"@radix-ui/react-select": "^2.2.5",
3133
"@radix-ui/react-slot": "^1.2.3",

src/components/navbar/NavBar.tsx

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
import { LogOut } from 'lucide-react';
1+
import { cn } from '@/lib/utils.ts';
2+
import { ArrowDown, LogOut } from 'lucide-react';
23
import { useState } from 'react';
34
import { useLoginLogout } from '@/hooks/useLoginLogout';
45
import useUserStore from '@/stores/useUser.store';
6+
import { getAvatarVisualNumber } from '@/utils/getAvatarVisualNumber.ts';
7+
import { truncateAddress } from '@/utils/truncateAddress.ts';
58
import iExecLogo from '../../assets/iexec-logo.svg';
69
import { ChainLink } from '../ChainLink.tsx';
710
import { ModeToggle } from '../ModeToggle.tsx';
811
import { Button } from '../ui/button.tsx';
12+
import {
13+
DropdownMenu,
14+
DropdownMenuContent,
15+
DropdownMenuItem,
16+
DropdownMenuTrigger,
17+
} from '../ui/dropdown-menu.tsx';
918
import { AddressChip } from './AddressChip.tsx';
1019
import { ChainSelector } from './ChainSelector.tsx';
20+
import avatarStyles from './profile.module.css';
1121

1222
export function Navbar() {
1323
const { isConnected, address: userAddress } = useUserStore();
@@ -17,6 +27,10 @@ export function Navbar() {
1727
setMenuOpen((prevState) => !prevState);
1828
};
1929

30+
const avatarVisualBg = getAvatarVisualNumber({
31+
address: userAddress!,
32+
});
33+
2034
return (
2135
<nav className="flex items-center justify-between py-6">
2236
<ChainLink to="/" className="-m-2 flex items-center gap-2 p-2 font-mono">
@@ -25,36 +39,51 @@ export function Navbar() {
2539
</ChainLink>
2640
<div className="mr-8 flex items-center gap-4 md:mr-0">
2741
<Button variant="link" asChild className="text-foreground -mr-4">
28-
<ChainLink to="/faucet">Faucet</ChainLink>
42+
<ChainLink to="/account?accountTab=Faucet">Faucet</ChainLink>
2943
</Button>
30-
{isConnected && (
31-
<div className="-mr-4 hidden md:flex">
32-
<Button variant="link" asChild className="text-foreground">
33-
<ChainLink to={`/address/${userAddress}?from=my_activity`}>
34-
My activity
35-
</ChainLink>
36-
</Button>
37-
<Button variant="link" asChild className="text-foreground">
38-
<ChainLink to="/account">iExec Account</ChainLink>
39-
</Button>
40-
</div>
41-
)}
4244
<span className="border-secondary h-9 border-l" />
4345
<div className="content hidden gap-4 md:flex">
4446
<ModeToggle />
4547
<ChainSelector />
4648
</div>
4749
{isConnected ? (
4850
<div className="flex max-w-[1260px] items-center gap-2">
49-
<AddressChip address={userAddress!} />
50-
51-
<button
52-
type="button"
53-
className="hover:drop-shadow-link-hover p-1"
54-
onClick={() => logout()}
55-
>
56-
<LogOut size="20" />
57-
</button>
51+
<DropdownMenu>
52+
<DropdownMenuTrigger className="text-primary bg-popover flex items-center gap-2 rounded-lg px-2 py-2">
53+
<div
54+
className={cn(
55+
avatarStyles[avatarVisualBg],
56+
'bg-background relative z-10 size-4 rounded-full bg-cover'
57+
)}
58+
/>
59+
<span className="text-sm">
60+
{truncateAddress(userAddress!, { startLen: 5, endLen: 3 })}
61+
</span>
62+
<ArrowDown className="text-foreground" size={16} />
63+
</DropdownMenuTrigger>
64+
<DropdownMenuContent>
65+
<DropdownMenuItem>
66+
<ChainLink to="/account?accountTab=Wallet+Activity">
67+
Wallet Activity
68+
</ChainLink>
69+
</DropdownMenuItem>
70+
<DropdownMenuItem>
71+
<ChainLink to="/account?accountTab=Manage+iExec+Account">
72+
Account
73+
</ChainLink>
74+
</DropdownMenuItem>
75+
<DropdownMenuItem>
76+
<button
77+
type="button"
78+
className="inline-flex items-center gap-2"
79+
onClick={() => logout()}
80+
>
81+
Logout
82+
<LogOut size="20" />
83+
</button>
84+
</DropdownMenuItem>
85+
</DropdownMenuContent>
86+
</DropdownMenu>
5887
</div>
5988
) : (
6089
<Button onClick={login}>
@@ -112,8 +141,9 @@ export function Navbar() {
112141
variant="link"
113142
asChild
114143
className="text-foreground justify-baseline px-3"
144+
onClick={handleMenuToggle}
115145
>
116-
<ChainLink to="/account">iExec Account</ChainLink>
146+
<ChainLink to="/account?accountTab=Faucet">Faucet</ChainLink>
117147
</Button>
118148
<ChainSelector className="w-full border-0" />
119149
</div>

src/components/ui/alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const alertVariants = cva(
99
variant: {
1010
default: 'bg-card text-card-foreground',
1111
destructive:
12-
'text-destructive bg-danger border-danger-border [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90 border-l-4',
12+
'text-destructive bg-destructive/5 border-danger-border [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90 border-l-4',
1313
},
1414
},
1515
defaultVariants: {

0 commit comments

Comments
 (0)