@@ -9,7 +9,7 @@ const Sun = () => (
99 xmlns = "http://www.w3.org/2000/svg"
1010 viewBox = "0 0 20 20"
1111 fill = "currentColor"
12- className = "h-6 w-6 text-gray-900 dark:text-gray-100 "
12+ className = "group:hover: text-gray-100 h-6 w-6 "
1313 >
1414 < path
1515 fillRule = "evenodd"
@@ -23,7 +23,7 @@ const Moon = () => (
2323 xmlns = "http://www.w3.org/2000/svg"
2424 viewBox = "0 0 20 20"
2525 fill = "currentColor"
26- className = "h-6 w-6 text-gray-900 dark:text-gray-100 "
26+ className = "group:hover: text-gray-100 h-6 w-6 "
2727 >
2828 < path d = "M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z" />
2929 </ svg >
@@ -37,13 +37,14 @@ const Monitor = () => (
3737 stroke-width = "2"
3838 stroke-linecap = "round"
3939 stroke-linejoin = "round"
40- className = "h-6 w-6 text-gray-900 dark:text-gray-100 "
40+ className = "group:hover: text-gray-100 h-6 w-6 "
4141 >
4242 < rect x = "3" y = "3" width = "14" height = "10" rx = "2" ry = "2" > </ rect >
4343 < line x1 = "7" y1 = "17" x2 = "13" y2 = "17" > </ line >
4444 < line x1 = "10" y1 = "13" x2 = "10" y2 = "17" > </ line >
4545 </ svg >
4646)
47+ const Blank = ( ) => < svg className = "h-6 w-6" />
4748
4849const ThemeSwitch = ( ) => {
4950 const [ mounted , setMounted ] = useState ( false )
@@ -55,8 +56,10 @@ const ThemeSwitch = () => {
5556 return (
5657 < div className = "mr-5" >
5758 < Menu as = "div" className = "relative inline-block text-left" >
58- < div >
59- < Menu . Button > { resolvedTheme === 'dark' ? < Moon /> : < Sun /> } </ Menu . Button >
59+ < div className = "hover:text-primary-500 dark:hover:text-primary-400" >
60+ < Menu . Button >
61+ { mounted ? resolvedTheme === 'dark' ? < Moon /> : < Sun /> : < Blank /> }
62+ </ Menu . Button >
6063 </ div >
6164 < Transition
6265 as = { Fragment }
@@ -72,32 +75,50 @@ const ThemeSwitch = () => {
7275 < div className = "p-1" >
7376 < RadioGroup . Option value = "light" >
7477 < Menu . Item >
75- < button className = "group flex w-full items-center rounded-md px-2 py-2 text-sm" >
76- < div className = "mr-2" >
77- < Sun />
78- </ div >
79- Light
80- </ button >
78+ { ( { active } ) => (
79+ < button
80+ className = { `${
81+ active ? 'bg-primary-600 text-white' : ''
82+ } group flex w-full items-center rounded-md px-2 py-2 text-sm`}
83+ >
84+ < div className = "mr-2" >
85+ < Sun />
86+ </ div >
87+ Light
88+ </ button >
89+ ) }
8190 </ Menu . Item >
8291 </ RadioGroup . Option >
8392 < RadioGroup . Option value = "dark" >
8493 < Menu . Item >
85- < button className = "group flex w-full items-center rounded-md px-2 py-2 text-sm" >
86- < div className = "mr-2" >
87- < Moon />
88- </ div >
89- Dark
90- </ button >
94+ { ( { active } ) => (
95+ < button
96+ className = { `${
97+ active ? 'bg-primary-600 text-white' : ''
98+ } group flex w-full items-center rounded-md px-2 py-2 text-sm`}
99+ >
100+ < div className = "mr-2" >
101+ < Moon />
102+ </ div >
103+ Dark
104+ </ button >
105+ ) }
91106 </ Menu . Item >
92107 </ RadioGroup . Option >
93108 < RadioGroup . Option value = "system" >
94109 < Menu . Item >
95- < button className = "group flex w-full items-center rounded-md px-2 py-2 text-sm" >
96- < div className = "mr-2" >
97- < Monitor />
98- </ div >
99- System
100- </ button >
110+ { ( { active } ) => (
111+ < button
112+ className = { `${
113+ active ? 'bg-primary-600 text-white' : ''
114+ } group flex w-full items-center rounded-md px-2 py-2 text-sm`}
115+ >
116+ < div className = "mr-2" >
117+ < Monitor />
118+ </ div >
119+ System
120+ </ button >
121+ ) }
101122 </ Menu . Item >
102123 </ RadioGroup . Option >
103124 </ div >
0 commit comments