From 5f6b66c40ec26a08387d2eff6f52ca607111b6ef Mon Sep 17 00:00:00 2001 From: highperfocused Date: Mon, 20 Oct 2025 16:12:47 +0200 Subject: [PATCH] feat: add BottomNav component for mobile navigation and update Layout to include it --- src/components/BottomNav.tsx | 109 ++++++++++++++++++++ src/components/Header.tsx | 59 +---------- src/components/Layout.tsx | 9 +- src/components/ProfessionalBlogPostForm.tsx | 4 +- 4 files changed, 123 insertions(+), 58 deletions(-) create mode 100644 src/components/BottomNav.tsx diff --git a/src/components/BottomNav.tsx b/src/components/BottomNav.tsx new file mode 100644 index 0000000..3cbe1f4 --- /dev/null +++ b/src/components/BottomNav.tsx @@ -0,0 +1,109 @@ +import { Link, useLocation } from 'react-router-dom'; +import { Home, Users, Bookmark, PenSquare, User as UserIcon } from 'lucide-react'; +import { useCurrentUser } from '@/hooks/useCurrentUser'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { nip19 } from 'nostr-tools'; + +export function BottomNav() { + const { user, metadata } = useCurrentUser(); + const location = useLocation(); + + const profilePath = user ? `/${nip19.npubEncode(user.pubkey)}` : '/'; + + const isActive = (pathStartsWith: string | string[]) => { + const paths = Array.isArray(pathStartsWith) ? pathStartsWith : [pathStartsWith]; + return paths.some((p) => location.pathname === p || location.pathname.startsWith(p + '/')); + }; + + return ( + + ); +} diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 074af51..b4bef6d 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -2,14 +2,11 @@ import { Link } from 'react-router-dom'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { LoginArea } from '@/components/auth/LoginArea'; import { Button } from '@/components/ui/button'; -import { PenSquare, Menu, Bookmark, Users } from 'lucide-react'; -import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet'; +import { PenSquare, Bookmark, Users } from 'lucide-react'; import { ThemeToggle } from '@/components/ThemeToggle'; -import { useState } from 'react'; export function Header() { const { user } = useCurrentUser(); - const [isMenuOpen, setIsMenuOpen] = useState(false); return (
@@ -53,56 +50,10 @@ export function Header() { - {/* Mobile Menu */} -
- - - - - -
- {/* Theme Toggle in Menu */} -
- Theme - -
- - {/* Login Area in Menu */} -
- Account - -
- - {/* Navigation for logged in users */} - {user && ( - <> -
- - - -
- - )} -
-
-
+ {/* Mobile: show LoginArea in header (bottom nav is still used for nav) */} +
+ +
diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 461da80..123627a 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,5 +1,6 @@ import { ReactNode } from 'react'; import { Header } from './Header'; +import { BottomNav } from './BottomNav'; import packageJson from '../../package.json'; interface LayoutProps { @@ -10,10 +11,14 @@ export function Layout({ children }: LayoutProps) { return (
-
+ {/* Add bottom padding on mobile so content isn't hidden behind the bottom nav */} +
{children}
-