1
- import { Listbox , Transition } from '@headlessui/react' ;
1
+ import { Dialog , Listbox , Transition } from '@headlessui/react' ;
2
2
import { CheckIcon , SelectorIcon } from '@heroicons/react/solid' ;
3
3
import Editor from '@monaco-editor/react' ;
4
4
import React , { Fragment , useRef , useState } from 'react' ;
@@ -13,6 +13,7 @@ import Header from '../Page/Header';
13
13
import Page from '../Page/Page' ;
14
14
import Leaderboard from '../leaderboard/Leaderboard' ;
15
15
import { languagesList } from '../../assets/languages' ;
16
+ import { XIcon } from '@heroicons/react/outline' ;
16
17
17
18
function classNames ( ...classes : string [ ] ) {
18
19
return classes . filter ( Boolean ) . join ( ' ' ) ;
@@ -28,6 +29,7 @@ const BenchmarkDetail = ({
28
29
match,
29
30
} : RouteComponentProps < BenchmarkDetailParams > ) => {
30
31
const [ selected , setSelected ] = useState ( languages [ 0 ] ) ;
32
+ const [ open , setOpen ] = useState ( false ) ;
31
33
32
34
//Get monaco instance to access code later
33
35
const editorRef : any = useRef < null > ( null ) ;
@@ -103,15 +105,84 @@ const BenchmarkDetail = ({
103
105
lastSubmission = lastSubmissionData . code ;
104
106
}
105
107
108
+ function openLeaderboardPanel ( ) {
109
+ setOpen ( true ) ;
110
+ }
111
+
106
112
return (
107
113
< Page >
114
+ { /*Leaderboard side panel*/ }
115
+ < Transition . Root show = { open } as = { Fragment } >
116
+ < Dialog
117
+ as = "div"
118
+ static
119
+ className = "fixed inset-0 overflow-hidden"
120
+ open = { open }
121
+ onClose = { setOpen }
122
+ >
123
+ < div className = "absolute inset-0 overflow-hidden" >
124
+ < Transition . Child
125
+ as = { Fragment }
126
+ enter = "ease-in-out duration-500"
127
+ enterFrom = "opacity-0"
128
+ enterTo = "opacity-100"
129
+ leave = "ease-in-out duration-500"
130
+ leaveFrom = "opacity-100"
131
+ leaveTo = "opacity-0"
132
+ >
133
+ < Dialog . Overlay className = "absolute inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
134
+ </ Transition . Child >
135
+ < div className = "fixed inset-y-0 right-0 pl-10 max-w-full flex" >
136
+ < Transition . Child
137
+ as = { Fragment }
138
+ enter = "transform transition ease-in-out duration-500 sm:duration-700"
139
+ enterFrom = "translate-x-full"
140
+ enterTo = "translate-x-0"
141
+ leave = "transform transition ease-in-out duration-500 sm:duration-700"
142
+ leaveFrom = "translate-x-0"
143
+ leaveTo = "translate-x-full"
144
+ >
145
+ < div className = "relative w-screen md:w-auto" >
146
+ < Transition . Child
147
+ as = { Fragment }
148
+ enter = "ease-in-out duration-500"
149
+ enterFrom = "opacity-0"
150
+ enterTo = "opacity-100"
151
+ leave = "ease-in-out duration-500"
152
+ leaveFrom = "opacity-100"
153
+ leaveTo = "opacity-0"
154
+ >
155
+ < div className = "absolute top-0 left-0 -ml-8 pt-4 pr-2 flex sm:-ml-10 sm:pr-4" >
156
+ < button
157
+ className = "rounded-md text-gray-300 hover:text-white focus:outline-none focus:ring-2 focus:ring-white"
158
+ onClick = { ( ) => setOpen ( false ) }
159
+ >
160
+ < span className = "sr-only" > Close panel</ span >
161
+ < XIcon className = "h-6 w-6" aria-hidden = "true" />
162
+ </ button >
163
+ </ div >
164
+ </ Transition . Child >
165
+ < div className = "h-full flex flex-col py-6 bg-white shadow-xl overflow-hidden" >
166
+ < div className = "relative flex-1 px-4 sm:px-6" >
167
+ < Leaderboard
168
+ benchmarkId = { benchmarkData ?. id ? benchmarkData . id : '' }
169
+ />
170
+ </ div >
171
+ </ div >
172
+ </ div >
173
+ </ Transition . Child >
174
+ </ div >
175
+ </ div >
176
+ </ Dialog >
177
+ </ Transition . Root >
178
+
108
179
< Header
109
- title = { benchmarkData ?. title || 'eee ' }
180
+ title = { benchmarkData ?. title || 'Failed to load benchmark ' }
110
181
button = "Back"
111
182
navTo = "/benchmarks"
112
183
/>
113
- < div className = "flex p-4 overflow-hidden" >
114
- < div className = "grid flex-1 " >
184
+ < div className = "flex p-4 overflow-hidden " >
185
+ < div className = "grid w-2/5 " >
115
186
< div className = "pl-8 pr-8 border-4 border-dashed border-gray-200 rounded-lg h-96 p-4" >
116
187
< div className = "flex justify-between" >
117
188
< h1 className = "text-2xl pb-3" > Subject</ h1 >
@@ -151,7 +222,7 @@ const BenchmarkDetail = ({
151
222
>
152
223
< Listbox . Options
153
224
static
154
- className = "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-56 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm"
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"
155
226
>
156
227
{ languages . map ( ( language ) => (
157
228
< Listbox . Option
@@ -214,17 +285,27 @@ const BenchmarkDetail = ({
214
285
</ div >
215
286
</ div >
216
287
< ReactMarkdown > { benchmarkData ?. subject || '' } </ ReactMarkdown >
288
+ < div className = "flex" >
289
+ < button
290
+ className = "bg-blue-500 hover:bg-blue-700 text-white font-bold mt-2 py-2 px-4 rounded"
291
+ onClick = { openLeaderboardPanel }
292
+ >
293
+ See Leaderboard
294
+ </ button >
295
+ </ div >
217
296
</ div >
218
297
</ div >
219
- < div className = "grid flex-1 " >
220
- < div className = "bg-gray-500 rounded-lg h-96" >
298
+ < div className = "grid w-3/5 " >
299
+ < div className = "bg-gray-500 h-96" >
221
300
< Editor
222
301
onMount = { handleEditorDidMount }
223
302
height = "100%"
224
303
value = { lastSubmission && lastSubmission }
225
304
language = { selected . name }
226
305
/>
227
- < div className = "grid justify-items-stretch" >
306
+ </ div >
307
+ < div className = "grid justify-items-end" >
308
+ < div className = "flex" >
228
309
< button
229
310
className = "justify-self-end bg-blue-500 hover:bg-blue-700 text-white font-bold mt-2 py-2 px-4 rounded"
230
311
onClick = { ( ) => {
@@ -239,11 +320,12 @@ const BenchmarkDetail = ({
239
320
Run code
240
321
</ button >
241
322
</ div >
242
- < div className = "justify-self-start ml-10" > { result && result } </ div >
243
323
</ div >
244
324
</ div >
245
- < Leaderboard benchmarkId = { benchmarkData ?. id ? benchmarkData . id : '' } />
325
+
326
+ { /*<Leaderboard benchmarkId={benchmarkData?.id ? benchmarkData.id : ''} />*/ }
246
327
</ div >
328
+ < div className = "justify-self-start ml-10" > { result && result } </ div >
247
329
</ Page >
248
330
) ;
249
331
} ;
0 commit comments