11import AnarchyIcon from "~icons/game-icons/anarchy" ;
22import FistIcon from "~icons/game-icons/fist" ;
33import HammerSickleIcon from "~icons/game-icons/hammer-sickle" ;
4+ import LogoutIcon from "~icons/hugeicons/logout-02" ;
45import MenuIcon from "~icons/line-md/close-to-menu-alt-transition" ;
56import GitHubIcon from "~icons/line-md/github-loop" ;
67import XIcon from "~icons/line-md/menu-to-close-transition" ;
@@ -26,6 +27,7 @@ import { A, RouteSectionProps, useLocation } from "@solidjs/router";
2627import { Observer } from "tailwindcss-intersect" ;
2728
2829import { pageList } from "../.." ;
30+ import { isAuthenticated , logoutUser } from "../../service/api/user" ;
2931
3032const getBreadcrumbs = ( ) => {
3133 const location = useLocation ( ) ;
@@ -82,66 +84,107 @@ const NavigationLinks = (props: {
8284 const location = useLocation ( ) ;
8385
8486 return (
85- < For each = { pageList } >
86- { ( page ) => {
87- switch ( props . kind ) {
88- case "desktop" :
89- return (
90- < li >
87+ < >
88+ < For each = { pageList } >
89+ { ( page ) => {
90+ switch ( props . kind ) {
91+ case "desktop" :
92+ return (
93+ < li >
94+ < A
95+ href = { page . path }
96+ activeClass = "bg-base-200 font-medium"
97+ class = {
98+ "hover:text-primary group text-xs-adjust rounded-lg py-1 transition-all duration-200 hover:scale-105 sm:py-2 sm:text-sm md:text-base"
99+ }
100+ end = { true }
101+ onClick = { props . onClick }
102+ >
103+ { page . icon && (
104+ < page . icon
105+ class = {
106+ "mr-1 inline h-4 w-4 transition-transform duration-200 group-hover:-rotate-12 sm:h-5 sm:w-5"
107+ }
108+ />
109+ ) }
110+ { page . title }
111+ </ A >
112+ </ li >
113+ ) ;
114+ case "mobile" :
115+ return (
91116 < A
92117 href = { page . path }
93- activeClass = "bg-base-200 font-medium"
94- class = {
95- "hover:text-primary group text-xs-adjust rounded-lg py-1 transition-all duration-200 hover:scale-105 sm:py-2 sm:text-sm md:text-base "
96- }
97- end = { true }
118+ class = { `btn btn-ghost btn-xs-adjust sm:btn-sm my-1 justify-start ${
119+ location . pathname === page . path ?
120+ "bg-base-300 font-medium "
121+ : ""
122+ } ` }
98123 onClick = { props . onClick }
99124 >
100125 { page . icon && (
101- < page . icon
102- class = {
103- "mr-1 inline h-4 w-4 transition-transform duration-200 group-hover:-rotate-12 sm:h-5 sm:w-5"
104- }
105- />
126+ < page . icon class = "mr-1 inline h-4 w-4 sm:h-5 sm:w-5" />
127+ ) }
128+ < span class = "truncate" > { page . title } </ span >
129+ </ A >
130+ ) ;
131+ case "footer" :
132+ return (
133+ < A
134+ href = { page . path }
135+ class = "link link-hover text-xs-adjust sm:text-sm"
136+ >
137+ { page . icon && (
138+ < page . icon class = "mr-1 inline h-4 w-4 sm:h-5 sm:w-5" />
106139 ) }
107140 { page . title }
108141 </ A >
109- </ li >
110- ) ;
111- case "mobile" :
112- return (
113- < A
114- href = { page . path }
115- class = { `btn btn-ghost btn-xs-adjust sm:btn-sm my-1 justify-start ${
116- location . pathname === page . path ?
117- "bg-base-300 font-medium"
118- : ""
119- } `}
120- onClick = { props . onClick }
121- >
122- { page . icon && (
123- < page . icon class = "mr-1 inline h-4 w-4 sm:h-5 sm:w-5" />
124- ) }
125- < span class = "truncate" > { page . title } </ span >
126- </ A >
127- ) ;
128- case "footer" :
129- return (
130- < A
131- href = { page . path }
132- class = "link link-hover text-xs-adjust sm:text-sm"
133- >
134- { page . icon && (
135- < page . icon class = "mr-1 inline h-4 w-4 sm:h-5 sm:w-5" />
136- ) }
137- { page . title }
138- </ A >
139- ) ;
140- default :
141- const _ : never = props . kind ;
142- }
143- } }
144- </ For >
142+ ) ;
143+ default :
144+ const _ : never = props . kind ;
145+ }
146+ } }
147+ </ For >
148+ { isAuthenticated ( ) ?
149+ props . kind === "desktop" ?
150+ < li >
151+ < A
152+ href = "/"
153+ activeClass = "bg-base-200 font-medium"
154+ class = {
155+ "hover:text-primary group text-xs-adjust rounded-lg py-1 transition-all duration-200 hover:scale-105 sm:py-2 sm:text-sm md:text-base"
156+ }
157+ end = { true }
158+ onClick = { logoutUser }
159+ >
160+ < LogoutIcon
161+ class = {
162+ "mr-1 inline h-4 w-4 transition-transform duration-200 group-hover:-rotate-12 sm:h-5 sm:w-5"
163+ }
164+ />
165+ Logout
166+ </ A >
167+ </ li >
168+ : props . kind === "mobile" ?
169+ < A
170+ href = "/"
171+ class = { "btn btn-ghost btn-xs-adjust sm:btn-sm my-1 justify-start" }
172+ onClick = { props . onClick }
173+ >
174+ < LogoutIcon class = "mr-1 inline h-4 w-4 sm:h-5 sm:w-5" />
175+ < span class = "truncate" > Logout</ span >
176+ </ A >
177+ : ( props . kind as string ) === "footer" ?
178+ < A
179+ href = "/"
180+ class = "link link-hover text-xs-adjust sm:text-sm"
181+ >
182+ < LogoutIcon class = "mr-1 inline h-4 w-4 sm:h-5 sm:w-5" />
183+ Logout
184+ </ A >
185+ : < > </ >
186+ : < > </ > }
187+ </ >
145188 ) ;
146189} ;
147190
0 commit comments