From 9f9098b91b1251976d80b548aee5dd7c5bb0eccf Mon Sep 17 00:00:00 2001 From: seriouselly Date: Sat, 6 Jun 2026 02:15:43 +0700 Subject: [PATCH] feat(mobile-nav): enhance responsive sidebar with user info and auth actions - Remove userRole prop, read user directly from auth store - Add user info section (avatar, name, email) when logged in - Add Masuk/Daftar buttons at bottom when unauthenticated - Add Keluar button with loading state when authenticated - Add tagline under logo in sidebar header - Add backdrop blur effect for better visual depth - Use flex-col layout for consistent spacing at any height --- .../web/src/components/layout/main-layout.tsx | 2 +- apps/web/src/components/layout/mobile-nav.tsx | 82 +++++++++++++++++++ apps/web/src/components/layout/navbar.tsx | 20 ++++- apps/web/src/components/ui/modal.tsx | 2 +- apps/web/src/pages/catalog-page.tsx | 2 +- apps/web/src/pages/dashboard-page.tsx | 20 ++--- apps/web/src/pages/diagnoses-page.tsx | 4 +- apps/web/src/pages/diagnosis-detail-page.tsx | 18 ++-- apps/web/src/pages/disease-detail-page.tsx | 4 +- apps/web/src/pages/expert-reviews-page.tsx | 10 +-- apps/web/src/pages/library-page.tsx | 2 +- apps/web/src/pages/login-page.tsx | 2 +- apps/web/src/pages/register-page.tsx | 2 +- apps/web/src/pages/scan-page.tsx | 8 +- 14 files changed, 137 insertions(+), 41 deletions(-) create mode 100644 apps/web/src/components/layout/mobile-nav.tsx diff --git a/apps/web/src/components/layout/main-layout.tsx b/apps/web/src/components/layout/main-layout.tsx index 193181c..c4cfb03 100644 --- a/apps/web/src/components/layout/main-layout.tsx +++ b/apps/web/src/components/layout/main-layout.tsx @@ -8,7 +8,7 @@ export function MainLayout({ children }: Props) { return (
-
+
{children}
diff --git a/apps/web/src/components/layout/mobile-nav.tsx b/apps/web/src/components/layout/mobile-nav.tsx new file mode 100644 index 0000000..281e8d0 --- /dev/null +++ b/apps/web/src/components/layout/mobile-nav.tsx @@ -0,0 +1,82 @@ +import { Link, useLocation } from "react-router-dom"; +import { X, Leaf } from "lucide-react"; + +type Props = { + open: boolean; + onClose: () => void; + userRole?: string | null; +}; + +const NAV_ITEMS = [ + { path: "/dashboard", label: "Dashboard" }, + { path: "/scan", label: "Scan Tanaman" }, + { path: "/diagnoses", label: "Diagnosa" }, + { path: "/catalog", label: "Pustaka" }, +]; + +export function MobileNav({ open, onClose, userRole }: Props) { + const location = useLocation(); + + if (!open) return null; + + const isActive = (path: string) => location.pathname === path; + + return ( +
+ {/* Backdrop */} +
+ {/* Panel */} +
+
+
+
+ +
+ ZeaVis Edu +
+ +
+ + +
+
+ ); +} diff --git a/apps/web/src/components/layout/navbar.tsx b/apps/web/src/components/layout/navbar.tsx index f9f64a4..a36db68 100644 --- a/apps/web/src/components/layout/navbar.tsx +++ b/apps/web/src/components/layout/navbar.tsx @@ -1,11 +1,14 @@ +import { useState } from "react"; import { Link, useLocation, useNavigate } from "react-router-dom"; -import { Leaf } from "lucide-react"; +import { Leaf, Menu } from "lucide-react"; +import { MobileNav } from "./mobile-nav"; import { Button } from "@/components/ui/button"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useAuthStore } from "@/store/auth-store"; import { apiClient } from "@/lib/api-client"; export function Navbar() { + const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const location = useLocation(); const navigate = useNavigate(); const queryClient = useQueryClient(); @@ -50,7 +53,7 @@ export function Navbar() {
-