|
1 | 1 | import { Link } from '@tanstack/react-router'; |
2 | 2 | import { LogOut } from 'lucide-react'; |
| 3 | +import { useState } from 'react'; |
3 | 4 | import { useLoginLogout } from '@/hooks/useLoginLogout'; |
4 | 5 | import useUserStore from '@/stores/useUser.store'; |
5 | 6 | import iExecLogo from '../../assets/iexec-logo.svg'; |
6 | 7 | import { Button } from '../ui/button.tsx'; |
| 8 | +import { |
| 9 | + Select, |
| 10 | + SelectContent, |
| 11 | + SelectItem, |
| 12 | + SelectTrigger, |
| 13 | + SelectValue, |
| 14 | +} from '../ui/select.tsx'; |
7 | 15 | import { AddressChip } from './AddressChip.tsx'; |
8 | 16 |
|
9 | 17 | export function TopNavBar() { |
10 | 18 | const { isConnected, address } = useUserStore(); |
11 | 19 | const { logout, login } = useLoginLogout(); |
| 20 | + const [isMenuOpen, setMenuOpen] = useState(false); |
| 21 | + const handleMenuToggle = () => { |
| 22 | + setMenuOpen((prevState) => !prevState); |
| 23 | + }; |
12 | 24 |
|
13 | 25 | return ( |
14 | | - <div className="flex items-center justify-between pt-5 lg:pt-10"> |
| 26 | + <div className="flex items-center justify-between pt-6 lg:pt-3"> |
15 | 27 | <Link to="/" className="-m-2 flex items-center gap-2 p-2 font-mono"> |
16 | 28 | <img src={iExecLogo} width="25" height="25" alt="iExec logo" /> |
17 | | - iExec Explorer |
| 29 | + <span className="hidden sm:block">iExec Explorer</span> |
18 | 30 | </Link> |
19 | | - {isConnected ? ( |
20 | | - <div className="flex max-w-[1260px] items-center pr-10 lg:pr-0"> |
21 | | - <AddressChip address={address!} className="ml-6" /> |
22 | | - <button |
23 | | - type="button" |
24 | | - className="hover:drop-shadow-link-hover -mr-1 ml-2 p-1" |
25 | | - onClick={() => logout()} |
| 31 | + <div className="mr-10 flex items-center gap-2 md:mr-0"> |
| 32 | + <div className="content hidden md:flex"> |
| 33 | + {isConnected && ( |
| 34 | + <Button variant="link" className="text-accent-foreground"> |
| 35 | + iExec Account |
| 36 | + </Button> |
| 37 | + )} |
| 38 | + <Select value="bellecour"> |
| 39 | + <SelectTrigger className=""> |
| 40 | + <SelectValue /> |
| 41 | + </SelectTrigger> |
| 42 | + <SelectContent> |
| 43 | + <SelectItem value="bellecour"> |
| 44 | + <img src={iExecLogo} className="size-4" alt="" /> Bellecour |
| 45 | + </SelectItem> |
| 46 | + </SelectContent> |
| 47 | + </Select> |
| 48 | + </div> |
| 49 | + {isConnected ? ( |
| 50 | + <div className="flex max-w-[1260px] items-center gap-2"> |
| 51 | + <AddressChip address={address!} className="ml-2" /> |
| 52 | + |
| 53 | + <button |
| 54 | + type="button" |
| 55 | + className="hover:drop-shadow-link-hover -mr-1 ml-2 p-1" |
| 56 | + onClick={() => logout()} |
| 57 | + > |
| 58 | + <LogOut size="20" /> |
| 59 | + </button> |
| 60 | + </div> |
| 61 | + ) : ( |
| 62 | + <Button onClick={login}> |
| 63 | + <span className="text-base font-semibold">Connect Wallet</span> |
| 64 | + </Button> |
| 65 | + )} |
| 66 | + </div> |
| 67 | + |
| 68 | + <div className="group pointer-events-none absolute inset-0 md:hidden"> |
| 69 | + <label |
| 70 | + className="group/checkbox pointer-events-auto fixed top-7 right-6 z-30 flex size-5 w-[26px] origin-center transform flex-col justify-between" |
| 71 | + htmlFor="menu" |
| 72 | + onClick={handleMenuToggle} |
| 73 | + > |
| 74 | + <input |
| 75 | + type="checkbox" |
| 76 | + className="absolute -inset-2 size-10 cursor-pointer appearance-none bg-transparent" |
| 77 | + name="menu" |
| 78 | + id="menu" |
| 79 | + checked={isMenuOpen} |
| 80 | + readOnly |
| 81 | + /> |
| 82 | + <span className="pointer-events-none block h-0.5 w-[26px] origin-right transform rounded-full bg-white duration-200 group-has-[:checked]/checkbox:-rotate-45"></span> |
| 83 | + <span className="pointer-events-none block h-0.5 w-[26px] origin-top-right transform rounded-full bg-white duration-200 group-has-[:checked]/checkbox:scale-x-0"></span> |
| 84 | + <span className="pointer-events-none block h-0.5 w-[26px] origin-right transform rounded-full bg-white duration-200 group-has-[:checked]/checkbox:rotate-45"></span> |
| 85 | + </label> |
| 86 | + |
| 87 | + <div className="border-grey-600 bg-grey-900 fixed inset-y-0 left-0 z-10 flex w-full -translate-x-full flex-col overflow-auto rounded-r-3xl border-r px-5 pt-5 duration-300 group-has-[:checked]:translate-x-0 lg:w-[255px] lg:translate-x-0"> |
| 88 | + <Link |
| 89 | + to="/" |
| 90 | + className="-m-2 flex items-center gap-2 p-2 font-mono" |
| 91 | + onClick={handleMenuToggle} |
26 | 92 | > |
27 | | - <LogOut size="20" /> |
28 | | - </button> |
| 93 | + <img src={iExecLogo} width="25" height="25" alt="iExec logo" /> |
| 94 | + iExec Explorer |
| 95 | + </Link> |
| 96 | + |
| 97 | + <div className="left-navbar text-grey-400 mt-10 flex grow flex-col gap-10"> |
| 98 | + {isConnected && ( |
| 99 | + <Button variant="link" className="text-accent-foreground w-max"> |
| 100 | + iExec Account |
| 101 | + </Button> |
| 102 | + )} |
| 103 | + <Select value="bellecour"> |
| 104 | + <SelectTrigger className=""> |
| 105 | + <SelectValue /> |
| 106 | + </SelectTrigger> |
| 107 | + <SelectContent> |
| 108 | + <SelectItem value="bellecour"> |
| 109 | + <img src={iExecLogo} className="size-4" alt="" /> Bellecour |
| 110 | + </SelectItem> |
| 111 | + </SelectContent> |
| 112 | + </Select> |
| 113 | + |
| 114 | + <div className="mb-16"></div> |
| 115 | + </div> |
29 | 116 | </div> |
30 | | - ) : ( |
31 | | - <Button className="px-10" onClick={login}> |
32 | | - <span className="text-base font-semibold">Connect Wallet</span> |
33 | | - </Button> |
34 | | - )} |
| 117 | + </div> |
35 | 118 | </div> |
36 | 119 | ); |
37 | 120 | } |
0 commit comments