@@ -22,6 +22,14 @@ import {
2222 DialogTitle ,
2323 DialogDescription ,
2424} from "../ui/dialog" ;
25+ import {
26+ DropdownMenu ,
27+ DropdownMenuContent ,
28+ DropdownMenuItem ,
29+ DropdownMenuLabel ,
30+ DropdownMenuSeparator ,
31+ DropdownMenuTrigger ,
32+ } from "../ui/dropdown-menu" ;
2533import { Button } from "../ui/button" ;
2634import { useAuth } from "../contexts/auth" ;
2735import { useCurrentUser } from "../contexts/github" ;
@@ -1174,7 +1182,6 @@ export function UserMenuButton({ className }: { className?: string }) {
11741182 const { isAuthenticated, isAnonymous, logout, setShowWelcomeDialog } =
11751183 useAuth ( ) ;
11761184 const currentUser = useCurrentUser ( ) ?. login ?? null ;
1177- const [ showConfirm , setShowConfirm ] = useState ( false ) ;
11781185
11791186 // Anonymous mode - show read-only indicator with sign-in option
11801187 if ( isAnonymous && ! isAuthenticated ) {
@@ -1198,51 +1205,57 @@ export function UserMenuButton({ className }: { className?: string }) {
11981205 return null ;
11991206 }
12001207
1201- if ( showConfirm ) {
1202- return (
1203- < div className = { cn ( "flex items-center gap-1" , className ) } >
1204- < span className = "text-xs text-muted-foreground" > Sign out?</ span >
1205- < Button
1206- variant = "ghost"
1207- size = "sm"
1208- onClick = { ( ) => {
1209- logout ( ) ;
1210- setShowConfirm ( false ) ;
1211- } }
1212- className = "h-6 px-2 text-xs text-destructive hover:text-destructive hover:bg-destructive/10"
1208+ return (
1209+ < DropdownMenu >
1210+ < DropdownMenuTrigger asChild >
1211+ < button
1212+ className = { cn (
1213+ "flex items-center gap-1.5 p-1 rounded-md hover:bg-muted/50 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background" ,
1214+ className
1215+ ) }
1216+ title = { currentUser ? `Signed in as ${ currentUser } ` : "Account" }
12131217 >
1214- Yes
1215- </ Button >
1216- < Button
1217- variant = "ghost"
1218- size = "sm"
1219- onClick = { ( ) => setShowConfirm ( false ) }
1220- className = "h-6 px-2 text-xs"
1218+ { currentUser ? (
1219+ < img
1220+ src = { `https://github.com/${ currentUser } .png` }
1221+ alt = { currentUser }
1222+ className = "w-5 h-5 rounded-full ring-1 ring-border"
1223+ />
1224+ ) : (
1225+ < LogOut className = "w-3.5 h-3.5 text-muted-foreground" />
1226+ ) }
1227+ </ button >
1228+ </ DropdownMenuTrigger >
1229+ < DropdownMenuContent align = "end" className = "w-48" >
1230+ { currentUser && (
1231+ < >
1232+ < DropdownMenuLabel className = "font-normal" >
1233+ < div className = "flex items-center gap-2" >
1234+ < img
1235+ src = { `https://github.com/${ currentUser } .png` }
1236+ alt = { currentUser }
1237+ className = "w-8 h-8 rounded-full"
1238+ />
1239+ < div className = "flex flex-col" >
1240+ < span className = "text-sm font-medium" > { currentUser } </ span >
1241+ < span className = "text-xs text-muted-foreground" >
1242+ Signed in with GitHub
1243+ </ span >
1244+ </ div >
1245+ </ div >
1246+ </ DropdownMenuLabel >
1247+ < DropdownMenuSeparator />
1248+ </ >
1249+ ) }
1250+ < DropdownMenuItem
1251+ variant = "destructive"
1252+ onClick = { logout }
1253+ className = "cursor-pointer"
12211254 >
1222- No
1223- </ Button >
1224- </ div >
1225- ) ;
1226- }
1227-
1228- return (
1229- < button
1230- onClick = { ( ) => setShowConfirm ( true ) }
1231- className = { cn (
1232- "flex items-center gap-1.5 p-1 rounded-md hover:bg-muted/50 transition-colors" ,
1233- className
1234- ) }
1235- title = { currentUser ? `Signed in as ${ currentUser } ` : "Sign out" }
1236- >
1237- { currentUser ? (
1238- < img
1239- src = { `https://github.com/${ currentUser } .png` }
1240- alt = { currentUser }
1241- className = "w-5 h-5 rounded-full ring-1 ring-border"
1242- />
1243- ) : (
1244- < LogOut className = "w-3.5 h-3.5 text-muted-foreground" />
1245- ) }
1246- </ button >
1255+ < LogOut className = "w-4 h-4" />
1256+ Sign out
1257+ </ DropdownMenuItem >
1258+ </ DropdownMenuContent >
1259+ </ DropdownMenu >
12471260 ) ;
12481261}
0 commit comments