mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(workspace-editor-footer): add error and warning marker count
This commit is contained in:
parent
4736f77cbf
commit
1de4396eaa
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { MarkerSeverity } from "monaco-editor";
|
||||||
import { useProblem } from "@/hooks/use-problem";
|
import { useProblem } from "@/hooks/use-problem";
|
||||||
|
import { CircleXIcon, TriangleAlertIcon } from "lucide-react";
|
||||||
|
|
||||||
interface WorkspaceEditorFooterProps {
|
interface WorkspaceEditorFooterProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -12,7 +14,7 @@ export function WorkspaceEditorFooter({
|
|||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: WorkspaceEditorFooterProps) {
|
}: WorkspaceEditorFooterProps) {
|
||||||
const { editor } = useProblem();
|
const { editor, markers } = useProblem();
|
||||||
const [position, setPosition] = useState<{ lineNumber: number; column: number } | null>(null);
|
const [position, setPosition] = useState<{ lineNumber: number; column: number } | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -39,9 +41,19 @@ export function WorkspaceEditorFooter({
|
|||||||
return (
|
return (
|
||||||
<footer
|
<footer
|
||||||
{...props}
|
{...props}
|
||||||
className={cn("h-9 flex flex-none items-center bg-muted px-3 py-2", className)}
|
className={cn("h-9 flex flex-none items-center px-3 py-2 bg-muted", className)}
|
||||||
>
|
>
|
||||||
<div className="w-full flex items-center justify-end">
|
<div className="w-full flex items-center justify-between px-0.5 truncate">
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<CircleXIcon className="text-red-500" size={20} aria-hidden="true" />
|
||||||
|
{markers.filter((m) => m.severity === MarkerSeverity.Error).length}
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<TriangleAlertIcon className="text-yellow-500" size={20} aria-hidden="true" />
|
||||||
|
{markers.filter((m) => m.severity === MarkerSeverity.Warning).length}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<span className="truncate">
|
<span className="truncate">
|
||||||
{position
|
{position
|
||||||
? `Row ${position.lineNumber}, Column ${position.column}`
|
? `Row ${position.lineNumber}, Column ${position.column}`
|
||||||
|
Loading…
Reference in New Issue
Block a user