@@ -14,6 +14,7 @@ import Page from '../Page/Page';
14
14
import Leaderboard from '../leaderboard/Leaderboard' ;
15
15
import { languagesList } from '../../assets/languages' ;
16
16
import { XIcon } from '@heroicons/react/outline' ;
17
+ import useDarkMode from '../../hooks/darkmode' ;
17
18
18
19
function classNames ( ...classes : string [ ] ) {
19
20
return classes . filter ( Boolean ) . join ( ' ' ) ;
@@ -30,10 +31,13 @@ const BenchmarkDetail = ({
30
31
} : RouteComponentProps < BenchmarkDetailParams > ) => {
31
32
const [ selected , setSelected ] = useState ( languages [ 0 ] ) ;
32
33
const [ open , setOpen ] = useState ( false ) ;
34
+ const [ colorTheme ] = useDarkMode ( ) ;
33
35
34
36
//Get monaco instance to access code later
35
37
const editorRef : any = useRef < null > ( null ) ;
36
38
39
+ let editorTheme = colorTheme === 'dark' ? 'light' : 'vs-dark' ;
40
+
37
41
function handleEditorDidMount ( editor : any , monaco : any ) {
38
42
editorRef . current = editor ;
39
43
}
@@ -185,16 +189,16 @@ const BenchmarkDetail = ({
185
189
< div className = "grid w-2/5" >
186
190
< div className = "pl-8 pr-8 border-4 border-dashed border-gray-200 rounded-lg h-96 p-4" >
187
191
< div className = "flex justify-between" >
188
- < h1 className = "text-2xl pb-3" > Subject</ h1 >
192
+ < h1 className = "text-2xl pb-3 dark:text-white " > Subject</ h1 >
189
193
< div className = "" >
190
194
< Listbox value = { selected } onChange = { setSelected } >
191
195
{ ( { open } ) => (
192
196
< >
193
- < Listbox . Label className = "block text-sm font-medium text-gray-700" >
197
+ < Listbox . Label className = "block dark:text-white text-sm font-medium text-gray-700" >
194
198
Languages
195
199
</ Listbox . Label >
196
200
< div className = "mt-1 relative" >
197
- < Listbox . Button className = "relative w-full bg-white border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" >
201
+ < Listbox . Button className = "dark:text-white dark:bg-gray-800 relative w-full bg-white border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" >
198
202
< span className = "flex items-center" >
199
203
< img
200
204
src = { selected . avatar }
@@ -222,7 +226,7 @@ const BenchmarkDetail = ({
222
226
>
223
227
< Listbox . Options
224
228
static
225
- className = "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-96 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
229
+ className = "dark:text-white dark:bg-gray-800 absolute z-10 mt-1 w-full bg-white shadow-lg max-h-96 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
226
230
>
227
231
{ languages . map ( ( language ) => (
228
232
< Listbox . Option
@@ -231,7 +235,7 @@ const BenchmarkDetail = ({
231
235
classNames (
232
236
active
233
237
? 'text-white bg-indigo-600'
234
- : 'text-gray-900' ,
238
+ : 'text-gray-900 dark:text-white ' ,
235
239
'cursor-default select-none relative py-2 pl-3 pr-9' ,
236
240
)
237
241
}
@@ -262,7 +266,7 @@ const BenchmarkDetail = ({
262
266
className = { classNames (
263
267
active
264
268
? 'text-white'
265
- : 'text-indigo-600' ,
269
+ : 'text-indigo-600 dark:text-white ' ,
266
270
'absolute inset-y-0 right-0 flex items-center pr-4' ,
267
271
) }
268
272
>
@@ -284,7 +288,9 @@ const BenchmarkDetail = ({
284
288
</ Listbox >
285
289
</ div >
286
290
</ div >
287
- < ReactMarkdown > { benchmarkData ?. subject || '' } </ ReactMarkdown >
291
+ < ReactMarkdown className = "dark:text-white" >
292
+ { benchmarkData ?. subject || '' }
293
+ </ ReactMarkdown >
288
294
< div className = "flex" >
289
295
< button
290
296
className = "bg-blue-500 hover:bg-blue-700 text-white font-bold mt-2 py-2 px-4 rounded-full"
@@ -300,6 +306,7 @@ const BenchmarkDetail = ({
300
306
< Editor
301
307
onMount = { handleEditorDidMount }
302
308
height = "100%"
309
+ theme = { editorTheme }
303
310
value = { lastSubmission && lastSubmission }
304
311
language = { selected . name }
305
312
/>
0 commit comments