From 9a5561c2c84e9ec955aefefbbc7d7bae6d72c901 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Sat, 26 Jul 2025 09:51:40 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Restructured=20User=20Profile=20?= =?UTF-8?q?&=20Theme=20Toggle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ Profile Dropdown Implementation: - Created comprehensive UserProfileDropdown component - Moved user profile to bottom of sidebar (better UX) - Added dropdown menu with Profile, Settings, Admin Panel, Logout - Profile button shows user avatar, email, and role - Smooth dropdown animation with backdrop click-to-close 🎨 Fire-Themed Profile Menu: - Logout option uses ember red color for distinction - Profile icons match the overall design system - Consistent hover states and accessibility features - Proper ARIA attributes for dropdown functionality 🌙 Separated Theme Toggle: - Moved theme toggle out of profile section - Now appears as standalone navigation item above profile - Shows 'Dark Mode' / 'Light Mode' text labels - Maintains all accessibility features and fire theming ♿ Enhanced Accessibility: - Proper dropdown ARIA attributes (expanded, haspopup) - Keyboard navigation support throughout - Screen reader friendly with proper labels - Focus management for dropdown interactions 🎯 Admin Panel Integration: - Admin Panel option only shows for admin users - Conditional rendering based on user role - Proper navigation structure for different user types - Consistent with existing admin badge logic �� Mobile Optimizations: - Dropdown works seamlessly on mobile devices - Proper touch targets and spacing - Auto-closes mobile menu when navigating - Backdrop prevents accidental interactions The sidebar now has a much cleaner hierarchy with the profile at the bottom and easy access to all user functions! 🔥👤 --- components/Layout.js | 230 ++++++++++++++++++++++++++++--------------- 1 file changed, 152 insertions(+), 78 deletions(-) diff --git a/components/Layout.js b/components/Layout.js index 3ab4196..507c576 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -3,6 +3,125 @@ import { useRouter } from 'next/router'; import Link from 'next/link'; import { useTheme } from '../lib/theme-context'; +// User Profile Dropdown Component +function UserProfileDropdown({ user, onMobileMenuClose }) { + const [isDropdownOpen, setIsDropdownOpen] = useState(false); + + const profileMenuItems = [ + { name: 'Profile', href: '/profile', icon: 'user' }, + { name: 'Settings', href: '/settings', icon: 'settings' }, + ...(user?.role === 'admin' ? [ + { name: 'Admin Panel', href: '/admin', icon: 'admin' } + ] : []), + { name: 'Logout', href: '/logout', icon: 'logout', isLogout: true } + ]; + + const getProfileIcon = (iconName) => { + const icons = { + user: ( + + + + ), + settings: ( + + + + + ), + admin: ( + + + + ), + logout: ( + + + + ) + }; + return icons[iconName] || icons.user; + }; + + return ( +
+ {/* Dropdown Menu */} + {isDropdownOpen && ( + <> + {/* Backdrop */} +
setIsDropdownOpen(false)} + /> + + {/* Menu */} +
+
+ {profileMenuItems.map((item) => ( + +
{ + setIsDropdownOpen(false); + onMobileMenuClose(); + }} + > + + {item.name} +
+ + ))} +
+
+ + )} + + {/* Profile Button */} + +
+ ); +} + export default function Layout({ children, user = { email: 'me@randallstillwell.com', role: 'user' }, showSearch = false }) { const router = useRouter(); const { theme, toggleTheme } = useTheme(); @@ -203,85 +322,40 @@ export default function Layout({ children, user = { email: 'me@randallstillwell. ))} - {/* Profile Section */} -
- {/* User Profile */} -
-
-
- - {user?.email?.charAt(0).toUpperCase() || 'G'} - -
-
-

- {user?.email || 'Guest'} -

-

- {user?.role || 'visitor'} -

-
- -
-
+ {/* Bottom Section */} +
+ {/* Theme Toggle */} + - {/* Bottom Navigation */} - + {/* User Profile Dropdown */} + setIsMobileMenuOpen(false)} + />