diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index 34e131c..a5cd5dc 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -8,10 +8,11 @@ import { NavBar } from "@/components/layout/nav-bar"; import { NotificationCenter } from "@/components/layout/notification-center"; import { routeLabelKey } from "@/components/layout/nav-items"; import { ShellMessagesButton } from "@/components/layout/shell-messages-button"; +import { MobileNavSheet } from "@/components/layout/mobile-nav-sheet"; import { SideNav } from "@/components/layout/side-nav"; import { SidebarAccount } from "@/components/layout/sidebar-account"; import { Button } from "@/components/ui/button"; -import { IconChevronLeft, IconPanelLeft, IconSearch, IconSparkles, IconX } from "@/components/ui/icons"; +import { IconChevronLeft, IconPanelLeft, IconSearch, IconSparkles } from "@/components/ui/icons"; import { Toaster } from "@/components/ui/toast"; import { useAuth } from "@/stores/auth-context"; import { ShellFeedProvider } from "@/stores/shell-feed-context"; @@ -96,37 +97,12 @@ export function AppShell(props: ParentProps) { - -
- -
-
- setMobileOpen(false)} /> -
- - - + + setMobileOpen(false)} + onLogout={logout} + />
@@ -183,7 +159,7 @@ export function AppShell(props: ParentProps) {
@@ -193,7 +169,7 @@ export function AppShell(props: ParentProps) {
{/* MobileTabBar stays inside the provider — it is a shell surface, so a useShellFeed() badge there must not throw. */} - + setMobileOpen(true)} /> diff --git a/src/components/layout/mobile-nav-sheet.tsx b/src/components/layout/mobile-nav-sheet.tsx new file mode 100644 index 0000000..7b8347c --- /dev/null +++ b/src/components/layout/mobile-nav-sheet.tsx @@ -0,0 +1,130 @@ +import { For, Show } from "solid-js"; +import { Link, useRouterState } from "@tanstack/solid-router"; +import { routeNavItem, sidebarNavGroups, type NavItem } from "@/components/layout/nav-items"; +import { SidebarAccount } from "@/components/layout/sidebar-account"; +import { IconX } from "@/components/ui/icons"; +import { cn } from "@/lib/cn"; +import { useAuth } from "@/stores/auth-context"; +import { useShellFeed } from "@/stores/shell-feed-context"; +import { useT } from "@/stores/preferences-context"; + +/** + * The phone-sized navigation menu: a sheet that rises from the bottom of the + * screen, where a thumb already is, instead of the side drawer this replaces. + * + * It stays mounted and is moved off-screen when closed, so opening and closing + * both animate; a `` around it would make it appear and disappear in one + * frame. + */ +export function MobileNavSheet(props: { + open: boolean; + onClose: () => void; + onLogout: () => void | Promise; +}) { + const auth = useAuth(); + const t = useT(); + const feed = useShellFeed(); + const pathname = useRouterState({ select: (state) => state.location.pathname }); + + // The primary destinations are already one tap away in the tab bar, so the + // sheet lists everything else. + const groups = () => sidebarNavGroups(auth.user()?.role); + const current = () => routeNavItem(pathname(), auth.user()?.role); + const badgeFor = (item: NavItem) => (item.id === "messages" ? feed.unreadMessages().total : 0); + + return ( +
+ +
+ +
+ + {(group) => ( +
+

+ {t(group.labelKey)} +

+
+ + {(item) => { + const active = () => current()?.id === item.id; + return ( + + + + + + {t(item.labelKey)} + + 0}> + + {badgeFor(item) > 99 ? "99+" : badgeFor(item)} + + + + ); + }} + +
+
+ )} +
+
+ + + + + ); +}