diff --git a/apps/www/components/Nav/AuthenticatedDropdownMenu.tsx b/apps/www/components/Nav/AuthenticatedDropdownMenu.tsx new file mode 100644 index 00000000000..e0e31f5f4f3 --- /dev/null +++ b/apps/www/components/Nav/AuthenticatedDropdownMenu.tsx @@ -0,0 +1,171 @@ +'use client' + +import React, { Fragment } from 'react' +import Link from 'next/link' +import { useTheme } from 'next-themes' +import { Home, LogOut, Menu, Search, Settings, User } from 'lucide-react' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuTrigger, + Theme, + buttonVariants, + cn, + themes, +} from 'ui' +import { useSetCommandMenuOpen } from 'ui-patterns/CommandMenu' +import { logOut, useUser } from 'common' +import { LucideIcon } from 'icons/src/createSupabaseIcon' + +const AuthenticatedDropdownMenu = () => { + const { theme, setTheme } = useTheme() + const setCommandMenuOpen = useSetCommandMenuOpen() + const user = useUser() + + interface menuItem { + label: string + type?: 'link' | 'button' | 'text' + icon?: LucideIcon + href?: string + shortcut?: string + onClick?: VoidFunction + otherProps?: { + target?: '_blank' + rel?: 'noreferrer noopener' + } + } + + const menu: menuItem[][] = [ + [ + { + label: user?.email ?? '', + type: 'text', + icon: User, + }, + { + label: 'Projects', + icon: Home, + href: 'https://supabase.com/dashboard/projects', + }, + { + label: 'Account Preferences', + icon: Settings, + href: 'https://supabase.com/dashboard/account/me', + }, + { + label: 'Logout', + type: 'button', + icon: LogOut, + onClick: () => logOut(), + }, + ], + [ + { + label: 'Search', + type: 'button', + icon: Search, + onClick: () => setCommandMenuOpen(true), + shortcut: '⌘K', + }, + ], + ] + + return ( + + + + + + {menu.map((menuSection, sectionIdx) => ( + + {sectionIdx !== 0 && } + {menuSection.map(({ icon: Icon, ...sectionItem }, itemIdx) => { + switch (sectionItem.type) { + case 'text': + return ( +
+ {Icon && } + {sectionItem.label} + {sectionItem.shortcut && ( + {sectionItem.shortcut} + )} +
+ ) + case 'button': + return ( + + {Icon && } + {sectionItem.label} + {sectionItem.shortcut && ( + {sectionItem.shortcut} + )} + + ) + default: + return ( + + {}}> + {Icon && } + {sectionItem.label} + {sectionItem.shortcut && ( + {sectionItem.shortcut} + )} + + + ) + } + })} +
+ ))} + + + Theme + { + setTheme(value) + }} + > + {themes + .filter((x) => x.value === 'light' || x.value === 'dark' || x.value === 'system') + .map((theme: Theme) => ( + + {theme.name} + + ))} + + +
+
+ ) +} + +export default AuthenticatedDropdownMenu diff --git a/apps/www/components/Nav/GitHubButton.tsx b/apps/www/components/Nav/GitHubButton.tsx index b59232b4fa6..76cb30f36a7 100644 --- a/apps/www/components/Nav/GitHubButton.tsx +++ b/apps/www/components/Nav/GitHubButton.tsx @@ -29,11 +29,7 @@ const GitHubButton = () => { }, []) return ( - - {/* !Temporary! */} - - - ) : ( - <> - - - - )} + + + + ) : ( + <> + + )}