Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

GuideNotes.tsx

56 lines1.9 KB

1import type { PullRequestReviewGuideNote } from "@t3tools/contracts";
2​
3import { cn } from "~/lib/utils";
4​
5import { GuideProse } from "./GuideProse";
6​
7export function GuideNoteMarker({ marker }: { marker: string }) {
8 return (
9 <span
10 aria-hidden
11 className="inline-flex size-4.5 shrink-0 items-center justify-center rounded-full bg-info/16 font-medium text-3xs text-info-foreground tabular-nums"
12 >
13 {marker}
14 </span>
15 );
17​
18export function GuideNotes({
19 notes,
20 className,
21}: {
22 notes: ReadonlyArray<{ readonly marker: string; readonly note: PullRequestReviewGuideNote }>;
23 className?: string;
24}) {
25 if (notes.length === 0) return null;
26 return (
27 <section className={cn("flex min-w-0 flex-col gap-2", className)}>
28 <h4 className="flex items-baseline justify-between gap-2 text-xs font-medium text-foreground">
29 Notes on this stop
30 <span className="font-normal text-muted-foreground tabular-nums">
31 {notes.length === 1 ? "1 note" : `${notes.length} notes`}
32 </span>
33 </h4>
34 <ol className="flex flex-col gap-3">
35 {notes.map(({ marker, note }) => (
36 <li key={marker} className="flex min-w-0 gap-2">
37 <GuideNoteMarker marker={marker} />
38 <div className="flex min-w-0 flex-col gap-0.5">
39 <p className="flex flex-wrap items-baseline gap-x-2 text-xs">
40 <span className="font-medium text-foreground">{note.title}</span>
41 <span className="truncate font-mono text-2xs text-muted-foreground">
42 {note.path.split("/").at(-1)}:{note.line}
43 </span>
44 </p>
45 {note.body.trim() !== "" ? (
46 <div className="text-xs text-muted-foreground">
47 <GuideProse text={note.body} />
48 </div>
49 ) : null}
50 </div>
51 </li>
52 ))}
53 </ol>
54 </section>
55 );