umami/src/app/(main)/MobileNav.tsx
Mike Cao 04c7216928 Add UserButton to SideNav, refactor NavButton into TeamsButton
- Create UserButton component at bottom of SideNav with Settings, Language,
  Theme, Admin, and Logout menu items
- Move Settings/Logout/Admin/Docs/Support out of NavButton into UserButton
- Remove LanguageButton and ThemeButton from SideNav bottom
- Refactor NavButton into TeamsButton with simplified team switching
- Simplify WebsiteNav and move TeamsButton to App top bar

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 21:34:42 -08:00

70 lines
2.2 KiB
TypeScript

import { Grid, Row, Text } from '@umami/react-zen';
import Link from 'next/link';
import { WebsiteNav } from '@/app/(main)/websites/[websiteId]/WebsiteNav';
import { IconLabel } from '@/components/common/IconLabel';
import { useMessages, useNavigation } from '@/components/hooks';
import { Globe, Grid2x2, LinkIcon } from '@/components/icons';
import { MobileMenuButton } from '@/components/input/MobileMenuButton';
import { TeamsButton } from '@/components/input/TeamsButton';
import { Logo } from '@/components/svg';
import { AdminNav } from './admin/AdminNav';
import { SettingsNav } from './settings/SettingsNav';
export function MobileNav() {
const { t, labels } = useMessages();
const { pathname, websiteId, renderUrl } = useNavigation();
const isAdmin = pathname.includes('/admin');
const isSettings = pathname.includes('/settings');
const links = [
{
id: 'websites',
label: t(labels.websites),
path: '/websites',
icon: <Globe />,
},
{
id: 'links',
label: t(labels.links),
path: '/links',
icon: <LinkIcon />,
},
{
id: 'pixels',
label: t(labels.pixels),
path: '/pixels',
icon: <Grid2x2 />,
},
];
return (
<Grid columns="auto 1fr" flexGrow={1} backgroundColor="surface-sunken" borderRadius>
<MobileMenuButton>
{({ close }) => {
return (
<>
<Row padding="3" onClick={close} border="bottom">
<TeamsButton />
{links.map(link => {
return (
<Link key={link.id} href={renderUrl(link.path)}>
<IconLabel icon={link.icon} label={link.label} />
</Link>
);
})}
</Row>
{websiteId && <WebsiteNav websiteId={websiteId} onItemClick={close} />}
{isAdmin && <AdminNav onItemClick={close} />}
{isSettings && <SettingsNav onItemClick={close} />}
</>
);
}}
</MobileMenuButton>
<Row alignItems="center" justifyContent="center" flexGrow={1}>
<IconLabel icon={<Logo />} style={{ width: 'auto' }}>
<Text weight="bold">umami</Text>
</IconLabel>
</Row>
</Grid>
);
}