Skip to content

Commit 00dccdd

Browse files
committed
Add user account dropdown menu with payments and sign out
- Replace simple sign out button with dropdown menu for signed-in users - Add menu items: Profile, Payments & Billing, Settings, and Sign out - Include icons for better visual hierarchy and UX - Remove Settings from main navigation bar (now in user menu) - Add smooth transitions and hover effects for menu interactions The dropdown provides a cleaner interface for account management while reducing main navigation clutter by consolidating user-specific options.
1 parent 52d5bbf commit 00dccdd

2 files changed

Lines changed: 101 additions & 5 deletions

File tree

src/components/SignIn.tsx

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { useState } from "react";
1+
import { useState, Fragment } from "react";
2+
import { Menu, Transition } from "@headlessui/react";
3+
import {
4+
ChevronDownIcon,
5+
CreditCardIcon,
6+
UserCircleIcon,
7+
ArrowRightOnRectangleIcon,
8+
Cog6ToothIcon
9+
} from "@heroicons/react/24/outline";
210
import useGraffiticodeAuth from "../hooks/use-graffiticode-auth";
311
import WalletSelectionDialog from "./WalletSelectionDialog";
412

@@ -35,9 +43,98 @@ export default function SignInComponent({ label = "Sign in", className }: SignIn
3543

3644
if (user) {
3745
return (
38-
<button className={className} disabled={loading} onClick={signOut}>
39-
{`${user.uid.slice(0, 7)}...${user.uid.slice(33)}`} (Sign out)
40-
</button>
46+
<Menu as="div" className="relative inline-block text-left">
47+
<div>
48+
<Menu.Button className={`inline-flex justify-center items-center w-full ${className}`}>
49+
{`${user.uid.slice(0, 7)}...${user.uid.slice(33)}`}
50+
<ChevronDownIcon className="ml-2 -mr-1 h-4 w-4" aria-hidden="true" />
51+
</Menu.Button>
52+
</div>
53+
54+
<Transition
55+
as={Fragment}
56+
enter="transition ease-out duration-100"
57+
enterFrom="transform opacity-0 scale-95"
58+
enterTo="transform opacity-100 scale-100"
59+
leave="transition ease-in duration-75"
60+
leaveFrom="transform opacity-100 scale-100"
61+
leaveTo="transform opacity-0 scale-95"
62+
>
63+
<Menu.Items className="absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
64+
<div className="px-1 py-1">
65+
<div className="px-3 py-2 text-xs text-gray-500 border-b border-gray-200">
66+
Account
67+
</div>
68+
<Menu.Item>
69+
{({ active }) => (
70+
<a
71+
href="/profile"
72+
className={`${
73+
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700'
74+
} group flex items-center px-4 py-2 text-sm mt-1`}
75+
>
76+
<UserCircleIcon
77+
className="mr-3 h-4 w-4 text-gray-400 group-hover:text-gray-500"
78+
aria-hidden="true"
79+
/>
80+
Profile
81+
</a>
82+
)}
83+
</Menu.Item>
84+
<Menu.Item>
85+
{({ active }) => (
86+
<a
87+
href="/payments"
88+
className={`${
89+
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700'
90+
} group flex items-center px-4 py-2 text-sm`}
91+
>
92+
<CreditCardIcon
93+
className="mr-3 h-4 w-4 text-gray-400 group-hover:text-gray-500"
94+
aria-hidden="true"
95+
/>
96+
Payments & Billing
97+
</a>
98+
)}
99+
</Menu.Item>
100+
<Menu.Item>
101+
{({ active }) => (
102+
<a
103+
href="/settings"
104+
className={`${
105+
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700'
106+
} group flex items-center px-4 py-2 text-sm`}
107+
>
108+
<Cog6ToothIcon
109+
className="mr-3 h-4 w-4 text-gray-400 group-hover:text-gray-500"
110+
aria-hidden="true"
111+
/>
112+
Settings
113+
</a>
114+
)}
115+
</Menu.Item>
116+
<div className="border-t border-gray-200 my-1"></div>
117+
<Menu.Item>
118+
{({ active }) => (
119+
<button
120+
onClick={signOut}
121+
disabled={loading}
122+
className={`${
123+
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700'
124+
} group flex items-center w-full text-left px-4 py-2 text-sm`}
125+
>
126+
<ArrowRightOnRectangleIcon
127+
className="mr-3 h-4 w-4 text-gray-400 group-hover:text-gray-500"
128+
aria-hidden="true"
129+
/>
130+
Sign out
131+
</button>
132+
)}
133+
</Menu.Item>
134+
</div>
135+
</Menu.Items>
136+
</Transition>
137+
</Menu>
41138
);
42139
} else {
43140
return (

src/components/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const navigation: NavigationItem[] = [
4141
{ name: 'Items', href: '/items', current: false },
4242
// { name: 'Tasks', href: '/tasks', current: false },
4343
{ name: 'Compiles', href: '/compiles', current: false },
44-
{ name: 'Settings', href: '/settings', current: false },
4544
{ name: 'Docs', href: '/docs', current: false },
4645
// { name: 'Explorer', href: '/explorer', current: false },
4746
]

0 commit comments

Comments
 (0)