mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-11 07:56:50 +02:00
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.
This commit is contained in:
36
src/components/nostr/RelaySupportedNips.tsx
Normal file
36
src/components/nostr/RelaySupportedNips.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { NIPBadge } from "@/components/NIPBadge";
|
||||
|
||||
interface RelaySupportedNipsProps {
|
||||
nips: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Relay Supported NIPs Display Component
|
||||
* Shows supported Nostr Implementation Possibilities (NIPs) for a relay
|
||||
* Used in both Relay Discovery and Monitor Announcement detail views
|
||||
*/
|
||||
export function RelaySupportedNips({ nips }: RelaySupportedNipsProps) {
|
||||
if (nips.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Label className="text-muted-foreground">
|
||||
Supported NIPs ({nips.length})
|
||||
</Label>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{nips.map((nip) => (
|
||||
<NIPBadge
|
||||
key={nip}
|
||||
nipNumber={nip.toString().padStart(2, "0")}
|
||||
showName={false}
|
||||
showNIPPrefix={false}
|
||||
className="text-xs"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { JsonViewer } from "@/components/JsonViewer";
|
||||
import { UserName } from "../UserName";
|
||||
import { NIPBadge } from "@/components/NIPBadge";
|
||||
import { RelayKindsDisplay } from "../RelayKindsDisplay";
|
||||
import { RelaySupportedNips } from "../RelaySupportedNips";
|
||||
import {
|
||||
getRelayUrl,
|
||||
getRttMetrics,
|
||||
@@ -221,24 +221,7 @@ export function RelayDiscoveryDetailRenderer({ event }: { event: NostrEvent }) {
|
||||
)}
|
||||
|
||||
{/* Supported NIPs */}
|
||||
{nips.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
<Label className="text-muted-foreground">
|
||||
Supported NIPs ({nips.length})
|
||||
</Label>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{nips.map((nip) => (
|
||||
<NIPBadge
|
||||
key={nip}
|
||||
nipNumber={nip.toString().padStart(2, "0")}
|
||||
showName={false}
|
||||
showNIPPrefix={false}
|
||||
className="text-xs"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<RelaySupportedNips nips={nips} />
|
||||
|
||||
{/* Relay Kinds */}
|
||||
<RelayKindsDisplay accepted={kinds.accepted} rejected={kinds.rejected} />
|
||||
|
||||
Reference in New Issue
Block a user