g1t/apps/web/app/components/repo-list.tsx
| 1 | import { BookMarked, Lock } from "lucide-react"; |
| 2 | import { Link } from "react-router"; |
| 3 | |
| 4 | import type { Repo } from "@g1t/contracts"; |
| 5 | |
| 6 | import { EmptyState, Pill, TimeAgo } from "./ui"; |
| 7 | |
| 8 | export function RepoList({ repos }: { repos: Repo[] }) { |
| 9 | if (repos.length === 0) { |
| 10 | return ( |
| 11 | <div className="mt-4"> |
| 12 | <EmptyState title="No repositories yet" /> |
| 13 | </div> |
| 14 | ); |
| 15 | } |
| 16 | return ( |
| 17 | <ul className="mt-4 grid gap-3 sm:grid-cols-2"> |
| 18 | {repos.map((repo) => ( |
| 19 | <li key={repo.id}> |
| 20 | <Link |
| 21 | to={`/${repo.namespace}/${repo.name}`} |
| 22 | className="flex h-full flex-col rounded-xl border border-line bg-surface p-4 transition-colors hover:border-line-strong" |
| 23 | > |
| 24 | <span className="flex items-center gap-2"> |
| 25 | {repo.isPrivate ? ( |
| 26 | <Lock size={15} className="text-faint" /> |
| 27 | ) : ( |
| 28 | <BookMarked size={15} className="text-faint" /> |
| 29 | )} |
| 30 | <span className="truncate font-mono text-sm"> |
| 31 | <span className="text-muted">{repo.namespace}/</span> |
| 32 | <span className="font-medium">{repo.name}</span> |
| 33 | </span> |
| 34 | {repo.isPrivate && <Pill>private</Pill>} |
| 35 | </span> |
| 36 | <span className="mt-2 line-clamp-2 grow text-sm text-muted"> |
| 37 | {repo.description ?? "No description."} |
| 38 | </span> |
| 39 | <span className="mt-3 text-xs text-faint"> |
| 40 | Created <TimeAgo at={repo.createdAt} /> |
| 41 | </span> |
| 42 | </Link> |
| 43 | </li> |
| 44 | ))} |
| 45 | </ul> |
| 46 | ); |
| 47 | } |