From 9b7f65155df29a80f74603d3ed7249b994e68c5d Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 2 Feb 2026 23:19:09 +0100 Subject: [PATCH] Shadcn-ified run --- src/app/run/page.tsx | 219 ++++++++++++++++++------------------------- 1 file changed, 92 insertions(+), 127 deletions(-) diff --git a/src/app/run/page.tsx b/src/app/run/page.tsx index 0cada5a..d7fe3df 100644 --- a/src/app/run/page.tsx +++ b/src/app/run/page.tsx @@ -1,13 +1,12 @@ "use client"; import { FileTree } from "@sinm/react-file-tree"; -import CodeMirror, { - EditorState, - EditorView, - ReactCodeMirrorRef, -} from "@uiw/react-codemirror"; +import CodeMirror, { EditorState } from "@uiw/react-codemirror"; import { vscodeDark } from "@uiw/codemirror-theme-vscode"; -import { useEffect, useRef } from "react"; + +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Input } from "@/components/ui/input"; +import { Separator } from "@/components/ui/separator"; type RunInfo = { category: "any%" | "100%"; @@ -24,45 +23,6 @@ type ChatMessage = { }; export default function Run() { - const splits = [ - { - problemName: "Two Sum Dash", - splitTime: "0:38", - delta: "-0:04", - isCompleted: true, - pbTime: "0:42", - }, - { - problemName: "Binary Sprint", - splitTime: "1:12", - delta: "+0:02", - isCompleted: true, - pbTime: "0:32", - }, - { - problemName: "String Scramble", - splitTime: "--:--", - delta: undefined, - isCompleted: false, - isCurrent: true, - pbTime: "0:55", - }, - { - problemName: "Linked List Rush", - splitTime: "--:--", - delta: undefined, - isCompleted: false, - pbTime: "1:24", - }, - { - problemName: "Stack Overflow", - splitTime: "--:--", - delta: undefined, - isCompleted: false, - pbTime: "1:42", - }, - ]; - const runInfo: RunInfo = { category: "any%", problems: 5, @@ -71,7 +31,7 @@ export default function Run() { currentAttempt: 47, }; - const chatMessages = [ + const chatMessages: ChatMessage[] = [ { user: "Alice", message: "Nice split!", time: "1:53" }, { user: "Bob", message: "Watch out for the string problem!", time: "1:54" }, { user: "Charlie", message: "PB incoming? 👀", time: "1:55" }, @@ -80,107 +40,112 @@ export default function Run() { return (
{/* Editor */} -
-
- -
-
-
myfile.js
-
- { - if (tr.selection && tr.isUserEvent("select")) { - return []; - } - return tr; - }), - ]} - theme={vscodeDark} - onCreateEditor={(view) => { - view.focus(); - - view.dispatch({ - selection: { anchor: 1 }, - scrollIntoView: true, - }); + + + {/* File tree */} +
+
-
-
+ + {/* Code */} +
+
+ myfile.js +
+ +
+ { + if (tr.selection && tr.isUserEvent("select")) { + return []; + } + return tr; + }), + ]} + theme={vscodeDark} + onCreateEditor={(view) => { + view.focus(); + view.dispatch({ + selection: { anchor: 1 }, + scrollIntoView: true, + }); + }} + /> +
+
+ + {/* Timer & Chat */} -
- - +
+ +
); } -function Timer({ runInfo }: { runInfo: RunInfo }) { +/* ---------------- Timer ---------------- */ + +function RunTimer({ runInfo }: { runInfo: RunInfo }) { return ( -
-
-
+ +
+

1:52.34

-

+

PB: {runInfo.pbTime} | Diff:{" "} +0:12

-
-
+ + ); } -function Chat({ chatMessages }: { chatMessages: ChatMessage[] }) { +/* ---------------- Chat ---------------- */ + +function RunChat({ chatMessages }: { chatMessages: ChatMessage[] }) { return ( -
- {/* Header */} -
-

Chat

- - {chatMessages.length} messages - -
+ + +
+ Chat + + {chatMessages.length} messages + +
+
- {/* Messages area */} -
- {chatMessages.map((msg, idx) => ( -
- {msg.user}:{" "} - {msg.message} - - {msg.time} - -
- ))} -
+ - {/* Input */} -
- -
-
+ + {/* Messages */} +
+ {chatMessages.map((msg, i) => ( +
+ {msg.user}:{" "} + {msg.message} + + {msg.time} + +
+ ))} +
+ + {/* Input */} + +
+ ); }