Skip to content

Commit 0c8025f

Browse files
Merge pull request #21 from Skywalker-organa/sanjana/QuestionWindow
Moved page.tsx to new folder
2 parents 672b900 + 8794ed9 commit 0c8025f

File tree

2 files changed

+137
-1
lines changed

2 files changed

+137
-1
lines changed

app/kitchen/page.tsx

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
"use client";
2+
3+
import Link from "next/link";
4+
import Editor from "@/components/Editor/Editor";
5+
import React, { useState } from "react";
6+
import Button from "@/components/ui/Button";
7+
import TabButton from "@/components/ui/TabButton";
8+
import Modal from "@/components/Modal/Modal";
9+
import QuestionWindow from "@/components/ui/QuestionWindow";
10+
import TestCases from "@/components/TestCases/TestCases";
11+
12+
export default function UIPage() {
13+
const [selectedLanguage, setSelectedLanguage] = useState("C++");
14+
const [showModal, setShowModal] = useState<"default" | "green" | "red" | "yellow" | null>(null);
15+
const [questionID, setQuestionID] = useState<number>(1);
16+
17+
const languages = ["C++", "C", "C#", "Java", "Python3", "PHP", "Rust", "Racket", "Ruby","Go"];
18+
19+
const questions = [
20+
{
21+
id: 1,
22+
title: "PROBLEM 1: HELLO WORLD",
23+
points: 10,
24+
content: [
25+
"A queue is an abstract data type that maintains order...",
26+
"A basic queue has the following operations:",
27+
"Enqueue: add to the end.",
28+
"Dequeue: remove from the front.",
29+
],
30+
},
31+
{
32+
id: 2,
33+
title: "PROBLEM 2: STACK IMPLEMENTATION",
34+
points: 15,
35+
content: [
36+
"A stack is a Last-In-First-Out (LIFO) data structure...",
37+
"Operations: Push, Pop, Peek.",
38+
],
39+
},
40+
];
41+
42+
type TestCase = {
43+
id: number;
44+
status: "Passed" | "Failed" | "Error";
45+
input: string;
46+
output: string;
47+
expectedOutput: string;
48+
isHidden: boolean;
49+
};
50+
51+
const defaultResults: TestCase[] = [
52+
{ id: 1, status: "Passed", input: "2 3", output: "5", expectedOutput: "5", isHidden: false },
53+
{ id: 2, status: "Failed", input: "10 4", output: "15", expectedOutput: "14", isHidden: false },
54+
{ id: 4, status: "Passed", input: "10 5", output: "20", expectedOutput: "20", isHidden: false },
55+
{ id: 3, status: "Passed", input: "7 8", output: "15", expectedOutput: "15", isHidden: true },
56+
];
57+
58+
const defaultCompilerDetails = {
59+
isCompileSuccess: false,
60+
message: "Compilation Successful !!",
61+
};
62+
63+
return (
64+
<div className="bg-[#070E0A] min-h-screen p-4 sm:p-6 text-gray-200">
65+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-10">
66+
{/* Left- Question window */}
67+
<div className="bg-[#131414] p-4 sm:p-0 -mt-5">
68+
<QuestionWindow
69+
questions={questions}
70+
questionID={questionID}
71+
setQuestionID={setQuestionID}
72+
/>
73+
</div>
74+
75+
{/*Right: Editor and Test case */}
76+
<div className="flex flex-col space-y-6 mt-0 transform -translate-x-6 translate-y-12">
77+
78+
79+
<div className="bg-[#131414]">
80+
<Editor
81+
languages={languages}
82+
selectedLanguage={selectedLanguage}
83+
onLanguageChange={setSelectedLanguage}
84+
round="Round 1"
85+
timer="00:11:52"
86+
/>
87+
</div>
88+
89+
<div className="bg-[#131414] p-4 sm:p-6 transform scale-90 -translate-x-8">
90+
<TestCases
91+
results={defaultResults}
92+
compilerDetails={defaultCompilerDetails}
93+
/>
94+
</div>
95+
</div>
96+
</div>
97+
98+
{/* Modal showcase */}
99+
<div className="mt-12">
100+
{(["default", "green", "destructive", "secondary"] as const).map((variant) => {
101+
const modalVariant: "default" | "green" | "red" | "yellow" =
102+
variant === "destructive" ? "red" :
103+
variant === "secondary" ? "yellow" :
104+
variant;
105+
const buttonVariant:
106+
| "green" | "secondary" | "destructive" | "link"
107+
| "outline" | "ghost" | "run" =
108+
variant === "default" ? "outline" : variant;
109+
const displayName = modalVariant.charAt(0).toUpperCase() + modalVariant.slice(1);
110+
return (
111+
<div key={variant} className="mb-6">
112+
<div className="flex gap-2 mb-2">
113+
<Button
114+
variant={buttonVariant}
115+
onClick={() => setShowModal(modalVariant)}
116+
>
117+
Show {displayName} Modal
118+
</Button>
119+
</div>
120+
{showModal === modalVariant && (
121+
<Modal
122+
title={`Sample ${displayName} Modal`}
123+
message={`This is a demonstration of the ${modalVariant} Modal variant.`}
124+
variant={modalVariant}
125+
onClose={() => setShowModal(null)}
126+
>
127+
<Button variant={buttonVariant}>Nested Button</Button>
128+
</Modal>
129+
)}
130+
</div>
131+
);
132+
})}
133+
</div>
134+
</div>
135+
);
136+
}

components/ui/QuestionWindow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const QuestionWindow: React.FC<QuestionWindowProps> = ({
6060
</span>
6161
<div className="prose prose-invert prose-sm sm:prose-base max-w-none text-gray-400 space-y-4">
6262
{q.content.map((para, i) => (
63-
<markdown key={i}>{para}</markdown>
63+
<Markdown key={i}>{para}</Markdown>
6464
))}
6565
</div>
6666
</div>

0 commit comments

Comments
 (0)