github-inline-comments
eldoraui/github-inline-commentsFreeComponent
A github inline comments component.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/github-inline-comments.jsonSource
1"use client"23import { useEffect, useRef, useState } from "react"4import { CheckCircle2, MessageSquarePlus, X } from "lucide-react"56import { cn } from "@/lib/utils"7import { Avatar, AvatarFallback } from "@/components/ui/avatar"8import { Badge } from "@/components/ui/badge"9import { Button } from "@/components/ui/button"10import { Separator } from "@/components/ui/separator"11import { Textarea } from "@/components/ui/textarea"12import {13 Tooltip,14 TooltipContent,15 TooltipProvider,16 TooltipTrigger,17} from "@/components/ui/tooltip"1819type Line =20 | { kind: "hunk"; content: string }21 | { kind: "context"; old: number | null; new: number | null; content: string }22 | { kind: "add"; old: number | null; new: number | null; content: string }23 | { kind: "del"; old: number | null; new: number | null; content: string }2425export default function GithubInlineComments({26 diff,27 fileName,28}: {29 diff: readonly Line[]30 fileName: string31}) {32 return <DiffList diff={diff} fileName={fileName} />33}3435function DiffList({36 diff,37 fileName,38}: {39 diff: readonly Line[]40 fileName: string41}) {42 const rows = diff ?? []4344 // Tracks which line index currently has an open thread45 const [openThreadAt, setOpenThreadAt] = useState<number | null>(null)46 // Tracks thread status per line47 const [resolvedMap, setResolvedMap] = useState<Record<number, boolean>>({})4849 function toggleResolve(idx: number) {50 setResolvedMap((m) => ({ ...m, [idx]: !m[idx] }))51 }5253 return (54 <TooltipProvider delayDuration={150}>55 <div56 role="table"57 aria-label={`Diff of ${fileName}`}58 className="bg-card rounded-md border dark:border-white/10"59 >60 <div className="flex items-center justify-between border-b px-2 py-1 dark:border-white/10">61 <div className="flex items-center gap-2">62 <span className="text-[13px] font-medium">{fileName}</span>63 <Badge64 variant="secondary"65 aria-label="File status"66 className="h-5 px-1.5 text-[11px]"67 >68 modified69 </Badge>70 </div>71 </div>7273 <ol role="rowgroup" className="divide-y dark:divide-white/10">74 {rows.map((line, idx) => {75 const isChange = line.kind === "add" || line.kind === "del"76 const isOpen = openThreadAt === idx77 const isResolved = !!resolvedMap[idx]7879 return (80 <li81 key={idx}82 role="row"83// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| animated-badgeanimated-badge | eldoraui | Components | Free | 2 deps | |
| animated-frameworksanimated-frameworks | eldoraui | Components | Free | 2 deps | |
| animated-grid-patternanimated-grid-pattern | eldoraui | Components | Free | 3 deps | |
| animated-listanimated-list | eldoraui | Components | Free | 1 dep | |
| animated-shiny-buttonanimated-shiny-button | eldoraui | Components | Free | 1 dep | |
| blur-in-textblur-in-text | eldoraui | Components | Free | 3 deps | |
| browserbrowser | eldoraui | Components | Free | 2 deps | |
| card-flip-hovercard-flip-hover | eldoraui | Components | Free | 1 dep |
