Spaces:
Running
Running
Commit
·
940813c
1
Parent(s):
7a7f75f
pause animation, better filter
Browse files- src/components/runs-list.tsx +14 -17
src/components/runs-list.tsx
CHANGED
@@ -27,21 +27,24 @@ export default function RunsList({
|
|
27 |
onTryRun,
|
28 |
}: RunsListProps) {
|
29 |
const [isPlaying, setIsPlaying] = useState(true);
|
30 |
-
const [
|
31 |
-
const [endFilter, setEndFilter] = useState("");
|
32 |
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
33 |
const listContainerRef = useRef<HTMLDivElement>(null);
|
34 |
const runItemsRef = useRef<Map<number, HTMLDivElement>>(new Map());
|
35 |
|
36 |
// Filter runs based on start and end filters
|
37 |
const filteredRuns = runs.filter((run) => {
|
38 |
-
const
|
39 |
-
run.start_article.toLowerCase().includes(
|
40 |
-
|
41 |
-
|
42 |
-
return matchesStart && matchesEnd;
|
43 |
});
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
// Auto-play functionality
|
46 |
useEffect(() => {
|
47 |
if (isPlaying) {
|
@@ -92,15 +95,9 @@ export default function RunsList({
|
|
92 |
<div className="space-y-2 mb-4">
|
93 |
<div className="flex gap-2 items-center">
|
94 |
<Input
|
95 |
-
placeholder="Filter by
|
96 |
-
value={
|
97 |
-
onChange={(e) =>
|
98 |
-
className="h-9"
|
99 |
-
/>
|
100 |
-
<Input
|
101 |
-
placeholder="Filter by end"
|
102 |
-
value={endFilter}
|
103 |
-
onChange={(e) => setEndFilter(e.target.value)}
|
104 |
className="h-9"
|
105 |
/>
|
106 |
<Button
|
@@ -151,7 +148,7 @@ export default function RunsList({
|
|
151 |
>
|
152 |
<div
|
153 |
className="p-3 flex flex-col gap-2"
|
154 |
-
onClick={() =>
|
155 |
>
|
156 |
<div className="flex items-start justify-between">
|
157 |
<div className="space-y-1">
|
|
|
27 |
onTryRun,
|
28 |
}: RunsListProps) {
|
29 |
const [isPlaying, setIsPlaying] = useState(true);
|
30 |
+
const [filter, setFilter] = useState("");
|
|
|
31 |
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
32 |
const listContainerRef = useRef<HTMLDivElement>(null);
|
33 |
const runItemsRef = useRef<Map<number, HTMLDivElement>>(new Map());
|
34 |
|
35 |
// Filter runs based on start and end filters
|
36 |
const filteredRuns = runs.filter((run) => {
|
37 |
+
const matches = filter === "" ||
|
38 |
+
run.start_article.toLowerCase().includes(filter.toLowerCase()) ||
|
39 |
+
run.destination_article.toLowerCase().includes(filter.toLowerCase());
|
40 |
+
return matches;
|
|
|
41 |
});
|
42 |
|
43 |
+
const _onSelectRun = (runId: number) => {
|
44 |
+
onSelectRun(runId);
|
45 |
+
setIsPlaying(false);
|
46 |
+
};
|
47 |
+
|
48 |
// Auto-play functionality
|
49 |
useEffect(() => {
|
50 |
if (isPlaying) {
|
|
|
95 |
<div className="space-y-2 mb-4">
|
96 |
<div className="flex gap-2 items-center">
|
97 |
<Input
|
98 |
+
placeholder="Filter by article"
|
99 |
+
value={filter}
|
100 |
+
onChange={(e) => setFilter(e.target.value)}
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
className="h-9"
|
102 |
/>
|
103 |
<Button
|
|
|
148 |
>
|
149 |
<div
|
150 |
className="p-3 flex flex-col gap-2"
|
151 |
+
onClick={() => _onSelectRun(originalIndex)}
|
152 |
>
|
153 |
<div className="flex items-start justify-between">
|
154 |
<div className="space-y-1">
|