-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathMinimalNavigation.tsx
59 lines (54 loc) · 2.49 KB
/
MinimalNavigation.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { IconLogomark } from '@posthog/icons'
import { LemonButton, Lettermark, Popover, ProfilePicture } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { organizationLogic } from 'scenes/organizationLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { navigationLogic } from '~/layout/navigation/navigationLogic'
import { ProjectSwitcherOverlay } from '~/layout/navigation/ProjectSwitcher'
import { AccountPopoverOverlay } from '~/layout/navigation/TopBar/AccountPopover'
export function MinimalNavigation(): JSX.Element {
const { user } = useValues(userLogic)
const { currentTeam } = useValues(teamLogic)
const { currentOrganization } = useValues(organizationLogic)
const { isAccountPopoverOpen, isProjectSwitcherShown } = useValues(navigationLogic)
const { closeAccountPopover, toggleAccountPopover, toggleProjectSwitcher, hideProjectSwitcher } =
useActions(navigationLogic)
return (
<nav className="flex items-center justify-between gap-2 p-2 border-b">
<LemonButton noPadding icon={<IconLogomark className="text-3xl mx-2" />} to={urls.projectHomepage()} />
<div className="flex-1" />
{currentOrganization?.teams?.length ?? 0 > 1 ? (
<Popover
overlay={<ProjectSwitcherOverlay onClickInside={hideProjectSwitcher} />}
visible={isProjectSwitcherShown}
onClickOutside={hideProjectSwitcher}
placement="bottom"
>
<LemonButton
type="tertiary"
icon={<Lettermark name={currentTeam?.name} />}
onClick={toggleProjectSwitcher}
>
{currentTeam?.name ?? 'Current project'}
</LemonButton>
</Popover>
) : null}
<Popover
overlay={<AccountPopoverOverlay />}
visible={isAccountPopoverOpen}
onClickOutside={closeAccountPopover}
placement="bottom"
>
<LemonButton
type="tertiary"
icon={<ProfilePicture user={user} size="md" />}
onClick={toggleAccountPopover}
>
{user?.first_name || user?.email}
</LemonButton>
</Popover>
</nav>
)
}