11import React from 'react' ;
2+ import { NavLink } from 'react-router-dom' ;
23import {
34 LayoutDashboard ,
45 Bot ,
5- Github ,
6- MessageSquare ,
76 Users ,
87 Activity ,
98 GitPullRequest ,
109 MessageCircleQuestion ,
1110 Menu ,
1211 Settings ,
13- User
12+ User ,
13+ LogOut
1414} from 'lucide-react' ;
1515
1616interface SidebarProps {
1717 isOpen : boolean ;
1818 setIsOpen : ( isOpen : boolean ) => void ;
19- activePage : string ;
20- setActivePage : ( page : string ) => void ;
19+ onLogout : ( ) => void ;
2120}
2221
23- const Sidebar : React . FC < SidebarProps > = ( { isOpen, setIsOpen, activePage, setActivePage } ) => (
24- < div className = { `fixed top-0 left-0 h-full bg-gray-900 text-white transition-all duration-300 ease-in-out ${ isOpen ? 'w-64' : 'w-20' } ` } >
25- < div className = "p-4 flex items-center justify-between" >
26- < h2 className = { `font-bold text-xl ${ ! isOpen && 'hidden' } ` } > Devr.AI</ h2 >
27- < button onClick = { ( ) => setIsOpen ( ! isOpen ) } className = "p-2 hover:bg-gray-800 rounded-lg" >
28- < Menu size = { 20 } />
29- </ button >
22+ const navItems = [
23+ { icon : < LayoutDashboard size = { 20 } /> , label : 'Dashboard' , path : '/dashboard' } ,
24+ { icon : < Bot size = { 20 } /> , label : 'Bot Integration' , path : '/integration' } ,
25+ { icon : < Users size = { 20 } /> , label : 'Contributors' , path : '/contributors' } ,
26+ { icon : < Activity size = { 20 } /> , label : 'Analytics' , path : '/analytics' } ,
27+ { icon : < GitPullRequest size = { 20 } /> , label : 'Pull Requests' , path : '/prs' } ,
28+ { icon : < MessageCircleQuestion size = { 20 } /> , label : 'Support' , path : '/support' } ,
29+ { icon : < Settings size = { 20 } /> , label : 'Settings' , path : '/settings' } ,
30+ { icon : < User size = { 20 } /> , label : 'Profile' , path : '/profile' } ,
31+ ] ;
32+
33+ const Sidebar : React . FC < SidebarProps > = ( { isOpen, setIsOpen, onLogout } ) => (
34+ < div className = { `fixed top-0 left-0 h-full bg-gray-900 text-white transition-all duration-300 ease-in-out ${ isOpen ? 'w-64' : 'w-20' } flex flex-col` } >
35+ < div >
36+ < div className = "p-4 flex items-center justify-between" >
37+ < h2 className = { `font-bold text-xl ${ ! isOpen && 'hidden' } ` } > Devr.AI</ h2 >
38+ < button onClick = { ( ) => setIsOpen ( ! isOpen ) } className = "p-2 hover:bg-gray-800 rounded-lg" >
39+ < Menu size = { 20 } />
40+ </ button >
41+ </ div >
42+
43+ < nav className = "mt-8" >
44+ { navItems . map ( ( item ) => (
45+ < NavLink
46+ key = { item . path }
47+ to = { item . path }
48+ className = { ( { isActive } ) =>
49+ `w-full flex items-center px-4 py-3 text-gray-300 hover:bg-gray-800 hover:text-green-400 transition-colors ${
50+ isActive ? 'bg-gray-800 text-green-400' : ''
51+ } `
52+ }
53+ >
54+ { item . icon }
55+ < span className = { `ml-4 ${ ! isOpen && 'hidden' } ` } > { item . label } </ span >
56+ </ NavLink >
57+ ) ) }
58+ </ nav >
3059 </ div >
31-
32- < nav className = "mt-8" >
33- { [
34- { icon : < LayoutDashboard size = { 20 } /> , label : 'Dashboard' , id : 'dashboard' } ,
35- { icon : < Bot size = { 20 } /> , label : 'Bot Integration' , id : 'integration' } ,
36- { icon : < Users size = { 20 } /> , label : 'Contributors' , id : 'contributors' } ,
37- { icon : < Activity size = { 20 } /> , label : 'Analytics' , id : 'analytics' } ,
38- { icon : < GitPullRequest size = { 20 } /> , label : 'Pull Requests' , id : 'prs' } ,
39- { icon : < MessageCircleQuestion size = { 20 } /> , label : 'Support' , id : 'support' } ,
40- { icon : < Settings size = { 20 } /> , label : 'Settings' , id : 'settings' } ,
41- { icon : < User size = { 20 } /> , label : 'Profile' , id : 'profile' } ,
42- ] . map ( ( item ) => (
60+ < div className = "mt-auto p-4" >
4361 < button
44- key = { item . id }
45- onClick = { ( ) => setActivePage ( item . id ) }
46- className = { `w-full flex items-center px-4 py-3 text-gray-300 hover:bg-gray-800 hover:text-green-400 transition-colors ${
47- activePage === item . id ? 'bg-gray-800 text-green-400' : ''
48- } `}
62+ onClick = { onLogout }
63+ className = { `w-full flex items-center px-4 py-3 text-gray-300 hover:bg-gray-800 hover:text-red-500 transition-colors` }
4964 >
50- { item . icon }
51- < span className = { `ml-4 ${ ! isOpen && 'hidden' } ` } > { item . label } </ span >
65+ < LogOut size = { 20 } />
66+ < span className = { `ml-4 ${ ! isOpen && 'hidden' } ` } > Logout </ span >
5267 </ button >
53- ) ) }
54- </ nav >
68+ </ div >
5569 </ div >
5670) ;
5771
58- export default Sidebar ;
72+ export default Sidebar ;
0 commit comments