1- import React from 'react'
1+ import React , { useEffect , useState } from 'react'
22import { Link } from '@tanstack/react-router'
3- import { MessageSquareText , ChevronLeft , User , Settings2 } from 'lucide-react'
3+ import { ChevronLeft , User , Settings2 , Menu } from 'lucide-react'
44import {
55 DropdownMenu ,
66 DropdownMenuTrigger ,
@@ -17,39 +17,40 @@ import { useRouteMatch } from '../hooks/useRouteMatch'
1717const Header : React . FC = ( ) => {
1818 const { selectedModel, setSelectedModel } = useModel ( )
1919 const isSettingsPage = useRouteMatch ( '/settings' )
20+ const [ isDark , setIsDark ] = useState ( false ) ;
2021
21- return (
22- < header className = "sticky top-0 z-50 bg-white dark:bg-gray-950 border-b border-gray-200 dark:border-gray-800 px-4 py-3 flex justify-between items-center" >
23- < div className = "flex items-center gap-2" >
24- < MessageSquareText className = "h-6 w-6 text-indigo-600 dark:text-indigo-400" />
25- < h1 className = "text-xl font-semibold" > PomChat</ h1 >
22+ useEffect ( ( ) => {
23+ setIsDark ( document . documentElement . classList . contains ( "dark" ) ) ;
24+ // Optionally, subscribe to theme changes
25+ const observer = new MutationObserver ( ( ) => {
26+ setIsDark ( document . documentElement . classList . contains ( "dark" ) ) ;
27+ } ) ;
28+ observer . observe ( document . documentElement , { attributes : true , attributeFilter : [ 'class' ] } ) ;
29+ return ( ) => observer . disconnect ( ) ;
30+ } , [ ] ) ;
2631
27- < ModelSelect value = { selectedModel } onValueChange = { setSelectedModel } />
28- </ div >
32+
33+ return (
34+ < header className = "sticky top-0 z-50 bg-primary dark:bg-background border-b px-4 py-3 flex justify-between items-center" >
2935 < div className = "flex items-center gap-2" >
30- { isSettingsPage && (
31- < Link
32- to = "/"
33- className = "flex items-center gap-2 text-sm text-gray-900 dark:text-gray-100 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors"
34- >
35- < ChevronLeft className = "h-4 w-4" />
36- Back to Chat
37- </ Link >
38- ) }
39- < ThemeToggle />
4036 < DropdownMenu >
4137 < DropdownMenuTrigger asChild >
42- < Button
43- variant = "ghost"
44- size = "sm"
45- className = "relative h-10 w-10 rounded-full"
46- >
47- < div className = "flex h-full w-full items-center justify-center rounded-full bg-indigo-100 dark:bg-indigo-900" >
48- < User className = "h-5 w-5 text-indigo-600 dark:text-indigo-400" />
49- </ div >
38+ < Button variant = "secondary" className = 'size-10 flex md:hidden justify-center items-center rounded-full' >
39+ < Menu className = 'size-4' />
5040 </ Button >
5141 </ DropdownMenuTrigger >
52- < DropdownMenuContent align = "end" className = "w-56" >
42+ < DropdownMenuContent className = 'mx-4 my-2' >
43+ { isSettingsPage && (
44+ < >
45+ < DropdownMenuItem asChild >
46+ < Link to = "/" className = 'flex gap-2 items-center justify-between' >
47+ < ChevronLeft className = "size-4" />
48+ Back to Chat
49+ </ Link >
50+ </ DropdownMenuItem >
51+ < DropdownMenuSeparator />
52+ </ >
53+ ) }
5354 < div className = "px-2 py-1.5" >
5455 < p className = "text-sm font-medium" > User Account</ p >
5556 < p className = "text-xs text-gray-500 dark:text-gray-400" >
@@ -74,6 +75,70 @@ const Header: React.FC = () => {
7475 </ DropdownMenuItem >
7576 </ DropdownMenuContent >
7677 </ DropdownMenu >
78+ < a href = "https://pomerium.com" target = '_blank' >
79+ < img
80+ src = { isDark ? "/pomerium-icon.svg" : "/pomerium-icon.png" }
81+ alt = "Pomerium Logo"
82+ className = 'w-8 hover:-translate-y-0.5 transition-all'
83+ />
84+ </ a >
85+ < Link to = "/" >
86+ < h1 className = "text-xl font-bold text-white" > PomChat</ h1 >
87+ </ Link >
88+ < ModelSelect value = { selectedModel } onValueChange = { setSelectedModel } />
89+ </ div >
90+
91+
92+
93+
94+ < div className = "flex items-center gap-2" >
95+ { isSettingsPage && (
96+ < Link
97+ to = "/"
98+ className = "hidden md:flex items-center gap-2 text-sm text-primary-foreground hover:bg-secondary hover:text-secondary-foreground rounded-lg px-2 py-1 transition-colors"
99+ >
100+ < ChevronLeft className = "h-4 w-4" />
101+ Back to Chat
102+ </ Link >
103+ ) }
104+ < ThemeToggle />
105+ < span className = 'hidden md:inline-block' >
106+ < DropdownMenu >
107+ < DropdownMenuTrigger asChild >
108+ < Button
109+ variant = "secondary"
110+ size = "sm"
111+ className = "size-10 flex items-center justify-center rounded-full"
112+ >
113+ < User className = "h-5 w-5 text-secondary-foreground" />
114+ </ Button >
115+ </ DropdownMenuTrigger >
116+ < DropdownMenuContent align = "end" className = "w-56" >
117+ < div className = "px-2 py-1.5" >
118+ < p className = "text-sm font-medium" > User Account</ p >
119+ < p className = "text-xs text-gray-500 dark:text-gray-400" >
120+ user@example.com
121+ </ p >
122+ </ div >
123+ < DropdownMenuSeparator />
124+ < DropdownMenuItem asChild >
125+ < Link to = "/settings" className = "w-full flex items-center" >
126+ < Settings2 className = "mr-2 h-4 w-4" />
127+ < span > Settings</ span >
128+ </ Link >
129+ </ DropdownMenuItem >
130+ < DropdownMenuSeparator />
131+ < DropdownMenuItem asChild >
132+ < a
133+ href = "/.pomerium/sign_out"
134+ className = "w-full flex items-center text-red-600 dark:text-red-400"
135+ >
136+ < span > Sign out</ span >
137+ </ a >
138+ </ DropdownMenuItem >
139+ </ DropdownMenuContent >
140+ </ DropdownMenu >
141+ </ span >
77142 </ div >
78143 </ header >
79144 )
0 commit comments