feat: implement dynamic mobile header with centered page title and adaptive layout

This commit is contained in:
2026-01-31 01:40:28 +01:00
parent f26dee782c
commit 712a1a2937
7 changed files with 491 additions and 102 deletions

View File

@@ -3,6 +3,7 @@
import Header from "@/components/Header/index";
import Sidebar from "@/components/Sidebar";
import React, { useState } from "react";
import { usePathname } from "next/navigation";
interface LayoutProps {
children: React.ReactNode;
@@ -10,6 +11,21 @@ interface LayoutProps {
const Layout: React.FC<LayoutProps> = ({ children }) => {
const [sidebarOpen, setSidebarOpen] = useState(false);
const pathname = usePathname();
const getPageTitle = (path: string) => {
if (path === "/") return "Overview";
const titles: Record<string, string> = {
"/users": "Users",
"/settings": "Settings",
"/profile": "Profile",
"/songs": "Songs Database",
"/events": "Worship & Events",
};
return titles[path] || "Dashboard";
};
return (
<div className="dashboard">
@@ -26,7 +42,11 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
<div
className={`flex min-h-screen flex-col transition-all duration-300 md:pl-64`}
>
<Header onMenuClick={() => setSidebarOpen(!sidebarOpen)} />
<Header
onMenuClick={() => setSidebarOpen(!sidebarOpen)}
pageTitle={getPageTitle(pathname)}
/>
<main className="animate-in fade-in flex-1 p-4 duration-500 md:p-8">
{children}
</main>
@@ -35,4 +55,4 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
);
};
export default Layout;
export default Layout;