Skip to content
69 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971import { Link } from "react-router";
2
3import type { Route } from "./+types/stargazers";
4import { Avatar, ButtonLink, EmptyState, TimeAgo } from "../../components/ui";
5import { requireRepo } from "../../lib/access.server";
6import { page } from "../../lib/meta";
7import { repos } from "../../lib/services.server";
8import { unwrap } from "../../lib/session.server";
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)9import { UserCard } from "../../components/user-card";
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9710
11export function meta({ params, ...args }: Route.MetaArgs) {
12 return page(args, { title: `Stargazers · ${params.owner}/${params.repo} · g1t` });
13}
14
15export async function loader({ params, context, request }: Route.LoaderArgs) {
16 const { viewer } = await requireRepo(context, params, "read");
17 const pageNumber = Math.max(1, Number(new URL(request.url).searchParams.get("page")) || 1);
18 const path = { namespace: params.owner, name: params.repo };
19 const [stargazers, stars] = await Promise.all([repos.stargazers(path, viewer, pageNumber), repos.stars(path, viewer)]);
20 return { stargazers: unwrap(stargazers), total: stars.ok ? stars.value.stars : null, page: pageNumber };
21}
22
23export default function Stargazers({ loaderData }: Route.ComponentProps) {
24 const { stargazers, total, page: at } = loaderData;
25 return (
26 <div className="space-y-4">
27 <h2 className="text-lg font-semibold tracking-tight">
28 Stargazers {total != null && <span className="font-normal text-faint">{total.toLocaleString("en-US")}</span>}
29 </h2>
30 {stargazers.length === 0 ? (
31 <EmptyState title={at > 1 ? "No more stargazers" : "No stars yet"}>
32 {at > 1 ? null : "Star it from the button beside Watch, and you show here."}
33 </EmptyState>
34 ) : (
35 <ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
36 {stargazers.map((person) => (
37 <li key={person.username} className="flex items-center gap-3 rounded-xl border border-line bg-surface p-3">
38 <Avatar name={person.username} image={person.avatar} size={36} />
39 <div className="min-w-0">
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)40 <UserCard username={person.username}>
41 <Link to={`/u/${person.username}`} className="block truncate text-sm font-medium hover:text-accent">
42 {person.username}
43 </Link>
44 </UserCard>
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9745 <p className="text-xs text-faint">
46 Starred <TimeAgo at={person.starredAt} />
47 </p>
48 </div>
49 </li>
50 ))}
51 </ul>
52 )}
53 {(at > 1 || stargazers.length === 100) && (
54 <div className="flex justify-center gap-2">
55 {at > 1 && (
56 <ButtonLink variant="quiet" to={`?page=${at - 1}`}>
57 Newer
58 </ButtonLink>
59 )}
60 {stargazers.length === 100 && (
61 <ButtonLink variant="quiet" to={`?page=${at + 1}`}>
62 Older
63 </ButtonLink>
64 )}
65 </div>
66 )}
67 </div>
68 );
69}

This file's history is long; its oldest lines are credited to the oldest commit read.