"use client" import { useTheme } from "next-themes" import { Moon, Sun, Menu } from "lucide-react" import { cn } from "@/lib/utils" import { useEffect, useState } from "react" import { useSidebar } from "@/contexts/sidebar-context" import { useParams, usePathname } from "next/navigation" import { PageBreadcrumb } from "./page-breadcrumb" // Define all sections for breadcrumb lookup const sections = [ // Foundation { id: "color", name: "Color", category: "foundation" as const }, { id: "iconography", name: "Iconography", category: "foundation" as const }, { id: "typography", name: "Typography", category: "foundation" as const }, { id: "spacing", name: "Spacing", category: "foundation" as const }, { id: "elevation", name: "Elevation", category: "foundation" as const }, // Components { id: "accordion", name: "Accordion", category: "components" as const }, { id: "alerts", name: "Alert", category: "components" as const }, { id: "alert-dialog", name: "Alert Dialog", category: "components" as const }, { id: "avatars", name: "Avatar", category: "components" as const }, { id: "badges", name: "Badge", category: "components" as const }, { id: "breadcrumbs", name: "Breadcrumb", category: "components" as const }, { id: "buttons", name: "Button", category: "components" as const }, { id: "calendar", name: "Calendar", category: "components" as const }, { id: "cards", name: "Card", category: "components" as const }, { id: "checkbox", name: "Checkbox", category: "components" as const }, { id: "collapsible", name: "Collapsible", category: "components" as const }, { id: "combobox", name: "Combobox", category: "components" as const }, { id: "command", name: "Command", category: "components" as const }, { id: "context-menu", name: "Context Menu", category: "components" as const }, { id: "dropdowns", name: "Dropdown", category: "components" as const }, { id: "forms", name: "Form", category: "components" as const }, { id: "hover-card", name: "Hover Card", category: "components" as const }, { id: "label", name: "Label", category: "components" as const }, { id: "modals", name: "Modal", category: "components" as const }, { id: "pagination", name: "Pagination", category: "components" as const }, { id: "progress", name: "Progress", category: "components" as const }, { id: "scroll-area", name: "Scroll Area", category: "components" as const }, { id: "sheet", name: "Sheet", category: "components" as const }, { id: "skeleton", name: "Skeleton", category: "components" as const }, { id: "slider", name: "Slider", category: "components" as const }, { id: "switch", name: "Switch", category: "components" as const }, { id: "tabs", name: "Tab", category: "components" as const }, { id: "tables", name: "Table", category: "components" as const }, { id: "toggle", name: "Toggle", category: "components" as const }, { id: "tooltips", name: "Tooltip", category: "components" as const }, // Blocks { id: "contact-form", name: "Contact Form", category: "blocks" as const }, { id: "dashboard-stats", name: "Dashboard Stats", category: "blocks" as const }, { id: "data-table", name: "Data Table", category: "blocks" as const }, { id: "user-profile", name: "User Profile", category: "blocks" as const }, { id: "settings-panel", name: "Settings Panel", category: "blocks" as const }, { id: "file-upload", name: "File Upload", category: "blocks" as const }, ] export function FixedHeader() { const { setTheme, theme } = useTheme() const [mounted, setMounted] = useState(false) const { sidebarVisible, toggleSidebar } = useSidebar() const params = useParams() const pathname = usePathname() // Only show the theme toggle after mounting to avoid hydration mismatch useEffect(() => { setMounted(true) }, []) // Debug function to test toggle const handleToggleClick = () => { console.log("Toggle clicked, current state:", sidebarVisible) toggleSidebar() } // Determine if we should show breadcrumbs const shouldShowBreadcrumbs = () => { // Show breadcrumbs for section pages (like /buttons, /cards, etc.) if (params?.section && typeof params.section === "string") { const section = sections.find((s) => s.id === params.section) return !!section } // Show breadcrumbs for category pages if (pathname === "/foundation" || pathname === "/components" || pathname === "/blocks") { return true } return false } const getBreadcrumbData = () => { if (params?.section && typeof params.section === "string") { const section = sections.find((s) => s.id === params.section) if (section) { return { category: section.category, sectionName: section.name, sectionId: section.id, } } } // For category pages if (pathname === "/foundation") { return { category: "foundation" as const, sectionName: "Foundation", sectionId: "foundation" } } if (pathname === "/components") { return { category: "components" as const, sectionName: "Components", sectionId: "components" } } if (pathname === "/blocks") { return { category: "blocks" as const, sectionName: "Blocks", sectionId: "blocks" } } return null } const breadcrumbData = getBreadcrumbData() return (
{/* Single smooth progressive blur overlay */}
{/* Container with content alignment matching page content */}
{/* Left side - Breadcrumbs aligned with page content */}
{/* Menu button - always visible on mobile, conditional on desktop */} {/* Breadcrumbs - hidden on mobile, visible on desktop with proper spacing */} {shouldShowBreadcrumbs() && breadcrumbData && (
)}
{/* Right side - Theme toggle */}
{mounted && (
)}
) }