Spaces:
Running
Running
refactor: update component definitions to function syntax
Browse files- Changed React component definitions from arrow functions to function declarations for ActionInsightsPanel, FilteringPanel, EpisodeLengthHistogram, Card, and StatsPanel for consistency and improved readability.
- Replaced hardcoded delimiter in shortName function with CHART_CONFIG.SERIES_NAME_DELIMITER for better maintainability.
src/components/action-insights-panel.tsx
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
| 10 |
ResponsiveContainer,
|
| 11 |
Tooltip,
|
| 12 |
} from "recharts";
|
|
|
|
|
|
|
| 13 |
import type {
|
| 14 |
CrossEpisodeVarianceData,
|
| 15 |
AggVelocityStat,
|
|
@@ -18,9 +20,6 @@ import type {
|
|
| 18 |
JerkyEpisode,
|
| 19 |
AggAlignment,
|
| 20 |
} from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 21 |
-
import { useFlaggedEpisodes } from "@/context/flagged-episodes-context";
|
| 22 |
-
|
| 23 |
-
const DELIMITER = " | ";
|
| 24 |
|
| 25 |
const FullscreenCtx = React.createContext(false);
|
| 26 |
const useIsFullscreen = () => React.useContext(FullscreenCtx);
|
|
@@ -207,7 +206,7 @@ const COLORS = [
|
|
| 207 |
];
|
| 208 |
|
| 209 |
function shortName(key: string): string {
|
| 210 |
-
const parts = key.split(
|
| 211 |
return parts.length > 1 ? parts[parts.length - 1] : key;
|
| 212 |
}
|
| 213 |
|
|
@@ -1452,12 +1451,12 @@ interface ActionInsightsPanelProps {
|
|
| 1452 |
crossEpisodeLoading: boolean;
|
| 1453 |
}
|
| 1454 |
|
| 1455 |
-
|
| 1456 |
flatChartData,
|
| 1457 |
fps,
|
| 1458 |
crossEpisodeData,
|
| 1459 |
crossEpisodeLoading,
|
| 1460 |
-
})
|
| 1461 |
const [mode, setMode] = useState<"episode" | "dataset">("dataset");
|
| 1462 |
const showAgg = mode === "dataset" && !!crossEpisodeData;
|
| 1463 |
|
|
@@ -1531,7 +1530,7 @@ const ActionInsightsPanel: React.FC<ActionInsightsPanelProps> = ({
|
|
| 1531 |
</FullscreenWrapper>
|
| 1532 |
</div>
|
| 1533 |
);
|
| 1534 |
-
}
|
| 1535 |
|
| 1536 |
export default ActionInsightsPanel;
|
| 1537 |
export { ActionVelocitySection, FullscreenWrapper };
|
|
|
|
| 10 |
ResponsiveContainer,
|
| 11 |
Tooltip,
|
| 12 |
} from "recharts";
|
| 13 |
+
import { useFlaggedEpisodes } from "@/context/flagged-episodes-context";
|
| 14 |
+
import { CHART_CONFIG } from "@/utils/constants";
|
| 15 |
import type {
|
| 16 |
CrossEpisodeVarianceData,
|
| 17 |
AggVelocityStat,
|
|
|
|
| 20 |
JerkyEpisode,
|
| 21 |
AggAlignment,
|
| 22 |
} from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
const FullscreenCtx = React.createContext(false);
|
| 25 |
const useIsFullscreen = () => React.useContext(FullscreenCtx);
|
|
|
|
| 206 |
];
|
| 207 |
|
| 208 |
function shortName(key: string): string {
|
| 209 |
+
const parts = key.split(CHART_CONFIG.SERIES_NAME_DELIMITER);
|
| 210 |
return parts.length > 1 ? parts[parts.length - 1] : key;
|
| 211 |
}
|
| 212 |
|
|
|
|
| 1451 |
crossEpisodeLoading: boolean;
|
| 1452 |
}
|
| 1453 |
|
| 1454 |
+
function ActionInsightsPanel({
|
| 1455 |
flatChartData,
|
| 1456 |
fps,
|
| 1457 |
crossEpisodeData,
|
| 1458 |
crossEpisodeLoading,
|
| 1459 |
+
}: ActionInsightsPanelProps) {
|
| 1460 |
const [mode, setMode] = useState<"episode" | "dataset">("dataset");
|
| 1461 |
const showAgg = mode === "dataset" && !!crossEpisodeData;
|
| 1462 |
|
|
|
|
| 1530 |
</FullscreenWrapper>
|
| 1531 |
</div>
|
| 1532 |
);
|
| 1533 |
+
}
|
| 1534 |
|
| 1535 |
export default ActionInsightsPanel;
|
| 1536 |
export { ActionVelocitySection, FullscreenWrapper };
|
src/components/filtering-panel.tsx
CHANGED
|
@@ -349,14 +349,14 @@ function FlaggedIdsCopyBar({
|
|
| 349 |
);
|
| 350 |
}
|
| 351 |
|
| 352 |
-
|
| 353 |
repoId,
|
| 354 |
crossEpisodeData,
|
| 355 |
crossEpisodeLoading,
|
| 356 |
episodeLengthStats,
|
| 357 |
flatChartData,
|
| 358 |
onViewFlaggedEpisodes,
|
| 359 |
-
})
|
| 360 |
return (
|
| 361 |
<div className="max-w-5xl mx-auto py-6 space-y-8">
|
| 362 |
<div>
|
|
@@ -417,6 +417,6 @@ const FilteringPanel: React.FC<FilteringPanelProps> = ({
|
|
| 417 |
</FullscreenWrapper>
|
| 418 |
</div>
|
| 419 |
);
|
| 420 |
-
}
|
| 421 |
|
| 422 |
export default FilteringPanel;
|
|
|
|
| 349 |
);
|
| 350 |
}
|
| 351 |
|
| 352 |
+
function FilteringPanel({
|
| 353 |
repoId,
|
| 354 |
crossEpisodeData,
|
| 355 |
crossEpisodeLoading,
|
| 356 |
episodeLengthStats,
|
| 357 |
flatChartData,
|
| 358 |
onViewFlaggedEpisodes,
|
| 359 |
+
}: FilteringPanelProps) {
|
| 360 |
return (
|
| 361 |
<div className="max-w-5xl mx-auto py-6 space-y-8">
|
| 362 |
<div>
|
|
|
|
| 417 |
</FullscreenWrapper>
|
| 418 |
</div>
|
| 419 |
);
|
| 420 |
+
}
|
| 421 |
|
| 422 |
export default FilteringPanel;
|
src/components/stats-panel.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
"use client";
|
| 2 |
|
| 3 |
-
import React from "react";
|
| 4 |
import type {
|
| 5 |
DatasetDisplayInfo,
|
| 6 |
EpisodeLengthStats,
|
|
@@ -22,9 +21,11 @@ function formatTotalTime(totalFrames: number, fps: number): string {
|
|
| 22 |
}
|
| 23 |
|
| 24 |
/** SVG bar chart for the episode-length histogram */
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
data: { binLabel: string; count: number }[];
|
| 27 |
-
}
|
| 28 |
if (data.length === 0) return null;
|
| 29 |
const maxCount = Math.max(...data.map((d) => d.count));
|
| 30 |
if (maxCount === 0) return null;
|
|
@@ -99,23 +100,22 @@ const EpisodeLengthHistogram: React.FC<{
|
|
| 99 |
</svg>
|
| 100 |
</div>
|
| 101 |
);
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
<
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
const StatsPanel: React.FC<StatsPanelProps> = ({
|
| 115 |
datasetInfo,
|
| 116 |
episodeLengthStats,
|
| 117 |
loading,
|
| 118 |
-
})
|
| 119 |
const els = episodeLengthStats;
|
| 120 |
|
| 121 |
return (
|
|
@@ -236,6 +236,6 @@ const StatsPanel: React.FC<StatsPanelProps> = ({
|
|
| 236 |
)}
|
| 237 |
</div>
|
| 238 |
);
|
| 239 |
-
}
|
| 240 |
|
| 241 |
export default StatsPanel;
|
|
|
|
| 1 |
"use client";
|
| 2 |
|
|
|
|
| 3 |
import type {
|
| 4 |
DatasetDisplayInfo,
|
| 5 |
EpisodeLengthStats,
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
/** SVG bar chart for the episode-length histogram */
|
| 24 |
+
function EpisodeLengthHistogram({
|
| 25 |
+
data,
|
| 26 |
+
}: {
|
| 27 |
data: { binLabel: string; count: number }[];
|
| 28 |
+
}) {
|
| 29 |
if (data.length === 0) return null;
|
| 30 |
const maxCount = Math.max(...data.map((d) => d.count));
|
| 31 |
if (maxCount === 0) return null;
|
|
|
|
| 100 |
</svg>
|
| 101 |
</div>
|
| 102 |
);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
function Card({ label, value }: { label: string; value: string | number }) {
|
| 106 |
+
return (
|
| 107 |
+
<div className="bg-slate-800/60 rounded-lg p-4 border border-slate-700">
|
| 108 |
+
<p className="text-xs text-slate-400 uppercase tracking-wide">{label}</p>
|
| 109 |
+
<p className="text-xl font-bold tabular-nums mt-1">{value}</p>
|
| 110 |
+
</div>
|
| 111 |
+
);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
function StatsPanel({
|
|
|
|
| 115 |
datasetInfo,
|
| 116 |
episodeLengthStats,
|
| 117 |
loading,
|
| 118 |
+
}: StatsPanelProps) {
|
| 119 |
const els = episodeLengthStats;
|
| 120 |
|
| 121 |
return (
|
|
|
|
| 236 |
)}
|
| 237 |
</div>
|
| 238 |
);
|
| 239 |
+
}
|
| 240 |
|
| 241 |
export default StatsPanel;
|