Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

New mobile menu.

Mike Cao10bc2895eb37
diff --git a/src/app/(main)/App.tsx b/src/app/(main)/App.tsx
index ee95850b4..16676523d 100644
--- a/src/app/(main)/App.tsx
+++ b/src/app/(main)/App.tsx
@@ -1,10 +1,10 @@
'use client';
-import { Grid, Loading, Column, Row, List, ListItem } from '@umami/react-zen';
+import { Grid, Loading, Column, Row } from '@umami/react-zen';
import Script from 'next/script';
import { UpdateNotice } from './UpdateNotice';
import { SideNav } from '@/app/(main)/SideNav';
import { useLoginQuery, useConfig, useNavigation } from '@/components/hooks';
-import { MobileMenuButton } from '@/components/input/MobileMenuButton';
+import { MobileNav } from '@/app/(main)/MobileNav';
export function App({ children }) {
const { user, isLoading, error } = useLoginQuery();
@@ -29,15 +29,9 @@ export function App({ children }) {
}
return (
- <Grid columns={{ xs: '1fr', lg: 'auto 1fr' }} height="100vh" width="100%" backgroundColor="2">
- <Row display={{ xs: 'flex', lg: 'none' }} alignItems="center" gap padding>
- <MobileMenuButton>
- <List>
- <ListItem>Websites</ListItem>
- <ListItem>Links</ListItem>
- <ListItem>Pixels</ListItem>
- </List>
- </MobileMenuButton>
+ <Grid columns={{ xs: '1fr', lg: 'auto 1fr' }} height="100vh" width="100%">
+ <Row display={{ xs: 'flex', lg: 'none' }} alignItems="center" gap padding="3">
+ <MobileNav />
</Row>
<Column display={{ xs: 'none', lg: 'flex' }}>
<SideNav />
diff --git a/src/app/(main)/MobileNav.tsx b/src/app/(main)/MobileNav.tsx
new file mode 100644
index 000000000..9e5565c01
--- /dev/null
+++ b/src/app/(main)/MobileNav.tsx
@@ -0,0 +1,77 @@
+import {
+ Row,
+ Dialog,
+ DialogTrigger,
+ Button,
+ Icon,
+ Modal,
+ NavMenu,
+ NavMenuItem,
+ IconLabel,
+ Text,
+ Grid,
+} from '@umami/react-zen';
+import { Globe, Grid2x2, LinkIcon, Menu } from '@/components/icons';
+import { useMessages, useNavigation } from '@/components/hooks';
+import Link from 'next/link';
+import { WebsiteNav } from '@/app/(main)/websites/[websiteId]/WebsiteNav';
+import { Logo } from '@/components/svg';
+
+export function MobileNav() {
+ const { formatMessage, labels } = useMessages();
+ const { websiteId } = useNavigation();
+
+ const links = [
+ {
+ id: 'websites',
+ label: formatMessage(labels.websites),
+ path: '/websites',
+ icon: <Globe />,
+ },
+ {
+ id: 'links',
+ label: formatMessage(labels.links),
+ path: '/links',
+ icon: <LinkIcon />,
+ },
+ {
+ id: 'pixels',
+ label: formatMessage(labels.pixels),
+ path: '/pixels',
+ icon: <Grid2x2 />,
+ },
+ ];
+
+ return (
+ <Grid columns="auto 1fr" flexGrow={1}>
+ <DialogTrigger>
+ <Button>
+ <Icon>
+ <Menu />
+ </Icon>
+ </Button>
+ <Modal position="left" offset="80px">
+ <Dialog variant="sheet">
+ <NavMenu padding="3">
+ {links.map(link => {
+ return (
+ <Link key={link.id} href={link.path}>
+ <NavMenuItem>
+ <IconLabel icon={link.icon} label={link.label} />
+ </NavMenuItem>
+ </Link>
+ );
+ })}
+ </NavMenu>
+ {websiteId && <WebsiteNav websiteId={websiteId} />}
+ </Dialog>
+ </Modal>
+ </DialogTrigger>
+ <Row alignItems="center" justifyContent="center" flexGrow={1}>
+ <IconLabel icon={<Logo />} style={{ width: 'auto' }}>
+ <Text weight="bold">umami</Text>
+ </IconLabel>
+ </Row>
+ </Grid>
+ );
+}
diff --git a/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx b/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx
index d357c6a3c..c92bbd9c8 100644
--- a/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx
+++ b/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx
@@ -12,6 +12,7 @@ export function WebsiteLayout({ websiteId, children }: { websiteId: string; chil
<Grid columns={{ xs: '1fr', lg: 'auto 1fr' }} width="100%" height="100%">
<Column
display={{ xs: 'none', lg: 'flex' }}
+ width="240px"
height="100%"
border="right"
backgroundColor
diff --git a/src/components/common/SideMenu.tsx b/src/components/common/SideMenu.tsx
index 2848e3046..c8a7c9983 100644
--- a/src/components/common/SideMenu.tsx
+++ b/src/components/common/SideMenu.tsx
@@ -57,7 +57,6 @@ export function SideMenu({
<Column
gap
padding
- width="240px"
overflowY="auto"
justifyContent="space-between"
position="sticky"
diff --git a/src/components/input/MobileMenuButton.tsx b/src/components/input/MobileMenuButton.tsx
deleted file mode 100644
index 8994922b1..000000000
--- a/src/components/input/MobileMenuButton.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Button, Icon, DialogTrigger, Dialog, Modal } from '@umami/react-zen';
-import { Menu } from '@/components/icons';
-import { ReactNode } from 'react';
-
-export function MobileMenuButton({ children }: { children: ReactNode }) {
- return (
- <DialogTrigger>
- <Button>
- <Icon>
- <Menu />
- </Icon>
- </Button>
- <Modal position="left" offset="20px">
- <Dialog variant="sheet">{children}</Dialog>
- </Modal>
- </DialogTrigger>
- );
-}
diff --git a/src/components/input/WebsiteSelect.tsx b/src/components/input/WebsiteSelect.tsx
index 01861fbd4..29ae040b0 100644
--- a/src/components/input/WebsiteSelect.tsx
+++ b/src/components/input/WebsiteSelect.tsx
@@ -1,6 +1,11 @@
import { useState } from 'react';
import { Select, SelectProps, ListItem, Text, Row } from '@umami/react-zen';
-import { useUserWebsitesQuery, useMessages, useLoginQuery, useWebsite } from '@/components/hooks';
+import {
+ useUserWebsitesQuery,
+ useMessages,
+ useLoginQuery,
+ useWebsiteQuery,
+} from '@/components/hooks';
import { Empty } from '@/components/common/Empty';
export function WebsiteSelect({
@@ -15,7 +20,7 @@ export function WebsiteSelect({
includeTeams?: boolean;
} & SelectProps) {
const { formatMessage, messages } = useMessages();
- const website = useWebsite();
+ const { data: website } = useWebsiteQuery(websiteId);
const [name, setName] = useState<string>(website?.name);
const [search, setSearch] = useState('');
const { user } = useLoginQuery();