improved live run row

This commit is contained in:
2026-02-07 22:15:41 +01:00
parent a98a481aa4
commit 2f55f3b3fb
2 changed files with 13 additions and 42 deletions
+8 -32
View File
@@ -1,8 +1,6 @@
"use client"; "use client";
import { Eye } from "lucide-react";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { TableRow, TableCell } from "@/components/ui/table"; import { TableRow, TableCell } from "@/components/ui/table";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { LiveRun } from "@/modules/live-run/types"; import { LiveRun } from "@/modules/live-run/types";
@@ -29,48 +27,26 @@ export default function LiveRunRow({
animationFillMode: "forwards", animationFillMode: "forwards",
}} }}
> >
<TableCell className="font-medium pl-5"> {/* Runner */}
<TableCell className="font-medium pl-5 py-5">
{isTop ? `🔥 ${run.username}` : run.username} {isTop ? `🔥 ${run.username}` : run.username}
</TableCell> </TableCell>
<TableCell> {/* Problem + Category */}
<div className="flex flex-col gap-1"> <TableCell>{run.problem}</TableCell>
<span>{run.problem}</span>
<Badge variant="outline" className="w-fit text-xs">
{run.category}
</Badge>
</div>
</TableCell>
{/* Runtime */}
<TableCell <TableCell
className={`font-mono ${isTop ? "text-primary font-bold" : ""}`} className={`font-mono ${isTop ? "text-primary font-bold" : ""}`}
> >
{formatTime(now - run.start, false)} {formatTime(now - run.start, false)}
</TableCell> </TableCell>
{/* Views */}
<TableCell>{isTop ? <Badge>{run.views}</Badge> : run.views}</TableCell> <TableCell>{isTop ? <Badge>{run.views}</Badge> : run.views}</TableCell>
<TableCell> {/* Live status with category color */}
<div className="flex items-center gap-2 text-sm"> <TableCell>{run.category}</TableCell>
<span
className={`h-2 w-2 rounded-full ${
status === "pb"
? "bg-green-500"
: status === "danger"
? "bg-red-500"
: "bg-emerald-400"
}`}
/>
Live
</div>
</TableCell>
<TableCell className="text-right pr-5">
<Button size="sm" variant={isTop ? "default" : "ghost"}>
<Eye className="h-4 w-4 mr-1" />
Watch
</Button>
</TableCell>
</TableRow> </TableRow>
); );
} }
+5 -10
View File
@@ -1,16 +1,12 @@
"use client"; "use client";
import { Zap, Users, Timer, TrendingUp, Eye } from "lucide-react"; import { Card } from "@/components/ui/card";
import { Card, CardHeader, CardTitle } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { import {
Table, Table,
TableBody, TableBody,
TableHead, TableHead,
TableHeader, TableHeader,
TableRow, TableRow,
TableCell,
} from "@/components/ui/table"; } from "@/components/ui/table";
import LiveRunRow from "./components/LiveRunRow"; import LiveRunRow from "./components/LiveRunRow";
import useAction from "@/hook/use-action"; import useAction from "@/hook/use-action";
@@ -18,7 +14,7 @@ import { getLiveRuns } from "@/modules/live-run/actions";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
export default function LiveRuns() { export default function LiveRuns() {
const [liveRuns, liveRunsLoaded, liveRunsError] = useAction(getLiveRuns); const [liveRuns] = useAction(getLiveRuns);
// Sort top runners (status === 'pb') to the top // Sort top runners (status === 'pb') to the top
const sortedRuns = [...(liveRuns || [])]; const sortedRuns = [...(liveRuns || [])];
@@ -53,10 +49,9 @@ export default function LiveRuns() {
<TableRow> <TableRow>
<TableHead className="pl-5">Runner</TableHead> <TableHead className="pl-5">Runner</TableHead>
<TableHead>Problem</TableHead> <TableHead>Problem</TableHead>
<TableHead>Time</TableHead> <TableHead className="w-20">Time</TableHead>
<TableHead>Views</TableHead> <TableHead className="w-20">Views</TableHead>
<TableHead>Status</TableHead> <TableHead className="pr-5">Category</TableHead>
<TableHead className="pr-5" />
</TableRow> </TableRow>
</TableHeader> </TableHeader>