@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 53 lines 2.1 KB
Raw
1 import { useGT } from "gt-react";
2 import type { ScopedThreadRef } from "@t3tools/contracts";
3 import { X } from "lucide-react";
4
5 import { isValidHistoryTimestamp, type BrowserHistoryEntry } from "~/browserHistoryStore";
6 import { RelativeTime } from "~/components/RelativeTime";
7
8 import { PreviewFaviconIcon } from "./PreviewFaviconIcon";
9
10 interface Props {
11 threadRef: ScopedThreadRef;
12 entry: BrowserHistoryEntry;
13 onOpen: () => void;
14 onRemove: () => void;
15 }
16
17 export function PreviewRecentUrlCard({ threadRef, entry, onOpen, onRemove }: Props) {
18 const gt = useGT();
19 const parsed = new URL(entry.url);
20 const path = parsed.pathname === "/" ? "" : parsed.pathname;
21 const label = `${parsed.host}${path}${parsed.search}${parsed.hash}`;
22 const visitedAt = isValidHistoryTimestamp(entry.lastVisitedAt) ? (
23 <RelativeTime timestamp={new Date(entry.lastVisitedAt).toISOString()} />
24 ) : null;
25 return (
26 <div className="group relative flex w-full items-center">
27 <button
28 type="button"
29 onClick={onOpen}
30 className="flex w-full items-center gap-3 px-3 py-3 pr-10 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
31 >
32 <PreviewFaviconIcon threadRef={threadRef} url={entry.url} />
33 <div className="flex min-w-0 flex-1 flex-col">
34 <span className="truncate text-sm font-medium text-foreground">
35 {entry.title ?? label}
36 </span>
37 <span className="truncate text-xs text-muted-foreground">
38 {entry.title ? `${label} · ` : ""}
39 {visitedAt}
40 </span>
41 </div>
42 </button>
43 <button
44 type="button"
45 aria-label={gt("Remove {url} from history", { url: label })}
46 onClick={onRemove}
47 className="absolute right-3 rounded p-1 text-muted-foreground opacity-0 hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring group-hover:opacity-100"
48 >
49 <X className="size-3.5" />
50 </button>
51 </div>
52 );
53 }