summaryrefslogtreecommitdiff
path: root/makima/frontend/src/components/history/TimelineList.tsx
blob: b0348c00bcc0f1ab250a1762bf0027ad2d0ae9d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import type { HistoryEvent } from "../../lib/api";
import { TimelineEventCard } from "./TimelineEventCard";

interface TimelineListProps {
  events: HistoryEvent[];
  loading: boolean;
  error: string | null;
  selectedEvent: HistoryEvent | null;
  onSelectEvent: (event: HistoryEvent) => void;
  onRefresh: () => void;
}

export function TimelineList({
  events,
  loading,
  error,
  selectedEvent,
  onSelectEvent,
  onRefresh,
}: TimelineListProps) {
  return (
    <div className="panel flex flex-col h-full">
      {/* Header */}
      <div className="shrink-0 p-3 border-b border-[rgba(117,170,252,0.15)] flex items-center justify-between">
        <h2 className="font-mono text-xs text-[#9bc3ff] uppercase tracking-wide">
          Timeline
        </h2>
        <button
          onClick={onRefresh}
          disabled={loading}
          className="text-[#7788aa] hover:text-[#9bc3ff] transition-colors disabled:opacity-50"
          title="Refresh timeline"
        >
          <svg
            className={`w-4 h-4 ${loading ? "animate-spin" : ""}`}
            fill="none"
            stroke="currentColor"
            viewBox="0 0 24 24"
          >
            <path
              strokeLinecap="round"
              strokeLinejoin="round"
              strokeWidth={2}
              d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
            />
          </svg>
        </button>
      </div>

      {/* Content */}
      <div className="flex-1 overflow-y-auto">
        {loading && events.length === 0 ? (
          <div className="flex items-center justify-center h-32">
            <div className="font-mono text-[#9bc3ff] text-sm">Loading...</div>
          </div>
        ) : error ? (
          <div className="p-4">
            <div className="font-mono text-red-400 text-xs mb-2">Error loading timeline</div>
            <div className="font-mono text-[#7788aa] text-[10px]">{error}</div>
          </div>
        ) : events.length === 0 ? (
          <div className="flex items-center justify-center h-32">
            <div className="font-mono text-[#7788aa] text-xs">No events found</div>
          </div>
        ) : (
          <div className="divide-y divide-[rgba(117,170,252,0.1)]">
            {events.map((event) => (
              <TimelineEventCard
                key={event.id}
                event={event}
                isSelected={selectedEvent?.id === event.id}
                onClick={() => onSelectEvent(event)}
              />
            ))}
          </div>
        )}
      </div>
    </div>
  );
}