|
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 | 14 | import { buttonStyle } from '~/ui/lib/Button'
|
| 15 | +import * as DropdownMenu from '~/ui/lib/DropdownMenu2' |
18 | 16 | import { pb } from '~/util/path-builder'
|
19 | 17 |
|
20 | 18 | export function TopBar({ children }: { children: React.ReactNode }) {
|
@@ -42,42 +40,27 @@ export function TopBar({ children }: { children: React.ReactNode }) {
|
42 | 40 | <div className="mx-3 flex h-[60px] shrink-0 items-center justify-between">
|
43 | 41 | <div className="flex items-center">{otherPickers}</div>
|
44 | 42 | <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 |
| - )} |
| 43 | + <DropdownMenu.Root> |
| 44 | + <DropdownMenu.Trigger |
| 45 | + className={buttonStyle({ size: 'sm', variant: 'secondary' })} |
51 | 46 | aria-label="User menu"
|
52 | 47 | >
|
53 |
| - <Profile16Icon className="text-quaternary" /> |
54 |
| - <span className="normal-case text-sans-md text-secondary"> |
55 |
| - {me.displayName || 'User'} |
| 48 | + <span className="flex items-center gap-2"> |
| 49 | + <Profile16Icon className="text-quaternary" /> |
| 50 | + <span className="normal-case text-sans-md text-secondary"> |
| 51 | + {me.displayName || 'User'} |
| 52 | + </span> |
| 53 | + <DirectionDownIcon className="!w-2.5" /> |
56 | 54 | </span>
|
57 |
| - <DirectionDownIcon className="!w-2.5" /> |
58 |
| - </MenuButton> |
| 55 | + </DropdownMenu.Trigger> |
59 | 56 | {/* 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> |
| 57 | + <DropdownMenu.Items> |
| 58 | + <DropdownMenu.LinkItem to={pb.profile()}>Settings</DropdownMenu.LinkItem> |
| 59 | + <DropdownMenu.Item onSelect={() => logout.mutate({})}> |
| 60 | + Sign out |
| 61 | + </DropdownMenu.Item> |
| 62 | + </DropdownMenu.Items> |
| 63 | + </DropdownMenu.Root> |
81 | 64 | </div>
|
82 | 65 | </div>
|
83 | 66 | </div>
|
|
0 commit comments