import { Link } from "@tanstack/react-router"; import { describeActivity } from "~/components/ActivityFeed"; import { Panel } from "~/ui/Panel"; import { RelativeTime } from "~/ui/RelativeTime"; import { TextLink } from "~/ui/TextLink"; import type { getContributions } from "~/fns/contributions"; type Detail = NonNullable>>["detail"]>; type Activity = Detail["activity"]["items"][number]; const SHORT_SHA = 7; const DATE_FORMAT = new Intl.DateTimeFormat(undefined, { weekday: "long", month: "long", day: "numeric", year: "numeric", timeZone: "UTC", }); function plural(count: number, word: string): string { return `${count} ${word}${count === 1 ? "" : "s"}`; } /** Issue and pull request activity links to the thread; everything else to the repository. */ function ActivityLink({ item }: { item: Activity }) { const number = typeof item.data.number === "number" ? item.data.number : null; const isPull = item.kind.startsWith("pull_") || item.data.isPull === true; const params = { owner: item.repo.owner, repo: item.repo.name }; const label = describeActivity(item); if (number !== null && isPull) { return ( {label} ); } if (number !== null && (item.kind.startsWith("issue_") || item.kind === "comment")) { return ( {label} ); } return {label}; } function PageLinks({ owner, page, hasMore, param, }: { owner: string; page: number; hasMore: boolean; param: "repoPage" | "activityPage"; }) { if (page === 1 && !hasMore) return null; return (
{page > 1 ? ( ({ ...previous, [param]: page - 1 === 1 ? undefined : page - 1 })} resetScroll={false} className="text-kumo-subtle hover:text-kumo-strong" > ← Newer ) : ( )} {hasMore && ( ({ ...previous, [param]: page + 1 })} resetScroll={false} className="text-kumo-subtle hover:text-kumo-strong" > More → )}
); } /** The selected day's contributions under the graph; each list pages on its own. */ export function ContributionDayDetails({ owner, detail }: { owner: string; detail: Detail }) { const title = DATE_FORMAT.format(new Date(`${detail.day}T00:00:00Z`)); const empty = detail.commitRepos.total === 0 && detail.activity.total === 0 && detail.privateCount === 0; return ( ({ ...previous, day: undefined, repoPage: undefined, activityPage: undefined })} resetScroll={false} className="text-xs text-kumo-subtle hover:text-kumo-strong" > Close } > {empty &&

No contributions on this day.

} {detail.commitRepos.total > 0 && (

Committed to {detail.commitRepos.total} {detail.commitRepos.total === 1 ? "repository" : "repositories"}

    {detail.commitRepos.items.map((repo) => (
  • {repo.owner}/{repo.name} {plural(repo.commits, "commit")}
    {repo.sample.length > 0 && (
      {repo.sample.map((commit) => (
    • {commit.sha.slice(0, SHORT_SHA)} {commit.subject}
    • ))}
    )}
  • ))}
)} {detail.activity.total > 0 && (

{plural(detail.activity.total, "other contribution")}

    {detail.activity.items.map((item) => (
  1. in {item.repo.owner}/{item.repo.name}
  2. ))}
)} {detail.privateCount > 0 && (

{plural(detail.privateCount, "contribution")} in private repositories.

)}
); }