mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-09 06:57:07 +02:00
feat: simplify kind viewer
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { getKindInfo } from "@/constants/kinds";
|
||||
import Command from "./Command";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
import { kinds } from "nostr-tools";
|
||||
import { NIPBadge } from "./NIPBadge";
|
||||
|
||||
// NIP-01 Kind ranges
|
||||
const REPLACEABLE_START = 10000;
|
||||
@@ -46,7 +45,7 @@ export default function KindRenderer({ kind }: { kind: number }) {
|
||||
</div>
|
||||
|
||||
{/* Details Grid */}
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-3 text-sm">
|
||||
<div className="grid grid-cols-2 gap-x-4 gap-y-3 text-sm items-center">
|
||||
<div className="text-muted-foreground">Kind Number</div>
|
||||
<code className="font-mono">{kind}</code>
|
||||
|
||||
@@ -74,35 +73,10 @@ export default function KindRenderer({ kind }: { kind: number }) {
|
||||
{kindInfo.nip && (
|
||||
<>
|
||||
<div className="text-muted-foreground">Defined in</div>
|
||||
<div>
|
||||
<Command
|
||||
name={`NIP-${kindInfo.nip}`}
|
||||
description={`View NIP-${kindInfo.nip} specification`}
|
||||
appId="nip"
|
||||
props={{ number: kindInfo.nip }}
|
||||
/>
|
||||
</div>
|
||||
<NIPBadge nipNumber={kindInfo.nip} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* GitHub Link */}
|
||||
{kindInfo.nip && (
|
||||
<div className="pt-4 border-t border-border">
|
||||
<a
|
||||
href={`https://github.com/nostr-protocol/nips/blob/master/${kindInfo.nip.padStart(
|
||||
2,
|
||||
"0",
|
||||
)}.md`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
View on GitHub
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ import { getNIPInfo } from "../lib/nip-icons";
|
||||
import { useGrimoire } from "@/core/state";
|
||||
|
||||
export interface NIPBadgeProps {
|
||||
nipNumber: number;
|
||||
nipNumber: string;
|
||||
className?: string;
|
||||
showName?: boolean;
|
||||
showNIPPrefix?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,7 @@ export function NIPBadge({
|
||||
nipNumber,
|
||||
className = "",
|
||||
showName = true,
|
||||
showNIPPrefix = true,
|
||||
}: NIPBadgeProps) {
|
||||
const { addWindow } = useGrimoire();
|
||||
const nipInfo = getNIPInfo(nipNumber);
|
||||
@@ -34,12 +36,16 @@ export function NIPBadge({
|
||||
return (
|
||||
<button
|
||||
onClick={openNIP}
|
||||
className={`flex items-center gap-1.5 rounded-md border bg-card px-2.5 py-1.5 text-sm hover:bg-muted/20 cursor-crosshair ${className}`}
|
||||
className={`flex items-center gap-2 border bg-card px-2.5 py-1.5 text-sm hover:underline hover:decoration-dotted cursor-crosshair ${className}`}
|
||||
title={description}
|
||||
>
|
||||
<span className="font-mono font-medium">{nipNumber}</span>
|
||||
<span className="text-muted-foreground">
|
||||
{`${showNIPPrefix ? "NIP-" : ""}${nipNumber}`}
|
||||
</span>
|
||||
{showName && nipInfo && (
|
||||
<span className="text-muted-foreground">· {name}</span>
|
||||
<>
|
||||
<span>{name}</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
|
||||
@@ -73,7 +73,7 @@ export function RelayViewer({ url }: RelayViewerProps) {
|
||||
<h3 className="mb-3 font-semibold text-sm">Supported NIPs</h3>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{info.supported_nips.map((num: number) => (
|
||||
<NIPBadge key={num} nipNumber={num} showName={true} />
|
||||
<NIPBadge key={num} nipNumber={String(num)} showName={true} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user