mirror of
https://litchi.icu/ngc2207/judge.git
synced 2025-05-18 19:56:33 +00:00
feat(playground): add Result component and message display in terminal
This commit is contained in:
parent
e6445dbed0
commit
0c065af788
@ -1,3 +1,4 @@
|
|||||||
|
import Result from "../layout/terminal/result";
|
||||||
import { ClipboardList, MessageSquareCode, TerminalSquare } from "lucide-react";
|
import { ClipboardList, MessageSquareCode, TerminalSquare } from "lucide-react";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
|
||||||
@ -48,9 +49,7 @@ export default function Terminal() {
|
|||||||
</TabsList>
|
</TabsList>
|
||||||
<div className="grow rounded-lg border border-border text-start bg-[#3e4452]">
|
<div className="grow rounded-lg border border-border text-start bg-[#3e4452]">
|
||||||
<TabsContent value="terminal">
|
<TabsContent value="terminal">
|
||||||
<p className="px-4 py-1.5 text-xs text-muted-foreground">
|
<Result />
|
||||||
Content for Tab 1
|
|
||||||
</p>
|
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="comment">
|
<TabsContent value="comment">
|
||||||
<p className="px-4 py-1.5 text-xs text-muted-foreground">
|
<p className="px-4 py-1.5 text-xs text-muted-foreground">
|
||||||
|
56
src/app/playground/layout/terminal/components/message.tsx
Normal file
56
src/app/playground/layout/terminal/components/message.tsx
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { CircleCheck, Info, TriangleAlert } from "lucide-react";
|
||||||
|
|
||||||
|
type MessageType = "info" | "error" | "warning" | "success";
|
||||||
|
|
||||||
|
interface MessageTypeDetails {
|
||||||
|
icon: React.ComponentType<{
|
||||||
|
className: string;
|
||||||
|
size: number;
|
||||||
|
strokeWidth: number;
|
||||||
|
"aria-hidden": boolean;
|
||||||
|
}>;
|
||||||
|
colorClass: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const messageTypeIconMap: Record<MessageType, MessageTypeDetails> = {
|
||||||
|
error: {
|
||||||
|
icon: CircleCheck,
|
||||||
|
colorClass: "text-red-500",
|
||||||
|
},
|
||||||
|
warning: {
|
||||||
|
icon: TriangleAlert,
|
||||||
|
colorClass: "text-amber-500",
|
||||||
|
},
|
||||||
|
success: {
|
||||||
|
icon: CircleCheck,
|
||||||
|
colorClass: "text-emerald-500",
|
||||||
|
},
|
||||||
|
info: {
|
||||||
|
icon: Info,
|
||||||
|
colorClass: "text-blue-500",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
interface MessageProps {
|
||||||
|
type: MessageType;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Message({ type, message }: MessageProps) {
|
||||||
|
const { icon: Icon, colorClass } = messageTypeIconMap[type];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="px-4 py-1">
|
||||||
|
<p className="grow text-sm">
|
||||||
|
<Icon
|
||||||
|
className={`-mt-0.5 me-3 inline-flex ${colorClass}`}
|
||||||
|
size={16}
|
||||||
|
strokeWidth={2}
|
||||||
|
aria-hidden={true}
|
||||||
|
/>
|
||||||
|
{message}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
5
src/app/playground/layout/terminal/result.tsx
Normal file
5
src/app/playground/layout/terminal/result.tsx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { Message } from "./components/message";
|
||||||
|
|
||||||
|
export default function ResultPage() {
|
||||||
|
return <Message type="info" message="This is a message" />;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user