11import React , { useState } from 'react' ;
22import { useAuth } from '../../hooks/useAuth' ;
3+ import { useTheme } from '../../hooks/useTheme' ;
34
45export const Header : React . FC = ( ) => {
56 const { user, logout } = useAuth ( ) ;
7+ const { theme, setTheme } = useTheme ( ) ;
68 const [ isDropdownOpen , setIsDropdownOpen ] = useState ( false ) ;
79
810 const handleLogout = async ( ) => {
@@ -68,7 +70,7 @@ export const Header: React.FC = () => {
6870 className = "fixed inset-0 z-10"
6971 onClick = { ( ) => setIsDropdownOpen ( false ) }
7072 > </ div >
71- < div className = "absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-md shadow-lg py-1 z-20 border border-gray-200 dark:border-gray-700" >
73+ < div className = "absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-md shadow-lg py-1 z-20 border border-gray-200 dark:border-gray-700" >
7274 < div className = "px-4 py-2 border-b border-gray-200 dark:border-gray-700" >
7375 < p className = "text-sm font-medium text-gray-900 dark:text-white" >
7476 { getUserDisplayName ( ) }
@@ -77,6 +79,63 @@ export const Header: React.FC = () => {
7779 < p className = "text-xs text-gray-500 dark:text-gray-400" > { user . email } </ p >
7880 ) }
7981 </ div >
82+
83+ < div className = "px-4 py-3 border-b border-gray-200 dark:border-gray-700" >
84+ < p className = "text-xs font-medium text-gray-500 dark:text-gray-400 mb-2" >
85+ Theme
86+ </ p >
87+ < div className = "space-y-1" >
88+ < button
89+ onClick = { ( ) => {
90+ setTheme ( 'light' ) ;
91+ setIsDropdownOpen ( false ) ;
92+ } }
93+ className = { `flex items-center w-full px-2 py-1.5 text-sm rounded transition-colors ${
94+ theme === 'light'
95+ ? 'bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300'
96+ : 'text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700'
97+ } `}
98+ >
99+ < svg className = "w-4 h-4 mr-2" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
100+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
101+ </ svg >
102+ Light
103+ </ button >
104+ < button
105+ onClick = { ( ) => {
106+ setTheme ( 'dark' ) ;
107+ setIsDropdownOpen ( false ) ;
108+ } }
109+ className = { `flex items-center w-full px-2 py-1.5 text-sm rounded transition-colors ${
110+ theme === 'dark'
111+ ? 'bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300'
112+ : 'text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700'
113+ } `}
114+ >
115+ < svg className = "w-4 h-4 mr-2" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
116+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
117+ </ svg >
118+ Dark
119+ </ button >
120+ < button
121+ onClick = { ( ) => {
122+ setTheme ( 'system' ) ;
123+ setIsDropdownOpen ( false ) ;
124+ } }
125+ className = { `flex items-center w-full px-2 py-1.5 text-sm rounded transition-colors ${
126+ theme === 'system'
127+ ? 'bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-300'
128+ : 'text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700'
129+ } `}
130+ >
131+ < svg className = "w-4 h-4 mr-2" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
132+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
133+ </ svg >
134+ System
135+ </ button >
136+ </ div >
137+ </ div >
138+
80139 < button
81140 onClick = { handleLogout }
82141 className = "block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700"
0 commit comments