@@ -8,11 +8,19 @@ import {
8
8
SignInButton ,
9
9
SignUpButton ,
10
10
useUser ,
11
+ useClerk ,
11
12
} from '@clerk/clerk-react' ;
12
13
import React from 'react' ;
14
+ import { IconMoon , IconSun } from '@tabler/icons-react' ;
13
15
14
- const Header : React . FC = ( ) => {
16
+ interface HeaderProps {
17
+ isDark : boolean ;
18
+ toggleTheme : ( ) => void ;
19
+ }
20
+
21
+ const Header : React . FC < HeaderProps > = ( { isDark, toggleTheme } ) => {
15
22
const { user } = useUser ( ) ;
23
+ const { signOut } = useClerk ( ) ;
16
24
17
25
const getWhimsicalGreeting = ( isMobile = false ) => {
18
26
const hour = new Date ( ) . getHours ( ) ;
@@ -92,77 +100,68 @@ const Header: React.FC = () => {
92
100
'Winding down with monitoring' ,
93
101
'Evening cluster zen' ,
94
102
'Time to relax and monitor' ,
95
- 'Evening brew master ' ,
103
+ 'Smooth sailing this evening ' ,
96
104
] ,
97
105
night : [
98
- 'Late evening session ' ,
99
- 'Night time monitoring' ,
100
- 'Almost bedtime ' ,
106
+ 'Night shift activated ' ,
107
+ 'Late night monitoring' ,
108
+ 'Almost time for bed ' ,
101
109
'Final cluster check' ,
102
- 'Ready to call it a day ' ,
110
+ 'Keeping watch tonight ' ,
103
111
] ,
104
112
} ;
105
113
106
- // Weekend variations (shorter for mobile)
107
- const weekendGreetings = {
108
- mobile : {
109
- lateNight : [
110
- 'Weekend night owl' ,
111
- 'Saturday night coding' ,
112
- 'Weekend warrior' ,
113
- ] ,
114
- morning : [ 'Weekend vibes' , 'Lazy morning' , 'Weekend coffee time' ] ,
115
- afternoon : [ 'Weekend bliss' , 'Chill monitoring' , 'Weekend check' ] ,
116
- evening : [ 'Weekend wind-down' , 'Sunday prep' , 'Weekend wrap-up' ] ,
117
- } ,
118
- desktop : {
119
- lateNight : [
120
- 'Weekend night owl' ,
121
- 'Saturday night coding session' ,
122
- 'Weekend warrior mode' ,
123
- ] ,
124
- morning : [
125
- 'Weekend vibes' ,
126
- 'Lazy morning monitoring' ,
127
- 'Weekend coffee time' ,
128
- ] ,
129
- afternoon : [
130
- 'Weekend afternoon bliss' ,
131
- 'Relaxed weekend monitoring' ,
132
- 'Weekend maintenance mode' ,
133
- ] ,
134
- evening : [
135
- 'Weekend wind-down' ,
136
- 'Sunday evening prep' ,
137
- 'Weekend cluster check' ,
138
- ] ,
139
- } ,
140
- } ;
141
-
142
114
const greetings = isMobile ? mobileGreetings : desktopGreetings ;
143
- const weekendVariations = isMobile
144
- ? weekendGreetings . mobile
145
- : weekendGreetings . desktop ;
146
115
147
- let timeBasedGreetings ;
116
+ // Weekend variations
117
+ const weekendVariations = {
118
+ morning : isWeekend
119
+ ? isMobile
120
+ ? [ 'Weekend vibes' , 'Lazy Saturday' , 'Sunday funday' ]
121
+ : [
122
+ 'Weekend monitoring mode' ,
123
+ 'Lazy Saturday cluster check' ,
124
+ 'Sunday funday monitoring' ,
125
+ ]
126
+ : [ ] ,
127
+ afternoon : isWeekend
128
+ ? isMobile
129
+ ? [ 'Weekend mode' , 'Chill Saturday' , 'Sunday relaxation' ]
130
+ : [
131
+ 'Weekend afternoon vibes' ,
132
+ 'Saturday chill monitoring' ,
133
+ 'Sunday relaxation mode' ,
134
+ ]
135
+ : [ ] ,
136
+ evening : isWeekend
137
+ ? isMobile
138
+ ? [ 'Weekend evening' , 'Saturday night' , 'Sunday night' ]
139
+ : [
140
+ 'Saturday night monitoring' ,
141
+ 'Sunday evening wind down' ,
142
+ 'Weekend evening cluster zen' ,
143
+ ]
144
+ : [ ] ,
145
+ } ;
146
+
147
+ let timeBasedGreetings : string [ ] = [ ] ;
148
148
149
- // Determine time period and get appropriate greetings
150
149
if ( hour >= 0 && hour < 5 ) {
151
- timeBasedGreetings = isWeekend
152
- ? [ ...greetings . lateNight , ...weekendVariations . lateNight ]
153
- : greetings . lateNight ;
150
+ timeBasedGreetings = greetings . lateNight ;
154
151
} else if ( hour >= 5 && hour < 9 ) {
155
- timeBasedGreetings = greetings . earlyMorning ;
152
+ timeBasedGreetings = [
153
+ ...greetings . earlyMorning ,
154
+ ...weekendVariations . morning ,
155
+ ] ;
156
156
} else if ( hour >= 9 && hour < 12 ) {
157
- timeBasedGreetings = isWeekend
158
- ? [ ...greetings . morning , ...weekendVariations . morning ]
159
- : greetings . morning ;
157
+ timeBasedGreetings = [ ...greetings . morning , ...weekendVariations . morning ] ;
160
158
} else if ( hour >= 12 && hour < 14 ) {
161
159
timeBasedGreetings = greetings . lunch ;
162
160
} else if ( hour >= 14 && hour < 18 ) {
163
- timeBasedGreetings = isWeekend
164
- ? [ ...greetings . afternoon , ...weekendVariations . afternoon ]
165
- : greetings . afternoon ;
161
+ timeBasedGreetings = [
162
+ ...greetings . afternoon ,
163
+ ...weekendVariations . afternoon ,
164
+ ] ;
166
165
} else if ( hour >= 18 && hour < 22 ) {
167
166
timeBasedGreetings = isWeekend
168
167
? [ ...greetings . evening , ...weekendVariations . evening ]
@@ -208,48 +207,68 @@ const Header: React.FC = () => {
208
207
>
209
208
< div className = "main-content-wrapper" >
210
209
< div className = "flex items-center justify-between py-1" >
211
- { ' ' }
212
- { /* Reduced from py-3 to py-1 */ }
213
- < SignedOut >
214
- < div
215
- className = "flex gap-4 text-base font-bold sm:text-lg"
216
- style = { {
217
- color : 'var(--primary)' ,
218
- } }
219
- >
220
- < SignInButton
221
- mode = "modal" // opens in popup
222
- // afterSignInUrl="/" // redirect
223
- // redirectUrl="/" // Optional redirect
224
- /> { ' ' }
225
- /
226
- < SignUpButton
227
- mode = "modal" // opens in popup
228
- // afterSignUpUrl="/" // redirect
229
- // redirectUrl="/" // Optional redirect
210
+ { /* Left side content */ }
211
+ < div className = "flex-1" >
212
+ < SignedOut >
213
+ < div
214
+ className = "flex gap-4 text-base font-bold sm:text-lg"
215
+ style = { {
216
+ color : 'var(--primary)' ,
217
+ } }
218
+ >
219
+ < SignInButton mode = "modal" /> /
220
+ < SignUpButton mode = "modal" />
221
+ </ div >
222
+ </ SignedOut >
223
+ < SignedIn >
224
+ { /* Enhanced Responsive Greeting */ }
225
+ < div
226
+ className = "text-lg font-semibold italic sm:text-xl md:text-xl lg:text-2xl xl:text-2xl"
227
+ style = { {
228
+ color : 'var(--primary)' ,
229
+ } }
230
+ >
231
+ { /* Mobile version - shorter greeting */ }
232
+ < span className = "block sm:hidden" >
233
+ { getWhimsicalGreeting ( true ) } , { getDisplayName ( ) } !
234
+ </ span >
235
+ { /* Desktop version - full greeting */ }
236
+ < span className = "hidden sm:block" >
237
+ { getWhimsicalGreeting ( false ) } , { getDisplayName ( ) } !
238
+ </ span >
239
+ </ div >
240
+ </ SignedIn >
241
+ </ div >
242
+
243
+ { /* Right side controls - Always present */ }
244
+ < div className = "flex flex-shrink-0 items-center gap-6" >
245
+ { /* SIGN OUT BUTTON - Only visible when signed in */ }
246
+ < SignedIn >
247
+ < button
248
+ onClick = { ( ) =>
249
+ signOut ( ( ) => {
250
+ window . location . href = '/' ;
251
+ } )
252
+ }
253
+ className = "duration-800 text-muted-foreground flex justify-center text-sm font-semibold transition-colors hover:text-red-500/70 sm:text-lg"
254
+ title = "Sign Out"
255
+ >
256
+ logout
257
+ </ button >
258
+ </ SignedIn >
259
+
260
+ { /* DARK MODE TOGGLE - Always visible */ }
261
+ < label className = "swap swap-rotate cursor-pointer hover:[&_.swap-off]:text-amber-500 hover:[&_.swap-on]:text-yellow-200/90" >
262
+ < input
263
+ type = "checkbox"
264
+ checked = { isDark }
265
+ onChange = { toggleTheme }
266
+ className = "sr-only"
230
267
/>
231
- </ div >
232
- { /* Empty div to maintain layout */ }
233
- < div > </ div >
234
- </ SignedOut >
235
- < SignedIn >
236
- { /* Left side - Enhanced Responsive Greeting */ }
237
- < div
238
- className = "text-lg font-semibold italic sm:text-xl md:text-xl lg:text-2xl xl:text-2xl" // Reduced max sizes
239
- style = { {
240
- color : 'var(--primary)' ,
241
- } }
242
- >
243
- { /* Mobile version - shorter greeting */ }
244
- < span className = "block sm:hidden" >
245
- { getWhimsicalGreeting ( true ) } , { getDisplayName ( ) } !
246
- </ span >
247
- { /* Desktop version - full greeting */ }
248
- < span className = "hidden sm:block" >
249
- { getWhimsicalGreeting ( false ) } , { getDisplayName ( ) } !
250
- </ span >
251
- </ div >
252
- </ SignedIn >
268
+ < IconMoon className = "duration-800 text-muted-foreground swap-on transition-all" />
269
+ < IconSun className = "duration-800 text-muted-foreground swap-off transition-all" />
270
+ </ label >
271
+ </ div >
253
272
</ div >
254
273
</ div >
255
274
</ header >
0 commit comments