1
1
"use client" ;
2
2
3
- import { ChevronLeftIcon } from "@radix-ui/react-icons" ;
3
+ import {
4
+ ChevronLeftIcon ,
5
+ ExitIcon ,
6
+ GitHubLogoIcon ,
7
+ } from "@radix-ui/react-icons" ;
4
8
import Link from "next/link" ;
5
9
import { homeRoute } from "../meta" ;
6
10
import { Button } from "../../components/button" ;
@@ -13,10 +17,15 @@ import { withAuth } from "@/hocs/withAuth";
13
17
import { authRoute } from "../auth/meta" ;
14
18
import { AlertDialog } from "../../components/alert-dialog" ;
15
19
import useSupernovaToast from "@/hooks/useSupernovaToast" ;
20
+ import { useTheme } from "next-themes" ;
16
21
17
22
const SettingsPage = ( ) => {
18
23
const { makeToast } = useSupernovaToast ( ) ;
19
24
const router = useRouter ( ) ;
25
+ const [ open , setOpen ] = useState ( false ) ;
26
+ const [ isMounted , setIsMounted ] = useState ( false ) ;
27
+ const { theme, setTheme } = useTheme ( ) ;
28
+
20
29
useEffect ( ( ) => {
21
30
Mousetrap . bind ( "esc" , ( ) => {
22
31
router . push ( homeRoute ) ;
@@ -25,7 +34,18 @@ const SettingsPage = () => {
25
34
Mousetrap . unbind ( "esc" ) ;
26
35
} ;
27
36
} , [ router ] ) ;
28
- const [ open , setOpen ] = useState ( false ) ;
37
+
38
+ useEffect ( ( ) => {
39
+ setIsMounted ( true ) ;
40
+ } , [ ] ) ;
41
+
42
+ useEffect ( ( ) => {
43
+ console . log ( theme ) ;
44
+ } , [ theme ] ) ;
45
+
46
+ if ( ! isMounted ) {
47
+ return null ;
48
+ }
29
49
30
50
return (
31
51
< main className = "flex max-h-screen flex-col items-center pt-5 mb-10 px-5 gap-[10px]" >
@@ -51,7 +71,7 @@ const SettingsPage = () => {
51
71
</ div >
52
72
< h1 className = "text-xl font-semibold" > Settings</ h1 >
53
73
< hr className = "h-[2px] w-32 bg-gray-300" />
54
- < div className = "flex flex-col w-full gap-4" >
74
+ < div className = "flex flex-col w-full max-w-lg gap-4" >
55
75
< div className = "flex justify-between" >
56
76
< div className = "inline-flex gap-2" >
57
77
< Image
@@ -81,26 +101,40 @@ const SettingsPage = () => {
81
101
< Button disabled > Coming soon</ Button >
82
102
</ div >
83
103
< div className = "flex justify-between" >
84
- < div className = "inline-flex gap-2" >
85
- < Image
86
- src = "/icons/svg/github.png"
87
- width = { 25 }
88
- height = { 20 }
89
- unoptimized
90
- alt = "Github icon"
91
- />
104
+ < div className = "inline-flex gap-2 items-center" >
105
+ < GitHubLogoIcon />
92
106
< p > Pull issues and PRs from Github</ p >
93
107
</ div >
94
108
< Button disabled > Coming soon</ Button >
95
109
</ div >
110
+ < div className = "flex justify-between" >
111
+ < div className = "inline-flex gap-2" >
112
+ < p > Appearance</ p >
113
+ </ div >
114
+ < select
115
+ className = "border rounded-md p-1 bg-black text-white"
116
+ name = "appearance"
117
+ value = { theme }
118
+ onChange = { ( e ) => {
119
+ e . currentTarget . value === "system"
120
+ ? setTheme ( "system" )
121
+ : setTheme ( e . currentTarget . value ) ;
122
+ } }
123
+ >
124
+ < option value = "system" > System setting</ option >
125
+ < option value = "light" > Light</ option >
126
+ < option value = "dark" > Dark</ option >
127
+ </ select >
128
+ </ div >
96
129
</ div >
97
130
< Button
98
- className = "mt-auto"
131
+ className = "mt-auto gap-1 "
99
132
onClick = { ( ) => {
100
133
setOpen ( true ) ;
101
134
} }
102
135
>
103
136
Logout
137
+ < ExitIcon />
104
138
</ Button >
105
139
</ main >
106
140
) ;
0 commit comments