Use menu trigger for team navigation and refine top navigation selectors
This commit is contained in:
1 parent
effe9990f8
commit
fed1ff76f6
3 files changed
+37
-39
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import { Icon, Row } from '@umami/react-zen';
|
import { Icon, Row } from '@umami/react-zen';
|
||||||
import { useNavigation } from '@/components/hooks';
|
import { useNavigation } from '@/components/hooks';
|
||||||
import { Slash } from '@/components/icons';
|
import { Minus } from '@/components/icons';
|
||||||
import { BoardSelect } from '@/components/input/BoardSelect';
|
import { BoardSelect } from '@/components/input/BoardSelect';
|
||||||
import { LinkSelect } from '@/components/input/LinkSelect';
|
import { LinkSelect } from '@/components/input/LinkSelect';
|
||||||
import { PixelSelect } from '@/components/input/PixelSelect';
|
import { PixelSelect } from '@/components/input/PixelSelect';
|
||||||
@@ -52,8 +52,8 @@ export function TopNav() {
|
|||||||
<TeamsButton />
|
<TeamsButton />
|
||||||
{(websiteId || linkId || pixelId || boardId) && (
|
{(websiteId || linkId || pixelId || boardId) && (
|
||||||
<>
|
<>
|
||||||
<Icon size="sm" color="muted" style={{ opacity: 0.7, margin: '0 6px' }}>
|
<Icon size="sm" color="muted" rotate={90} style={{ opacity: 0.7, margin: '0 6px' }}>
|
||||||
<Slash />
|
<Minus />
|
||||||
</Icon>
|
</Icon>
|
||||||
{websiteId && (
|
{websiteId && (
|
||||||
<WebsiteSelect
|
<WebsiteSelect
|
||||||
@@ -61,8 +61,7 @@ export function TopNav() {
|
|||||||
teamId={teamId}
|
teamId={teamId}
|
||||||
onChange={handleWebsiteChange}
|
onChange={handleWebsiteChange}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
variant: 'quiet',
|
style: { minWidth: 200, maxWidth: 200 },
|
||||||
style: { minHeight: 40, minWidth: 200, maxWidth: 200 },
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
DialogTrigger,
|
|
||||||
Icon,
|
Icon,
|
||||||
Menu,
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
MenuSection,
|
MenuSection,
|
||||||
MenuSeparator,
|
MenuSeparator,
|
||||||
Popover,
|
MenuTrigger,
|
||||||
Row,
|
Row,
|
||||||
Text,
|
Text,
|
||||||
} from '@umami/react-zen';
|
} from '@umami/react-zen';
|
||||||
@@ -53,7 +52,7 @@ export function TeamsButton() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogTrigger>
|
<MenuTrigger>
|
||||||
<Button variant="quiet">
|
<Button variant="quiet">
|
||||||
<Row
|
<Row
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
@@ -70,37 +69,32 @@ export function TeamsButton() {
|
|||||||
<ChevronRight />
|
<ChevronRight />
|
||||||
</Icon>
|
</Icon>
|
||||||
</Button>
|
</Button>
|
||||||
<Popover side="bottom" align="start" sideOffset={4}>
|
<Menu className="min-w-[300px]" selectionMode="single" selectedKeys={selectedKeys}>
|
||||||
<Menu className="min-w-[300px]" selectionMode="single" selectedKeys={selectedKeys}>
|
<MenuSection title={t(labels.myAccount)}>
|
||||||
<MenuSection title={t(labels.myAccount)}>
|
<MenuItem id="user" onAction={handleAction}>
|
||||||
<MenuItem id="user" onAction={handleAction}>
|
<IconLabel icon={<User />} label={user.username} />
|
||||||
<IconLabel icon={<User />} label={user.username} />
|
</MenuItem>
|
||||||
|
</MenuSection>
|
||||||
|
<MenuSeparator />
|
||||||
|
<MenuSection title={t(labels.teams)}>
|
||||||
|
{user?.teams?.map(({ id, name }) => (
|
||||||
|
<MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
|
||||||
|
<IconLabel icon={<Users />}>
|
||||||
|
<Text wrap="nowrap">{name}</Text>
|
||||||
|
</IconLabel>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuSection>
|
))}
|
||||||
<MenuSeparator />
|
<MenuSeparator />
|
||||||
<MenuSection title={t(labels.teams)}>
|
<MenuItem id="manage-teams" onAction={() => handleNavigate(getUrl('/settings/teams'))}>
|
||||||
{user?.teams?.map(({ id, name }) => (
|
<Row alignItems="center" justifyContent="space-between" gap width="100%">
|
||||||
<MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
|
<Text align="center">Manage teams</Text>
|
||||||
<IconLabel icon={<Users />}>
|
<Icon>
|
||||||
<Text wrap="nowrap">{name}</Text>
|
<ArrowRight />
|
||||||
</IconLabel>
|
</Icon>
|
||||||
</MenuItem>
|
</Row>
|
||||||
))}
|
</MenuItem>
|
||||||
<MenuSeparator />
|
</MenuSection>
|
||||||
<MenuItem
|
</Menu>
|
||||||
id="manage-teams"
|
</MenuTrigger>
|
||||||
onAction={() => handleNavigate(getUrl('/settings/teams'))}
|
|
||||||
>
|
|
||||||
<Row alignItems="center" justifyContent="space-between" gap width="100%">
|
|
||||||
<Text align="center">Manage teams</Text>
|
|
||||||
<Icon>
|
|
||||||
<ArrowRight />
|
|
||||||
</Icon>
|
|
||||||
</Row>
|
|
||||||
</MenuItem>
|
|
||||||
</MenuSection>
|
|
||||||
</Menu>
|
|
||||||
</Popover>
|
|
||||||
</DialogTrigger>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -84,8 +84,13 @@ export function WebsiteSelect({
|
|||||||
renderValue={renderValue}
|
renderValue={renderValue}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
...buttonProps,
|
...buttonProps,
|
||||||
|
className: [
|
||||||
|
'border-transparent bg-transparent shadow-none hover:border-transparent hover:bg-interactive active:bg-interactive-hover',
|
||||||
|
buttonProps?.className,
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' '),
|
||||||
style: {
|
style: {
|
||||||
minHeight: 40,
|
|
||||||
gap: 0,
|
gap: 0,
|
||||||
justifyContent: isCollapsed ? 'start' : undefined,
|
justifyContent: isCollapsed ? 'start' : undefined,
|
||||||
...buttonProps?.style,
|
...buttonProps?.style,
|
||||||
|
|||||||
Reference in new issue
Block a user