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

PreviewLocalServerCard.tsx

34 lines1.2 KB

1import type { ScopedThreadRef } from "@t3tools/contracts";
2​
3import { PreviewFaviconIcon } from "./PreviewFaviconIcon";
4import type { PreviewableServer } from "./useDiscoveredLocalServers";
5​
6interface Props {
7 threadRef: ScopedThreadRef;
8 server: PreviewableServer;
9 onOpen: () => void;
11​
12export function PreviewLocalServerCard({ threadRef, server, onOpen }: Props) {
13 const subtitle = describeServer(server);
14 return (
15 <button
16 type="button"
17 onClick={onOpen}
18 className="group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
19 >
20 <PreviewFaviconIcon threadRef={threadRef} url={server.requestedUrl} />
21 <div className="flex min-w-0 flex-1 flex-col">
22 <span className="truncate text-sm font-medium text-foreground">{subtitle}</span>
23 <span className="truncate text-xs text-muted-foreground">
24 {server.host}:{server.port}
25 </span>
26 </div>
27 </button>
28 );
30​
31function describeServer(server: PreviewableServer): string {
32 if (server.processName) return server.processName;
33 return "Listening";