diff --git a/components/Layout.js b/components/Layout.js index ecfe5dc..a7d2e6e 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import Link from 'next/link'; import { useTheme } from '../lib/theme-context'; @@ -127,6 +127,16 @@ export default function Layout({ children, user = { email: 'me@randallstillwell. const { theme, toggleTheme } = useTheme(); const [searchQuery, setSearchQuery] = useState(''); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); + const [isCommunityExpanded, setIsCommunityExpanded] = useState( + router.pathname.startsWith('/community') + ); + + // Auto-expand Community section when navigating to community pages + useEffect(() => { + if (router.pathname.startsWith('/community')) { + setIsCommunityExpanded(true); + } + }, [router.pathname]); const navigation = [ { name: 'Dashboard', href: '/dashboard', icon: 'grid', active: router.pathname === '/dashboard' }, @@ -134,14 +144,24 @@ export default function Layout({ children, user = { email: 'me@randallstillwell. { name: 'Cards', href: '/cards', icon: 'card', active: router.pathname === '/cards' }, { name: 'Decks', href: '/decks', icon: 'deck', active: router.pathname === '/decks', badge: '12' }, { name: 'Analytics', href: '/analytics', icon: 'analytics', active: router.pathname === '/analytics' }, - { name: 'Community', href: '/community', icon: 'community', active: router.pathname === '/community' }, - { name: 'Community Collections', href: '/community/collections', icon: 'community', active: router.pathname === '/community/collections' }, { name: 'Settings', href: '/settings', icon: 'settings', active: router.pathname === '/settings' }, ...(user?.role === 'admin' ? [ { name: 'Admin Tools', href: '/admin/card-editor', icon: 'admin', active: router.pathname.startsWith('/admin'), badge: 'ADMIN' } ] : []) ]; + const communityNavigation = { + name: 'Community', + icon: 'community', + active: router.pathname.startsWith('/community'), + expanded: isCommunityExpanded, + items: [ + { name: 'Collections', href: '/community/collections', active: router.pathname === '/community/collections' }, + { name: 'Decks', href: '/community/decks', active: router.pathname === '/community/decks' }, + { name: 'Forums', href: '/community/forums', active: router.pathname === '/community/forums' } + ] + }; + const bottomNavigation = [ { name: 'Notifications', href: '/notifications', icon: 'notifications', active: router.pathname === '/notifications' }, { name: 'Settings', href: '/settings', icon: 'settings', active: router.pathname === '/settings' }, @@ -321,6 +341,91 @@ export default function Layout({ children, user = { email: 'me@randallstillwell. ))} + + {/* Community Section with Sub-items */} +