feat: profile & badge sets

This commit is contained in:
Alejandro Gómez
2026-03-31 23:02:24 +02:00
parent fcc9b50d25
commit 4e694945b3
4 changed files with 20 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import {
getBadgeImageUrl,
} from "@/lib/nip58-helpers";
import { Award } from "lucide-react";
import { getTagValue } from "applesauce-core/helpers";
import { UserName } from "../UserName";
import { ClickableEventTitle } from "./BaseEventRenderer";
@@ -125,12 +126,14 @@ export function ProfileBadgesDetailRenderer({
event,
}: ProfileBadgesDetailRendererProps) {
const badgePairs = getProfileBadgePairs(event);
const isProfileBadges = getTagValue(event, "d") === "profile_badges";
const heading = isProfileBadges ? "Profile Badges" : "Badge Set";
return (
<div className="flex flex-col gap-6 p-6 max-w-4xl mx-auto">
{/* Header */}
<div className="flex flex-col gap-2">
<h1 className="text-3xl font-bold">Profile Badges</h1>
<h1 className="text-3xl font-bold">{heading}</h1>
<div className="flex items-center gap-2 text-sm text-muted-foreground">
<UserName pubkey={event.pubkey} />
<span></span>

View File

@@ -13,6 +13,7 @@ import {
getBadgeImageUrl,
} from "@/lib/nip58-helpers";
import { Award } from "lucide-react";
import { getTagValue } from "applesauce-core/helpers";
/**
* Parse an address pointer from an a tag value
@@ -78,6 +79,8 @@ function BadgeItem({ badgeAddress }: { badgeAddress: string }) {
*/
export function ProfileBadgesRenderer({ event }: BaseEventProps) {
const badgePairs = getProfileBadgePairs(event);
const isProfileBadges = getTagValue(event, "d") === "profile_badges";
const heading = isProfileBadges ? "Profile Badges" : "Badge Set";
const MAX_VISIBLE_BADGES = 5;
const visibleBadges = badgePairs.slice(0, MAX_VISIBLE_BADGES);
const remainingCount = Math.max(0, badgePairs.length - MAX_VISIBLE_BADGES);
@@ -101,7 +104,8 @@ export function ProfileBadgesRenderer({ event }: BaseEventProps) {
event={event}
className="text-sm font-semibold text-foreground hover:text-foreground/80"
>
{badgePairs.length} {badgePairs.length === 1 ? "badge" : "badges"}
{heading}: {badgePairs.length}{" "}
{badgePairs.length === 1 ? "badge" : "badges"}
</ClickableEventTitle>
{/* Limited Badge Thumbnails */}

View File

@@ -268,6 +268,7 @@ const kindRenderers: Record<number, React.ComponentType<BaseEventProps>> = {
30005: VideoCurationSetRenderer, // Video Curation Sets (NIP-51)
30006: PictureCurationSetRenderer, // Picture Curation Sets (NIP-51)
30007: KindMuteSetRenderer, // Kind Mute Sets (NIP-51)
10008: ProfileBadgesRenderer, // Profile Badges (NIP-58)
30008: ProfileBadgesRenderer, // Profile Badges (NIP-58)
30009: BadgeDefinitionRenderer, // Badge (NIP-58)
30015: InterestSetRenderer, // Interest Sets (NIP-51)
@@ -388,6 +389,7 @@ const detailRenderers: Record<
30005: VideoCurationSetDetailRenderer, // Video Curation Sets Detail (NIP-51)
30006: PictureCurationSetDetailRenderer, // Picture Curation Sets Detail (NIP-51)
30007: KindMuteSetDetailRenderer, // Kind Mute Sets Detail (NIP-51)
10008: ProfileBadgesDetailRenderer, // Profile Badges Detail (NIP-58)
30008: ProfileBadgesDetailRenderer, // Profile Badges Detail (NIP-58)
30009: BadgeDefinitionDetailRenderer, // Badge Detail (NIP-58)
30015: InterestSetDetailRenderer, // Interest Sets Detail (NIP-51)

View File

@@ -790,6 +790,13 @@ export const EVENT_KINDS: Record<number | string, EventKind> = {
nip: "51",
icon: Search,
},
10008: {
kind: 10008,
name: "Profile Badge",
description: "Profile Badges",
nip: "58",
icon: Award,
},
10009: {
kind: 10009,
name: "User Group List",
@@ -1183,8 +1190,8 @@ export const EVENT_KINDS: Record<number | string, EventKind> = {
},
30008: {
kind: 30008,
name: "Profile Badge",
description: "Profile Badges",
name: "Badge Set",
description: "Badge Set",
nip: "58",
icon: Award,
},