55 lines · 1.8 KB
import { Link } from "@tanstack/react-router";
import { Avatar, RelativeTime, StatusDot } from "./ui/Primitives";
import type { StatusState } from "~/lib/types";
import type { CommitBrief } from "~/lib/code-intel";

export function CommitList({
  owner,
  repo,
  commits,
  statuses = {},
}: {
  owner: string;
  repo: string;
  commits: CommitBrief[];
  statuses?: Record<string, StatusState>;
}) {
  return (
    <ul className="divide-y divide-gray-800/70">
      {commits.map((commit) => (
        <li key={commit.sha} className="flex items-center gap-3 px-4 py-3">
          <Avatar name={commit.authorName} size="sm" />
          <div className="min-w-0 flex-1">
            <Link
              to="/$owner/$repo/commit/$sha"
              params={{ owner, repo, sha: commit.sha }}
              className="block truncate text-sm text-gray-100 hover:text-accent-400"
            >
              {commit.subject}
            </Link>
            <div className="text-xs text-gray-500">
              {commit.authorName} committed <RelativeTime timestamp={commit.committedAt} />
            </div>
          </div>
          <StatusDot state={statuses[commit.sha] ?? null} />
          <Link
            to="/$owner/$repo/commit/$sha"
            params={{ owner, repo, sha: commit.sha }}
            className="rounded border border-gray-800 px-2 py-0.5 font-mono text-xs text-gray-400 hover:border-gray-600 hover:text-white"
          >
            {commit.shortSha}