File tree Expand file tree Collapse file tree 6 files changed +169
-15
lines changed Expand file tree Collapse file tree 6 files changed +169
-15
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import './globals.css'
3
3
import type { Metadata } from 'next'
4
4
import { Inter } from 'next/font/google'
5
5
import Container from '@/components/shared/Container'
6
+ import styles from '@/style/layout.module.css' ;
6
7
7
8
const inter = Inter ( { subsets : [ 'latin' ] } )
8
9
@@ -20,7 +21,7 @@ export default function RootLayout({
20
21
< html lang = "en" >
21
22
< body className = { inter . className } >
22
23
< TitleBar />
23
- < Container > { children } </ Container >
24
+ < Container className = { styles . main_container } > { children } </ Container >
24
25
</ body >
25
26
</ html >
26
27
)
Original file line number Diff line number Diff line change 1
1
import { fetchQuestion } from '@/api/gateway' ;
2
2
import { Question as QnType , ErrorBody , isError } from "@/api/structs" ;
3
+ import styles from '@/style/question.module.css' ;
3
4
import ErrorBlock from '@/components/shared/ErrorBlock' ;
4
5
import React from 'react'
6
+ import QuestionBlock from './question' ;
5
7
6
8
type Props = {
7
9
params : {
8
10
question : string
9
11
}
10
12
}
11
13
12
- const questionBlock = ( question : QnType ) => (
13
- < >
14
- < h1 > It works?</ h1 >
15
- < p > { question . description } </ p >
16
- </ >
17
- ) ;
18
-
19
14
async function Question ( { params } : Props ) {
20
15
const question = await fetchQuestion ( params . question ) ;
21
16
22
17
return (
23
- < div className = "from-white" >
24
- { isError ( question ) ? < ErrorBlock err = { question as ErrorBody } /> : questionBlock ( question as QnType ) }
18
+ < div className = { styles . wrapper } >
19
+ {
20
+ isError ( question )
21
+ ? < ErrorBlock err = { question as ErrorBody } />
22
+ : < QuestionBlock question = { question as QnType } />
23
+ }
25
24
</ div >
26
25
)
27
26
}
Original file line number Diff line number Diff line change
1
+ import { Question , ErrorBody , Difficulty } from "@/api/structs" ;
2
+ import styles from '@/style/question.module.css' ;
3
+
4
+ interface Props {
5
+ question : Question ;
6
+ }
7
+
8
+ const difficultyColor = ( diff : Difficulty ) => {
9
+ return (
10
+ diff === Difficulty . Easy ? < p className = { `${ styles . title } ${ styles . easy } ` } > Easy</ p >
11
+ : diff === Difficulty . Medium ? < p className = { `${ styles . title } ${ styles . med } ` } > Med</ p >
12
+ : < p className = { `${ styles . title } ${ styles . hard } ` } > Hard</ p >
13
+ ) ;
14
+ }
15
+
16
+ function QuestionBlock ( { question } : Props ) {
17
+ const keys = Object . keys ( question . test_cases ) ;
18
+
19
+ const createRow = ( key : string ) => (
20
+ < tr key = { key } >
21
+ < td className = { `${ styles . table } ${ styles . cell } ` } > { key } </ td >
22
+ < td className = { `${ styles . table } ${ styles . cell } ` } > { question . test_cases [ key ] } </ td >
23
+ </ tr >
24
+ ) ;
25
+
26
+ return (
27
+ < >
28
+ < div className = { styles . qn_container } >
29
+ < div className = { styles . title_wrapper } >
30
+ < h1 className = { styles . title } > Q{ question . id } : { question . title } </ h1 >
31
+ { difficultyColor ( question . difficulty ) }
32
+ </ div >
33
+ < br />
34
+ < p > { question . description } </ p >
35
+ < br />
36
+ < table className = { styles . table } >
37
+ < tbody >
38
+ < tr >
39
+ < th className = { `${ styles . table } ${ styles . header } ${ styles . input } ` } > Input</ th >
40
+ < th className = { `${ styles . table } ${ styles . header } ${ styles . output } ` } > Expected Output</ th >
41
+ </ tr >
42
+ { keys . map ( createRow ) }
43
+ </ tbody >
44
+ </ table >
45
+ </ div >
46
+ < form className = { styles . editor_container } >
47
+ < textarea className = { styles . code_editor } />
48
+ </ form >
49
+ </ >
50
+ ) ;
51
+ }
52
+
53
+ export default QuestionBlock ;
Original file line number Diff line number Diff line change 1
1
import React , { ReactNode } from 'react' ;
2
- import styles from '@/style/layout.module.css' ;
3
2
4
3
interface Props {
5
- children : ReactNode
4
+ children : ReactNode ,
5
+ className : string
6
6
}
7
7
8
- function Container ( { children } : Props ) {
8
+ function Container ( { children, className } : Props ) {
9
9
return (
10
- < div className = { styles . container } >
10
+ < div className = { className } >
11
11
{ children }
12
12
</ div >
13
13
)
Original file line number Diff line number Diff line change 6
6
padding : 1px 5px 1px 5px ;
7
7
}
8
8
9
- .container {
9
+ .main_container {
10
10
display : flex;
11
11
flex-direction : column;
12
12
min-width : 100% ;
Original file line number Diff line number Diff line change
1
+ /* TODO: If the window is more tall than wide, flex-direction should flip. */
2
+ .wrapper {
3
+ display : flex;
4
+ flex-direction : row;
5
+ justify-content : space-evenly;
6
+ align-items : flex-start;
7
+ padding : 10px 5px ;
8
+ height : 100% ;
9
+ width : 100% ;
10
+ }
11
+
12
+ .qn_container {
13
+ display : flex;
14
+ flex-direction : column;
15
+ width : 48% ;
16
+ height : 100% ;
17
+ overflow-y : auto;
18
+ scrollbar-width : none;
19
+ -ms-overflow-style : none;
20
+ }
21
+
22
+ .title_wrapper {
23
+ display : flex;
24
+ flex-direction : row;
25
+ justify-content : space-between;
26
+ align-items : center;
27
+ width : 100% ;
28
+ padding : 0px 5px ;
29
+ }
30
+
31
+ .title {
32
+ font-size : large;
33
+ font-family : Helvetica, Arial, sans-serif;
34
+ font-weight : bolder;
35
+ }
36
+
37
+ .easy {
38
+ padding : 1px ;
39
+ background-color : beige;
40
+ border : 1px solid darkgreen;
41
+ border-radius : 5% ;
42
+ color : darkgreen;
43
+ }
44
+
45
+ .med {
46
+ padding : 1px ;
47
+ background-color : azure;
48
+ border : 1px solid darkgoldenrod;
49
+ border-radius : 5% ;
50
+ color : darkgoldenrod;
51
+ }
52
+
53
+ .hard {
54
+ padding : 1px ;
55
+ background-color : mintcream;
56
+ border : 1px solid red;
57
+ border-radius : 5% ;
58
+ color : red;
59
+ }
60
+
61
+ .table {
62
+ text-align : center;
63
+ border : 2px solid grey;
64
+ }
65
+
66
+ .cell {
67
+ font-weight : 300 ;
68
+ }
69
+
70
+ .header {
71
+ font-weight : bold;
72
+ }
73
+
74
+ .input {
75
+ width : 70% ;
76
+ }
77
+
78
+ .output {
79
+ width : 30% ;
80
+ }
81
+
82
+ .editor_container {
83
+ width : 48% ;
84
+ height : 100% ;
85
+ overflow-y : none;
86
+ scrollbar-width : none;
87
+ -ms-overflow-style : none;
88
+ }
89
+
90
+ .code_editor {
91
+ width : 100% ;
92
+ height : 100% ;
93
+ border-radius : 1% ;
94
+ border : 1px darkblue;
95
+ outline : none;
96
+ font-family : 'Courier New' , Courier, monospace;
97
+ background-color : rgb (29 , 29 , 53 );
98
+ color : beige;
99
+ padding : 10px 6px ;
100
+ resize : none;
101
+ }
You can’t perform that action at this time.
0 commit comments