11import { IconLock , IconLogout , IconUser } from "@tabler/icons-react" ;
2- import { LocalePicker , NavLink , ThemeSwitcher } from "src/components" ;
2+ import cs from "classnames" ;
3+ import { useState } from "react" ;
4+ import { LocalePicker , NavLink , SiteMenu , ThemeSwitcher } from "src/components" ;
35import { useAuthState } from "src/context" ;
46import { useUser } from "src/hooks" ;
57import { T } from "src/locale" ;
@@ -10,105 +12,110 @@ export function SiteHeader() {
1012 const { data : currentUser } = useUser ( "me" ) ;
1113 const isAdmin = currentUser ?. roles . includes ( "admin" ) ;
1214 const { logout } = useAuthState ( ) ;
15+ const [ expanded , setExpanded ] = useState ( false ) ;
1316
1417 return (
15- < header className = "navbar navbar-expand-md d-print-none" >
16- < div className = "container-xl" >
17- < button
18- className = "navbar-toggler"
19- type = "button"
20- data-bs-toggle = "collapse"
21- data-bs-target = "#navbar-menu"
22- aria-controls = "navbar-menu"
23- aria-expanded = "false"
24- aria-label = "Toggle navigation"
25- >
26- < span className = "navbar-toggler-icon" />
27- </ button >
28- < div className = "navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3" >
29- < NavLink to = "/" >
30- < div className = { styles . logo } >
31- < img
32- src = "/images/logo-no-text.svg"
33- width = { 40 }
34- height = { 40 }
35- className = "navbar-brand-image"
36- alt = "Logo"
37- />
38- </ div >
39- Nginx Proxy Manager
40- </ NavLink >
41- </ div >
42- < div className = "navbar-nav flex-row order-md-last" >
43- < div className = "d-none d-md-flex" >
44- < div className = "nav-item" >
45- < LocalePicker />
46- </ div >
47- < div className = "nav-item" >
48- < ThemeSwitcher />
49- </ div >
50- </ div >
51- < div className = "nav-item d-none d-md-flex me-3" >
52- < div className = "nav-item dropdown" >
53- < a
54- href = "/"
55- className = "nav-link d-flex lh-1 p-0 px-2"
56- data-bs-toggle = "dropdown"
57- aria-label = "Open user menu"
58- >
59- < span
60- className = "avatar avatar-sm"
61- style = { {
62- backgroundImage : `url(${ currentUser ?. avatar || "/images/default-avatar.jpg" } )` ,
63- } }
18+ < >
19+ < header className = "navbar navbar-expand-md d-print-none" >
20+ < div className = "container-xl" >
21+ < button
22+ className = { cs ( "navbar-toggler" , { collapsed : ! expanded } ) }
23+ type = "button"
24+ data-bs-toggle = "collapse"
25+ data-bs-target = "#navbar-menu"
26+ aria-controls = "navbar-menu"
27+ aria-expanded = { expanded }
28+ aria-label = "Toggle navigation"
29+ onClick = { ( ) => setExpanded ( ! expanded ) }
30+ >
31+ < span className = "navbar-toggler-icon" />
32+ </ button >
33+ < div className = "navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3" >
34+ < NavLink to = "/" >
35+ < div className = { styles . logo } >
36+ < img
37+ src = "/images/logo-no-text.svg"
38+ width = { 40 }
39+ height = { 40 }
40+ className = "navbar-brand-image"
41+ alt = "Logo"
6442 />
65- < div className = "d-none d-xl-block ps-2" >
66- < div > { currentUser ?. nickname } </ div >
67- < div className = "mt-1 small text-secondary" >
68- < T id = { isAdmin ? "role.admin" : "role.standard-user" } />
69- </ div >
70- </ div >
71- </ a >
72- < div className = "dropdown-menu dropdown-menu-end dropdown-menu-arrow" >
73- < a
74- href = "?"
75- className = "dropdown-item"
76- onClick = { ( e ) => {
77- e . preventDefault ( ) ;
78- showUserModal ( "me" ) ;
79- } }
80- >
81- < IconUser width = { 18 } />
82- < T id = "user.edit-profile" />
83- </ a >
84- < a
85- href = "?"
86- className = "dropdown-item"
87- onClick = { ( e ) => {
88- e . preventDefault ( ) ;
89- showChangePasswordModal ( "me" ) ;
90- } }
91- >
92- < IconLock width = { 18 } />
93- < T id = "user.change-password" />
94- </ a >
95- < div className = "dropdown-divider" />
43+ </ div >
44+ Nginx Proxy Manager
45+ </ NavLink >
46+ </ div >
47+ < div className = "navbar-nav flex-row order-md-last" >
48+ < div className = "d-none d-md-flex" >
49+ < div className = "nav-item" >
50+ < LocalePicker />
51+ </ div >
52+ < div className = "nav-item" >
53+ < ThemeSwitcher />
54+ </ div >
55+ </ div >
56+ < div className = "nav-item d-none d-md-flex me-3" >
57+ < div className = "nav-item dropdown" >
9658 < a
97- href = "?"
98- className = "dropdown-item"
99- onClick = { ( e ) => {
100- e . preventDefault ( ) ;
101- logout ( ) ;
102- } }
59+ href = "/"
60+ className = "nav-link d-flex lh-1 p-0 px-2"
61+ data-bs-toggle = "dropdown"
62+ aria-label = "Open user menu"
10363 >
104- < IconLogout width = { 18 } />
105- < T id = "user.logout" />
64+ < span
65+ className = "avatar avatar-sm"
66+ style = { {
67+ backgroundImage : `url(${ currentUser ?. avatar || "/images/default-avatar.jpg" } )` ,
68+ } }
69+ />
70+ < div className = "d-none d-xl-block ps-2" >
71+ < div > { currentUser ?. nickname } </ div >
72+ < div className = "mt-1 small text-secondary" >
73+ < T id = { isAdmin ? "role.admin" : "role.standard-user" } />
74+ </ div >
75+ </ div >
10676 </ a >
77+ < div className = "dropdown-menu dropdown-menu-end dropdown-menu-arrow" >
78+ < a
79+ href = "?"
80+ className = "dropdown-item"
81+ onClick = { ( e ) => {
82+ e . preventDefault ( ) ;
83+ showUserModal ( "me" ) ;
84+ } }
85+ >
86+ < IconUser width = { 18 } />
87+ < T id = "user.edit-profile" />
88+ </ a >
89+ < a
90+ href = "?"
91+ className = "dropdown-item"
92+ onClick = { ( e ) => {
93+ e . preventDefault ( ) ;
94+ showChangePasswordModal ( "me" ) ;
95+ } }
96+ >
97+ < IconLock width = { 18 } />
98+ < T id = "user.change-password" />
99+ </ a >
100+ < div className = "dropdown-divider" />
101+ < a
102+ href = "?"
103+ className = "dropdown-item"
104+ onClick = { ( e ) => {
105+ e . preventDefault ( ) ;
106+ logout ( ) ;
107+ } }
108+ >
109+ < IconLogout width = { 18 } />
110+ < T id = "user.logout" />
111+ </ a >
112+ </ div >
107113 </ div >
108114 </ div >
109115 </ div >
110116 </ div >
111- </ div >
112- </ header >
117+ </ header >
118+ < SiteMenu mobileExpanded = { expanded } setMobileExpanded = { setExpanded } />
119+ </ >
113120 ) ;
114121}
0 commit comments