|
5 | 5 | * |
6 | 6 | * Copyright Oxide Computer Company |
7 | 7 | */ |
8 | | -import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react' |
9 | | -import cn from 'classnames' |
10 | 8 | import React from 'react' |
11 | | -import { Link } from 'react-router-dom' |
12 | 9 |
|
13 | 10 | import { navToLogin, useApiMutation } from '@oxide/api' |
14 | 11 | import { DirectionDownIcon, Profile16Icon } from '@oxide/design-system/icons/react' |
15 | 12 |
|
16 | 13 | import { useCurrentUser } from '~/layouts/AuthenticatedLayout' |
17 | | -import { buttonStyle } from '~/ui/lib/Button' |
| 14 | +import * as DropdownMenu from '~/ui/lib/DropdownMenu2' |
18 | 15 | import { pb } from '~/util/path-builder' |
19 | 16 |
|
20 | 17 | export function TopBar({ children }: { children: React.ReactNode }) { |
@@ -42,42 +39,24 @@ export function TopBar({ children }: { children: React.ReactNode }) { |
42 | 39 | <div className="mx-3 flex h-[60px] shrink-0 items-center justify-between"> |
43 | 40 | <div className="flex items-center">{otherPickers}</div> |
44 | 41 | <div className="flex items-center gap-2"> |
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'} |
| 42 | + <DropdownMenu.Root> |
| 43 | + <DropdownMenu.Trigger aria-label="User menu"> |
| 44 | + <span className="flex items-center gap-2"> |
| 45 | + <Profile16Icon className="text-quaternary" /> |
| 46 | + <span className="normal-case text-sans-md text-secondary"> |
| 47 | + {me.displayName || 'User'} |
| 48 | + </span> |
| 49 | + <DirectionDownIcon className="!w-2.5" /> |
56 | 50 | </span> |
57 | | - <DirectionDownIcon className="!w-2.5" /> |
58 | | - </MenuButton> |
| 51 | + </DropdownMenu.Trigger> |
59 | 52 | {/* 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> |
| 53 | + <DropdownMenu.Items> |
| 54 | + <DropdownMenu.LinkItem to={pb.profile()}>Settings</DropdownMenu.LinkItem> |
| 55 | + <DropdownMenu.Item onSelect={() => logout.mutate({})}> |
| 56 | + Sign out |
| 57 | + </DropdownMenu.Item> |
| 58 | + </DropdownMenu.Items> |
| 59 | + </DropdownMenu.Root> |
81 | 60 | </div> |
82 | 61 | </div> |
83 | 62 | </div> |
|
0 commit comments