Diagnostics Panel
thegridcn/diagnostics-panelFreeComponent
thegridcn publishes no description for this item.
Install it
npx shadcn@latest add https://thegridcn.com/r/diagnostics-panel.jsonSource
1"use client";23import * as React from "react";4import { cn } from "@/lib/utils";56interface DiagnosticMetric {7 label: string;8 status?: "ok" | "warning" | "critical";9 value: number;10}1112interface DiagnosticsPanelProps extends React.HTMLAttributes<HTMLDivElement> {13 metrics: DiagnosticMetric[];14 status?: "online" | "offline" | "degraded";15 title?: string;16}1718const statusDot: Record<string, string> = {19 degraded: "bg-amber-500 shadow-[0_0_6px_rgba(245,158,11,0.6)]",20 offline: "bg-red-500 shadow-[0_0_6px_rgba(239,68,68,0.6)]",21 online: "bg-green-500 shadow-[0_0_6px_rgba(34,197,94,0.6)]",22};2324const statusLabel: Record<string, string> = {25 degraded: "text-amber-500",26 offline: "text-red-500",27 online: "text-green-500",28};2930const metricStatusColor: Record<string, string> = {31 critical: "text-red-500",32 ok: "text-green-500",33 warning: "text-amber-500",34};3536const metricBarColor: Record<string, string> = {37 critical: "bg-red-500",38 ok: "bg-green-500",39 warning: "bg-amber-500",40};4142const metricBarGlow: Record<string, string> = {43 critical: "shadow-[0_0_6px_rgba(239,68,68,0.4)]",44 ok: "shadow-[0_0_6px_rgba(34,197,94,0.4)]",45 warning: "shadow-[0_0_6px_rgba(245,158,11,0.4)]",46};4748function getMetricStatus(49 value: number,50 explicit?: "ok" | "warning" | "critical"51) {52 if (explicit) {53 return explicit;54 }55 if (value >= 80) {56 return "critical";57 }58 if (value >= 60) {59 return "warning";60 }61 return "ok";62}6364export function DiagnosticsPanel({65 metrics,66 title = "DIAGNOSTICS",67 status = "online",68 className,69 ...props70}: DiagnosticsPanelProps) {71 const avgValue = metrics.length72 ? Math.round(metrics.reduce((sum, m) => sum + m.value, 0) / metrics.length)73 : 0;7475 // Staggered bar fill animation76 const [filledBars, setFilledBars] = React.useState<boolean[]>(77 metrics.map(() => false)78 );7980 React.useEffect(() => {81 const timers: ReturnType<typeof setTimeout>[] = [];82 metrics.forEach((_, i) => {83 timers.push(84 setTimeout(85 () => {86 setFilledBars((prev) => {87 const next = [...prev];88 next[i] = true;89 return next;90 });91 },92 150 + i * 12093 )94 );95 });96 return () => timers.forEach(clearTimeout);97 }, [metrics.forEach]); // eslint-disable-line react-hooks/exhaustive-deps9899 return (100 <div101 data-slot="tron-diagnostics-panel"102 data-status={status}103 className={cn(104// … truncated
Files it writes
More from thegridcn
All 139 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | thegridcn | Components | Free | 2 deps | |
| Agent Avataragent-avatar | thegridcn | Components | Free | no deps | |
| Alertalert | thegridcn | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | thegridcn | Components | Free | 1 dep | |
| Announcement Barannouncement-bar | thegridcn | Components | Free | no deps | |
| Anomaly Banneranomaly-banner | thegridcn | Components | Free | no deps | |
| Arrival Panelarrival-panel | thegridcn | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | thegridcn | Components | Free | 1 dep |
