"use client"; /** * SiteBottomNav — mobile-only bottom tab bar. * * Four items: Home · Search · Kautilya · Account. * Mirrors the Instagram pattern — fixed to the viewport bottom, full * width, equal-width tabs, the active tab uses the primary color. * * Hidden on md+ — desktop uses SiteSidebar. */ import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Home, Search, User as UserIcon } from "lucide-react"; import { useAuth } from "@/components/auth/auth-provider"; import { KautilyaIcon } from "@/components/selection-toolbar/shared"; import { cn } from "@/lib/utils"; type Item = { /** Tab label, used for the aria-label. Bottom nav is icon-only. */ label: string; href: string; icon: React.ReactNode; matchPrefixes?: string[]; }; export function SiteBottomNav() { const pathname = usePathname(); const { user } = useAuth(); const items: Item[] = [ { href: "/", label: "Home", icon: }, { href: "/search", label: "Search", icon: , // Search is the knowledgebase entry point too — keep the tab lit // while the user is reading anywhere in the library. matchPrefixes: [ "/search", "/books", "/letters", "/transcriptions", "/essays", "/glossary", "/journals", "/magazines", "/other-documents", "/disciples", ], }, { href: "/ask", label: "Kautilya", icon: , }, { href: user ? "/u/me" : "/login", label: user ? "You" : "Sign in", // Show the user's uploaded avatar when available so the nav // feels personalized. Falls back to the generic person glyph // for anonymous viewers and signed-in users who haven't // uploaded a picture yet. The avatar circle is slightly larger // (size-6 vs the size-5 icons elsewhere) so it reads as an // identifying glyph rather than fading in with the other tabs. icon: user?.avatar_url ? ( ) : ( ), matchPrefixes: ["/u/me", "/login", "/signup"], }, ]; function isActive(item: Item): boolean { if (item.matchPrefixes) { return item.matchPrefixes.some((p) => p === "/" ? pathname === "/" : pathname.startsWith(p), ); } if (item.href === "/") return pathname === "/"; return pathname === item.href || pathname.startsWith(`${item.href}/`); } return ( ); }