|
5 | 5 | *
|
6 | 6 | * Copyright Oxide Computer Company
|
7 | 7 | */
|
| 8 | +import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react' |
| 9 | +import cn from 'classnames' |
8 | 10 | import React from 'react'
|
| 11 | +import { Link } from 'react-router-dom' |
9 | 12 |
|
10 | 13 | import { navToLogin, useApiMutation } from '@oxide/api'
|
11 | 14 | import { DirectionDownIcon, Profile16Icon } from '@oxide/design-system/icons/react'
|
12 | 15 |
|
13 | 16 | import { useCurrentUser } from '~/layouts/AuthenticatedLayout'
|
14 |
| -import { Button } from '~/ui/lib/Button' |
15 |
| -import { DropdownMenu } from '~/ui/lib/DropdownMenu' |
| 17 | +import { buttonStyle } from '~/ui/lib/Button' |
16 | 18 | import { pb } from '~/util/path-builder'
|
17 | 19 |
|
18 | 20 | export function TopBar({ children }: { children: React.ReactNode }) {
|
@@ -40,31 +42,42 @@ export function TopBar({ children }: { children: React.ReactNode }) {
|
40 | 42 | <div className="mx-3 flex h-[60px] shrink-0 items-center justify-between">
|
41 | 43 | <div className="flex items-center">{otherPickers}</div>
|
42 | 44 | <div className="flex items-center gap-2">
|
43 |
| - {/* <Button variant="secondary" size="icon" className="ml-2" title="Notifications"> |
44 |
| - <Notifications16Icon className="text-quaternary" /> |
45 |
| - </Button> */} |
46 |
| - <DropdownMenu.Root> |
47 |
| - <DropdownMenu.Trigger asChild> |
48 |
| - <Button |
49 |
| - size="sm" |
50 |
| - variant="secondary" |
51 |
| - aria-label="User menu" |
52 |
| - innerClassName="space-x-2" |
53 |
| - > |
54 |
| - <Profile16Icon className="text-quaternary" /> |
55 |
| - <span className="normal-case text-sans-md text-secondary"> |
56 |
| - {me.displayName || 'User'} |
57 |
| - </span> |
58 |
| - <DirectionDownIcon className="!w-2.5" /> |
59 |
| - </Button> |
60 |
| - </DropdownMenu.Trigger> |
61 |
| - <DropdownMenu.Content align="end" sideOffset={8}> |
62 |
| - <DropdownMenu.LinkItem to={pb.profile()}>Settings</DropdownMenu.LinkItem> |
63 |
| - <DropdownMenu.Item onSelect={() => logout.mutate({})}> |
64 |
| - Sign out |
65 |
| - </DropdownMenu.Item> |
66 |
| - </DropdownMenu.Content> |
67 |
| - </DropdownMenu.Root> |
| 45 | + <Menu> |
| 46 | + <MenuButton |
| 47 | + className={cn( |
| 48 | + 'flex items-center gap-2', |
| 49 | + buttonStyle({ size: 'sm', variant: 'secondary' }) |
| 50 | + )} |
| 51 | + aria-label="User menu" |
| 52 | + > |
| 53 | + <Profile16Icon className="text-quaternary" /> |
| 54 | + <span className="normal-case text-sans-md text-secondary"> |
| 55 | + {me.displayName || 'User'} |
| 56 | + </span> |
| 57 | + <DirectionDownIcon className="!w-2.5" /> |
| 58 | + </MenuButton> |
| 59 | + {/* TODO: fix hover style + should be able to click anywhere in the menu item */} |
| 60 | + <MenuItems |
| 61 | + anchor="bottom end" |
| 62 | + className="DropdownMenuContent [--anchor-gap:8px]" |
| 63 | + > |
| 64 | + {/* TODO: extract Item and LinkItem components*/} |
| 65 | + <MenuItem> |
| 66 | + <Link className="DropdownMenuItem ox-menu-item" to={pb.profile()}> |
| 67 | + Settings |
| 68 | + </Link> |
| 69 | + </MenuItem> |
| 70 | + <MenuItem> |
| 71 | + <button |
| 72 | + type="button" |
| 73 | + onClick={() => logout.mutate({})} |
| 74 | + className="DropdownMenuItem ox-menu-item" |
| 75 | + > |
| 76 | + Sign out |
| 77 | + </button> |
| 78 | + </MenuItem> |
| 79 | + </MenuItems> |
| 80 | + </Menu> |
68 | 81 | </div>
|
69 | 82 | </div>
|
70 | 83 | </div>
|
|
0 commit comments