1
- "use client" ;
2
-
3
1
import Image from "next/image" ;
4
2
import Link from "next/link" ;
5
- import { useState } from "react" ;
3
+
4
+ import CTC_Icon from "@/CTCLogo.svg" ;
6
5
7
6
const arrow_icon = "/svgs/admin/simple_arrow.svg" ;
8
7
const dashboard_icon = "/svgs/admin/dashboard_icon.svg" ;
@@ -12,14 +11,6 @@ const ticket_icon = "/svgs/admin/ticket_icon.svg";
12
11
const add_icon = "/svgs/admin/add_square.svg" ;
13
12
const reset_icon = "/svgs/admin/reset_icon.svg" ;
14
13
15
- const NAV_BAR_SECTION_STYLES =
16
- "flex flex-col items-center bg-awesomer-purple h-full text-white transition-width duration-300 md:w-80" ;
17
- const LOGO_BUTTON_STYLES =
18
- "mt-6 flex size-10 items-center justify-center md:size-14" ;
19
- const NAV_BAR_HEADER_STYLES = "my-2 text-center text-xl font-bold md:text-2xl" ;
20
- const NAV_LINK_CONTAINER_STYLES =
21
- "flex justify-between hover:bg-[#5E48D1] p-2 rounded-md mb-2" ;
22
- const NAV_LINK_ICON_STYLES = "mr-2 flex p-2 justify-center rounded-md bg-white" ;
23
14
export interface DashboardLink {
24
15
name : string ;
25
16
icon : string ;
@@ -35,28 +26,26 @@ const NavLinkContainer = ({
35
26
dashboardLink : DashboardLink ;
36
27
} ) => {
37
28
return (
38
- < Link href = { dashboardLink . route } className = { NAV_LINK_CONTAINER_STYLES } >
39
- < div className = "flex" >
40
- < div className = { NAV_LINK_ICON_STYLES } >
29
+ < Link
30
+ href = { dashboardLink . route }
31
+ className = { "mb-2 flex justify-between rounded-md p-2 hover:bg-[#5E48D1]" }
32
+ >
33
+ < div className = "flex gap-2" >
34
+ < div className = { "flex justify-center rounded-md bg-white p-2" } >
41
35
< Image
42
36
height = { 20 }
43
37
width = { 20 }
44
38
src = { dashboardLink . icon }
45
39
alt = { `${ dashboardLink . name } icon` }
46
40
/>
47
41
</ div >
48
- < p > { dashboardLink . name } </ p >
42
+ < p className = "flex items-center" > { dashboardLink . name } </ p >
49
43
</ div >
50
44
< Image height = { 10 } width = { 10 } src = { arrow_icon } alt = "Arrow icon" />
51
45
</ Link >
52
46
) ;
53
47
} ;
54
- const SideNavBar = ( ) => {
55
- const [ isCollapsed , setIsCollapsed ] = useState ( true ) ;
56
-
57
- const toggleSidebar = ( ) => {
58
- setIsCollapsed ( ! isCollapsed ) ;
59
- } ;
48
+ export default function SideNavBar ( ) {
60
49
const dashboardRoutes : DashboardRoutes [ ] = [
61
50
{
62
51
group : "ADMIN" ,
@@ -115,41 +104,32 @@ const SideNavBar = () => {
115
104
] ;
116
105
117
106
return (
118
- < div className = "relative text-sm md:text-lg" >
119
- < div
120
- className = { `${ NAV_BAR_SECTION_STYLES } ${
121
- isCollapsed
122
- ? "w-16 md:w-[80px]"
123
- : "fixed left-0 top-0 z-[1000] w-60 md:w-80"
124
- } `}
125
- >
126
- < button className = { LOGO_BUTTON_STYLES } onClick = { toggleSidebar } >
127
- < Image
128
- src = "/CTCLogo.svg"
129
- alt = "Code The Change Logo"
130
- width = { 50 }
131
- height = { 50 }
132
- />
133
- </ button >
134
- { ! isCollapsed && (
135
- < nav className = "w-full p-6" >
136
- < h1 className = { NAV_BAR_HEADER_STYLES } > HACK THE CHANGE</ h1 >
137
- < div className = "mt-2" >
138
- { dashboardRoutes . map ( ( route ) => (
139
- < div key = { route . group } >
140
- < h2 > { route . group } </ h2 >
141
- < hr className = "my-2" />
142
- { route . routes . map ( ( r , index ) => (
143
- < NavLinkContainer key = { index } dashboardLink = { r } />
144
- ) ) }
145
- </ div >
146
- ) ) }
147
- </ div >
148
- </ nav >
149
- ) }
150
- </ div >
151
- </ div >
107
+ < details
108
+ className = { `transition-width md:open:w-80" relative flex h-full w-20 cursor-pointer flex-col items-center gap-2 bg-awesomer-purple text-white duration-500 open:fixed open:top-0 open:w-60 md:w-[80px]` }
109
+ >
110
+ < summary className = "sticky top-0 list-none pt-4" >
111
+ < Image
112
+ src = { CTC_Icon }
113
+ alt = "Code The Change Logo"
114
+ className = "transition-transform hover:scale-125"
115
+ width = { 50 }
116
+ height = { 50 }
117
+ />
118
+ </ summary >
119
+ < h1 className = "line-clamp-1 text-center text-xl font-bold md:text-2xl" >
120
+ HACK THE CHANGE
121
+ </ h1 >
122
+ < ul className = "absolute inset-0 mt-28 w-full overflow-y-auto px-2" >
123
+ { dashboardRoutes . map ( ( route ) => (
124
+ < li key = { route . group } >
125
+ < h2 > { route . group } </ h2 >
126
+ < hr />
127
+ { route . routes . map ( ( r , index ) => (
128
+ < NavLinkContainer key = { index } dashboardLink = { r } />
129
+ ) ) }
130
+ </ li >
131
+ ) ) }
132
+ </ ul >
133
+ </ details >
152
134
) ;
153
- } ;
154
-
155
- export default SideNavBar ;
135
+ }
0 commit comments