diff --git a/src/components/Layout.js b/src/components/Layout.js index 743bc527..a42b3f05 100755 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -1,25 +1,37 @@ -import React, { useState, useEffect, useRef } from 'react'; -import { useLocation } from 'react-router-dom'; -import ToolSidebar from './ToolSidebar'; -import NavigationConfirmModal from './NavigationConfirmModal'; -import useNavigationGuard from '../hooks/useNavigationGuard'; -import { Menu, X, ChevronDown, Terminal, Sparkles, Home } from 'lucide-react'; -import ThemeToggle from './ThemeToggle'; -import SEOHead from './SEOHead'; -import ConsentBanner from './ConsentBanner'; -import { NON_TOOLS, TOOLS, SITE_CONFIG, getCategoryConfig } from '../config/tools'; -import { useAnalytics } from '../hooks/useAnalytics'; +import React, { useState, useEffect, useRef } from "react"; +import { useLocation } from "react-router-dom"; +import ToolSidebar from "./ToolSidebar"; +import NavigationConfirmModal from "./NavigationConfirmModal"; +import useNavigationGuard from "../hooks/useNavigationGuard"; +import { Menu, X, ChevronDown, Terminal, Sparkles, Home } from "lucide-react"; +import ThemeToggle from "./ThemeToggle"; +import SEOHead from "./SEOHead"; +import ConsentBanner from "./ConsentBanner"; +import { + NON_TOOLS, + TOOLS, + SITE_CONFIG, + getCategoryConfig, +} from "../config/tools"; +import { useAnalytics } from "../hooks/useAnalytics"; const Layout = ({ children }) => { const location = useLocation(); - const { showModal, pendingNavigation, handleConfirm, handleCancel, hasUnsavedData, navigateWithGuard } = useNavigationGuard(); + const { + showModal, + pendingNavigation, + handleConfirm, + handleCancel, + hasUnsavedData, + navigateWithGuard, + } = useNavigationGuard(); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const dropdownRef = useRef(null); - + // Initialize analytics tracking useAnalytics(); - + const isActive = (path) => { return location.pathname === path; }; @@ -32,9 +44,9 @@ const Layout = ({ children }) => { } }; - document.addEventListener('mousedown', handleClickOutside); + document.addEventListener("mousedown", handleClickOutside); return () => { - document.removeEventListener('mousedown', handleClickOutside); + document.removeEventListener("mousedown", handleClickOutside); }; }, []); @@ -45,33 +57,42 @@ const Layout = ({ children }) => { }, [location.pathname]); // Check if we're on a tool page (not homepage) - const isToolPage = location.pathname !== '/'; - + const isToolPage = location.pathname !== "/"; + // Check if we're on invoice preview page (no sidebar needed) - const isInvoicePreviewPage = location.pathname === '/invoice-preview'; + const isInvoicePreviewPage = location.pathname === "/invoice-preview"; return (
{/* SEO Head Management */} - + {/* Header */}
-
+
- - +
{/* Desktop Navigation - only show on homepage */} {!isToolPage && ( @@ -91,18 +112,18 @@ const Layout = ({ children }) => { - + {/* Tools Dropdown */}
- + {/* Dropdown Menu */} {isDropdownOpen && (
@@ -125,8 +148,10 @@ const Layout = ({ children }) => {
{TOOLS.map((tool) => { const IconComponent = tool.icon; - const categoryConfig = getCategoryConfig(tool.category); - + const categoryConfig = getCategoryConfig( + tool.category, + ); + return (
@@ -180,49 +213,19 @@ const Layout = ({ children }) => { {isMobileMenuOpen && ( <> {/* Overlay */} -
setIsMobileMenuOpen(false)} /> - + {/* Menu */}
-
-
- {/* Non-Tools Section */} - {NON_TOOLS.map((tool) => { - const IconComponent = tool.icon; - - return ( - - ); - })} - -
-
- - {isToolPage ? 'Switch Tools' : 'Tools'} -
- {TOOLS.map((tool) => { +
+
+ {/* Non-Tools Section */} + {NON_TOOLS.map((tool) => { const IconComponent = tool.icon; - const categoryConfig = getCategoryConfig(tool.category); - + return ( ); })} + +
+
+ + {isToolPage ? "Switch Tools" : "Tools"} +
+ {TOOLS.map((tool) => { + const IconComponent = tool.icon; + const categoryConfig = getCategoryConfig(tool.category); + + return ( + + ); + })} +
-
)} @@ -263,22 +304,18 @@ const Layout = ({ children }) => {
-
+
{children}
) : isInvoicePreviewPage ? (
-
- {children} -
+
{children}
) : (
-
- {children} -
+
{children}
{/* Global Footer for Homepage */}
@@ -287,15 +324,15 @@ const Layout = ({ children }) => {
- {SITE_CONFIG.title} { // Fallback to Terminal icon with text if logo fails to load - e.target.style.display = 'none'; - e.target.nextSibling.style.display = 'flex'; + e.target.style.display = "none"; + e.target.nextSibling.style.display = "flex"; }} />
@@ -333,22 +370,26 @@ const Layout = ({ children }) => {
- - - - - - -
)} - + {/* GDPR Consent Banner */}