Skip to content
67 linesCodeBlameRaw
1import type { GithubRepoLink } from "@g1t/contracts";
2import { siGithub } from "simple-icons";
3
4import { TimeAgo } from "./ui";
5
6/** GitHub's mark (from Simple Icons), for the buttons that go there. */
7export function GithubMark({ className = "size-4" }: { className?: string }) {
8 return (
9 <svg viewBox="0 0 24 24" aria-hidden="true" fill="currentColor" className={className}>
10 <path d={siGithub.path} />
11 </svg>
12 );
13}
14
15/**
16 * "Continue with GitHub": a full page load to /auth/github, which sends the
17 * browser on to GitHub.
18 */
19export function ContinueWithGithub({ href, label = "Continue with GitHub" }: { href: string; label?: string }) {
20 return (
21 <a
22 href={href}
23 className="inline-flex w-full items-center justify-center gap-2 rounded-md border border-line px-3.5 py-2 text-sm font-medium text-fg/90 transition-colors hover:border-line-strong hover:bg-surface hover:text-fg"
24 >
25 <GithubMark />
26 {label}
27 </a>
28 );
29}
30
31/** The rule between "Continue with GitHub" and the form below it. */
32export function OrDivider() {
33 return (
34 <div className="my-6 flex items-center gap-3 text-xs text-faint">
35 <span className="h-px grow bg-line" />
36 or
37 <span className="h-px grow bg-line" />
38 </div>
39 );
40}
41
42/**
43 * Where a repository's code was imported from on GitHub, on its overview,
44 * and when. A repository that stays in step with GitHub says so beside its
45 * name instead, and is managed under Settings → Mirroring.
46 */
47export function GithubLinkStrip({ link }: { link: GithubRepoLink }) {
48 return (
49 <div className="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-line px-4 py-2.5 text-sm">
50 <span className="flex min-w-0 items-start gap-2 text-muted">
51 <GithubMark className="mt-0.5 size-4 shrink-0" />
52 <span className="min-w-0">
53 Imported from{" "}
54 <a href={`https://github.com/${link.fullName}`} className="font-mono break-all text-fg hover:text-accent" target="_blank" rel="noreferrer">
55 github.com/{link.fullName}
56 </a>
57 </span>
58 </span>
59 {link.syncedAt && (
60 <span className="text-xs text-faint">
61 copied <TimeAgo at={link.syncedAt} />
62 </span>
63 )}
64 {link.lastError && <p className="w-full text-xs text-warn">{link.lastError}</p>}
65 </div>
66 );
67}