mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-11 07:56:50 +02:00
* feat(nip-66): add relay discovery and monitor announcement renderers Implements NIP-66 support to display relay health metrics and monitoring information. Users can now view relay performance data (RTT, network type, supported NIPs) and monitor announcements to make informed decisions about relay selection and reliability. Includes 58 comprehensive tests for all helper functions and event parsing. * refactor(nip-66): improve UI with Label, NIPBadge, and clickable titles Enhance NIP-66 renderers with better UI components: - Use NIPBadge component for clickable NIP numbers - Replace section headers with Label component for consistency - Add ClickableEventTitle to monitor announcements - Improve requirement icons with CheckCircle/XCircle for clarity - Add proper icons throughout for better visual hierarchy * refactor(nip-66): use Hammer icon for PoW requirements Replace Zap (lightning bolt) icon with Hammer icon for proof-of-work indicators to better represent the mining/work metaphor. Updates both feed and detail renderers for relay discovery events. * refactor(nip-66): improve feed UI with clickable titles and simplified layout - Add ClickableEventTitle to relay discovery feed items for opening detail view - Remove "Monitoring" label from relay monitor feed items for cleaner layout - Remove unused imports (RelayLink, Label, Activity) from feed renderers - Maintain existing Label and NIPBadge usage in detail renderers * refactor(nip-66): add Label component for check types in monitor feed Add "Check Types" label to relay monitor feed renderer for better visual hierarchy and consistency with detail renderer. * refactor(nip-66): remove Check Types label from monitor feed Remove label title to simplify monitor feed layout - check type badges are displayed directly without a header for cleaner appearance. * refactor(nip-66): use Label component for individual check types in monitor feed Replace Badge components with Label components for check types to match the design system and provide better visual consistency. * refactor(nip-66): rename components to human-readable names Rename NIP-66 component exports to match established naming convention: - Kind10166Renderer → MonitorAnnouncementRenderer - Kind10166DetailRenderer → MonitorAnnouncementDetailRenderer - Kind30166Renderer → RelayDiscoveryRenderer - Kind30166DetailRenderer → RelayDiscoveryDetailRenderer This follows the pattern used elsewhere (e.g., LiveActivityRenderer vs Kind30311Renderer) to make code more readable without memorizing kind numbers. * refactor(nip-66): extract relay kinds display into reusable component Create RelayKindsDisplay component to show accepted/rejected kinds in a consistent format across detail views. Used in RelayDiscoveryDetailRenderer to reduce code duplication and improve maintainability. * refactor(nip-66): extract supported NIPs display into reusable component Create RelaySupportedNips component to show relay-supported NIPs in a consistent format. Used in RelayDiscoveryDetailRenderer to reduce code duplication and improve maintainability. * refactor(nip-66): add icon to supported NIPs component for consistent styling Add FileText icon to RelaySupportedNips Label to match the visual hierarchy pattern used in other relay detail sections (Performance Metrics, Characteristics, Requirements, etc.). * refactor(nip-66): use nicer NIP rendering from RelayViewer in shared component Update RelaySupportedNips component to match RelayViewer's nicer styling: - Show NIP names alongside numbers (showName=true) for better readability - Use gap-2 for better spacing - Use h3 title styling instead of Label with icon - Make component reusable with optional title customization - Use in both RelayViewer and RelayDiscoveryDetailRenderer --------- Co-authored-by: Claude <noreply@anthropic.com>
77 lines
2.3 KiB
TypeScript
77 lines
2.3 KiB
TypeScript
import { Copy, CopyCheck } from "lucide-react";
|
|
import { useRelayInfo } from "../hooks/useRelayInfo";
|
|
import { useCopy } from "../hooks/useCopy";
|
|
import { Button } from "./ui/button";
|
|
import { UserName } from "./nostr/UserName";
|
|
import { RelaySupportedNips } from "./nostr/RelaySupportedNips";
|
|
|
|
export interface RelayViewerProps {
|
|
url: string;
|
|
}
|
|
|
|
export function RelayViewer({ url }: RelayViewerProps) {
|
|
const info = useRelayInfo(url);
|
|
const { copy, copied } = useCopy();
|
|
|
|
return (
|
|
<div className="flex flex-col gap-6 p-4">
|
|
{/* Header */}
|
|
<div className="flex items-center gap-4">
|
|
<div className="flex-1">
|
|
<h2 className="text-2xl font-bold">
|
|
{info?.name || "Unknown Relay"}
|
|
</h2>
|
|
<div className="flex items-center gap-2 text-xs font-mono text-muted-foreground">
|
|
{url}
|
|
<Button
|
|
variant="link"
|
|
size="icon"
|
|
className="size-4 text-muted-foreground"
|
|
onClick={() => copy(url)}
|
|
>
|
|
{copied ? (
|
|
<CopyCheck className="size-3" />
|
|
) : (
|
|
<Copy className="size-3" />
|
|
)}
|
|
</Button>
|
|
</div>
|
|
{info?.description && (
|
|
<p className="text-sm mt-2">{info.description}</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Operator */}
|
|
{(info?.contact || info?.pubkey) && (
|
|
<div>
|
|
<h3 className="mb-2 font-semibold text-sm">Operator</h3>
|
|
<div className="space-y-2 text-sm text-accent">
|
|
{info.contact && info.contact.length == 64 && (
|
|
<UserName pubkey={info.contact} />
|
|
)}
|
|
{info.pubkey && info.pubkey.length === 64 && (
|
|
<UserName pubkey={info.pubkey} />
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* Software */}
|
|
{(info?.software || info?.version) && (
|
|
<div>
|
|
<h3 className="mb-2 font-semibold text-sm">Software</h3>
|
|
<span className="text-sm text-muted-foreground">
|
|
{info.software || info.version}
|
|
</span>
|
|
</div>
|
|
)}
|
|
|
|
{/* Supported NIPs */}
|
|
{info?.supported_nips && (
|
|
<RelaySupportedNips nips={info.supported_nips} />
|
|
)}
|
|
</div>
|
|
);
|
|
}
|