1
1
import { Dialog , Transition } from '@headlessui/react' ;
2
2
import { LogoutIcon , XIcon } from '@heroicons/react/outline' ;
3
+ import classnames from 'classnames' ;
3
4
import { signOut } from 'next-auth/client' ;
4
5
import Image from 'next/image' ;
5
6
import React , { Fragment , useCallback } from 'react' ;
@@ -14,7 +15,6 @@ import {
14
15
ADMIN_USERS ,
15
16
filterRoutesForRole ,
16
17
} from 'src/routes' ;
17
- import { classNames } from 'src/utils/ui' ;
18
18
19
19
import type { Session } from 'src/components/Auth' ;
20
20
@@ -39,7 +39,7 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
39
39
< Transition . Root as = { Fragment } show = { open } >
40
40
< Dialog
41
41
as = "div"
42
- className = "fixed inset-0 flex z-40 lg:hidden"
42
+ className = "fixed inset-0 z-40 flex lg:hidden"
43
43
onClose = { handleState }
44
44
open = { open }
45
45
static
@@ -64,7 +64,7 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
64
64
leaveFrom = "translate-x-0"
65
65
leaveTo = "-translate-x-full"
66
66
>
67
- < div className = "relative flex-1 flex flex -col max-w-xs w-full pt-5 pb-4 bg-white" >
67
+ < div className = "relative flex flex-col flex-1 w-full max-w-xs pt-5 pb-4 bg-white" >
68
68
< Transition . Child
69
69
as = { Fragment }
70
70
enter = "ease-in-out duration-300"
@@ -74,50 +74,54 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
74
74
leaveFrom = "opacity-100"
75
75
leaveTo = "opacity-0"
76
76
>
77
- < div className = "absolute top-0 right-0 - mr-12 pt-2 " >
77
+ < div className = "absolute top-0 right-0 pt-2 - mr-12" >
78
78
< button
79
- className = "ml-1 flex items-center justify-center h -10 w -10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
79
+ className = "flex items-center justify-center w -10 h -10 ml-1 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
80
80
onClick = { ( ) => handleState ( false ) }
81
81
type = "button"
82
82
>
83
83
< span className = "sr-only" > Close sidebar</ span >
84
- < XIcon aria-hidden = "true" className = "h -6 w -6 text-white" />
84
+ < XIcon aria-hidden = "true" className = "w -6 h -6 text-white" />
85
85
</ button >
86
86
</ div >
87
87
</ Transition . Child >
88
- < div className = "flex-shrink-0 flex items-center px-4" >
88
+ < div className = "flex items-center flex-shrink-0 px-4" >
89
89
< Image
90
90
alt = "Workflow"
91
- className = "h-8 w-auto"
91
+ className = "w-auto h-8 "
92
92
height = { 50 }
93
93
src = "https://tailwindui.com/img/logos/workflow-logo-purple-500-mark-gray-700-text.svg"
94
94
width = { 200 }
95
95
/>
96
96
</ div >
97
- < div className = "mt-5 flex-1 h-0 overflow-y-auto" >
97
+ < div className = "flex-1 h-0 mt-5 overflow-y-auto" >
98
98
< nav className = "px-2" >
99
99
< div className = "space-y-1" >
100
100
{ navigation . filter ( filterRoutes ) . map ( ( item ) => (
101
101
< ActiveLink key = { item . path } href = { item . path } nested >
102
102
{ ( { isActive } ) => (
103
103
< a
104
104
aria-current = { isActive ? 'page' : undefined }
105
- className = { classNames (
106
- isActive
107
- ? 'bg-gray-100 text-gray-900'
108
- : // eslint-disable-next-line max-len
109
- 'text-gray-600 hover:text-gray-900 hover:bg-gray-50' ,
105
+ className = { classnames (
110
106
// eslint-disable-next-line max-len
111
- 'group flex items-center px-2 py-2 text-base leading-5 font-medium rounded-md'
107
+ 'group flex items-center px-2 py-2 text-base leading-5 font-medium rounded-md' ,
108
+ {
109
+ 'bg-gray-100 text-gray-900' : isActive ,
110
+ // eslint-disable-next-line max-len
111
+ 'text-gray-600 hover:text-gray-900 hover:bg-gray-50' :
112
+ ! isActive ,
113
+ }
112
114
) }
113
115
>
114
116
< item . icon
115
117
aria-hidden = "true"
116
- className = { classNames (
117
- isActive
118
- ? 'text-gray-500'
119
- : 'text-gray-400 group-hover:text-gray-500' ,
120
- 'mr-3 flex-shrink-0 h-6 w-6'
118
+ className = { classnames (
119
+ 'mr-3 flex-shrink-0 h-6 w-6' ,
120
+ {
121
+ 'text-gray-400 group-hover:text-gray-500' :
122
+ ! isActive ,
123
+ 'text-gray-500' : isActive ,
124
+ }
121
125
) }
122
126
/>
123
127
{ item . name }
@@ -137,42 +141,43 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
137
141
</ Transition . Root >
138
142
{ /* Static sidebar for desktop */ }
139
143
< div className = "hidden lg:flex lg:flex-shrink-0" >
140
- < div className = "flex flex-col w-64 border-r border-gray-200 pt-5 pb-4 bg-gray-100" >
144
+ < div className = "flex flex-col w-64 pt-5 pb-4 bg-gray-100 border-r border-gray-200 " >
141
145
< div className = "flex items-center flex-shrink-0 px-6" >
142
146
< Image
143
147
alt = "Workflow"
144
- className = "h-8 w-auto"
148
+ className = "w-auto h-8 "
145
149
height = { 50 }
146
150
src = "https://tailwindui.com/img/logos/workflow-logo-purple-500-mark-gray-700-text.svg"
147
151
width = { 200 }
148
152
/>
149
153
</ div >
150
- < div className = "h-0 flex-1 flex flex-col overflow-y-auto" >
154
+ < div className = "flex flex-col flex-1 h-0 overflow-y-auto" >
151
155
{ /* Navigation */ }
152
- < nav className = "flex-1 px-3 divide-y mt-6" >
156
+ < nav className = "flex-1 px-3 mt-6 divide-y " >
153
157
< div className = "space-y-1" >
154
158
{ navigation . filter ( filterRoutes ) . map ( ( item ) => (
155
159
< ActiveLink key = { item . path } href = { item . path } nested >
156
160
{ ( { isActive } ) => (
157
161
< a
158
162
aria-current = { isActive ? 'page' : undefined }
159
- className = { classNames (
160
- isActive
161
- ? 'bg-gray-200 text-gray-900'
162
- : // eslint-disable-next-line max-len
163
- 'text-gray-700 hover:text-gray-900 hover:bg-gray-50' ,
163
+ className = { classnames (
164
164
// eslint-disable-next-line max-len
165
- 'group flex items-center px-2 py-2 text-sm font-medium rounded-md'
165
+ 'group flex items-center px-2 py-2 text-sm font-medium rounded-md' ,
166
+ {
167
+ 'bg-gray-200 text-gray-900' : isActive ,
168
+ // eslint-disable-next-line max-len
169
+ 'text-gray-700 hover:text-gray-900 hover:bg-gray-50' :
170
+ ! isActive ,
171
+ }
166
172
) }
167
173
>
168
174
< item . icon
169
175
aria-hidden = "true"
170
- className = { classNames (
171
- isActive
172
- ? 'text-gray-500'
173
- : 'text-gray-400 group-hover:text-gray-500' ,
174
- 'mr-3 flex-shrink-0 h-6 w-6'
175
- ) }
176
+ className = { classnames ( 'mr-3 flex-shrink-0 h-6 w-6' , {
177
+ 'text-gray-400 group-hover:text-gray-500' :
178
+ ! isActive ,
179
+ 'text-gray-500' : isActive ,
180
+ } ) }
176
181
/>
177
182
{ item . name }
178
183
</ a >
@@ -181,8 +186,8 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
181
186
) ) }
182
187
</ div >
183
188
</ nav >
184
- < div className = "group w-full bg-gray-100 rounded-md px-3.5 py-2 text-sm text-left font-medium text-gray-700" >
185
- < span className = "flex w-full justify-between items-center " >
189
+ < div className = "w-full py-2 text-sm font-medium text-left text- gray-700 bg-gray-100 group rounded-md px-3.5 " >
190
+ < span className = "flex items-center justify-between w-full " >
186
191
{ session ?. user && (
187
192
< UserAvatar
188
193
image = { session . user . image }
@@ -198,35 +203,30 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
198
203
{ ( { isActive } ) => (
199
204
< a
200
205
aria-current = { isActive ? 'page' : undefined }
201
- className = { classNames (
202
- isActive
203
- ? 'bg-gray-200 text-gray-900'
204
- : // eslint-disable-next-line max-len
205
- 'text-gray-700 hover:text-gray-900 hover:bg-gray-50' ,
206
+ className = { classnames (
206
207
// eslint-disable-next-line max-len
207
- 'group flex items-center px-2 py-2 text-sm font-medium rounded-md'
208
+ 'group flex items-center px-2 py-2 text-sm font-medium rounded-md' ,
209
+ {
210
+ 'bg-gray-200 text-gray-900' : isActive ,
211
+ 'text-gray-700 hover:text-gray-900 hover:bg-gray-50' :
212
+ ! isActive ,
213
+ }
208
214
) }
209
215
>
210
216
< item . icon
211
217
aria-hidden = "true"
212
- className = { classNames (
213
- isActive
214
- ? 'text-gray-500'
215
- : 'text-gray-400 group-hover:text-gray-500' ,
216
- 'mr-3 flex-shrink-0 h-6 w-6'
217
- ) }
218
+ className = { classnames ( 'mr-3 flex-shrink-0 h-6 w-6' , {
219
+ 'text-gray-400 group-hover:text-gray-500' : ! isActive ,
220
+ 'text-gray-500' : isActive ,
221
+ } ) }
218
222
/>
219
223
{ item . name }
220
224
</ a >
221
225
) }
222
226
</ ActiveLink >
223
227
) ) }
224
228
< button
225
- className = { classNames (
226
- 'text-gray-700 hover:text-gray-900 hover:bg-gray-50 w-full' ,
227
- // eslint-disable-next-line max-len
228
- 'group flex items-center px-2 py-2 text-sm font-medium rounded-md'
229
- ) }
229
+ className = "flex items-center w-full px-2 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 rounded-md"
230
230
onClick = { ( ) =>
231
231
signOut ( {
232
232
callbackUrl :
@@ -237,10 +237,7 @@ const Sidebar: React.FC<SidebarProps> = ({ handleState, open, session }) => {
237
237
>
238
238
< LogoutIcon
239
239
aria-hidden = "true"
240
- className = { classNames (
241
- 'text-gray-400 group-hover:text-gray-500' ,
242
- 'mr-3 flex-shrink-0 h-6 w-6'
243
- ) }
240
+ className = "flex-shrink-0 w-6 h-6 mr-3 text-gray-400 group-hover:text-gray-500"
244
241
/>
245
242
Logout
246
243
</ button >
0 commit comments