Clickable profiles, open in a new window

This commit is contained in:
Mariusz Kotas 2023-06-27 16:47:36 +02:00
parent 9fd8b65bdf
commit 2c7d1931bd
No known key found for this signature in database
GPG Key ID: B6E53FBA926D958B
3 changed files with 13 additions and 3 deletions

View File

@ -16,3 +16,7 @@
outline: unset;
object-fit: cover;
}
.profile:hover {
opacity: 0.8;
}

View File

@ -2,6 +2,7 @@ import "./profile.css";
import { useUserProfile } from "@snort/system-react";
import { UserMetadata } from "@snort/system";
import { hexToBech32 } from "@snort/shared";
import { linkToProfileHex } from "utils";
import { System } from "index";
export interface ProfileOptions {
@ -32,10 +33,10 @@ export function Profile({
const profile = useUserProfile(System, pubkey);
return (
<div className="profile">
<a href={linkToProfileHex(pubkey)} target="_blank" className="profile">
{(options?.showAvatar ?? true) && <img src={profile?.picture ?? ""} />}
{(options?.showName ?? true) &&
(options?.overrideName ?? getName(pubkey, profile))}
</div>
</a>
);
}

View File

@ -1,8 +1,13 @@
import { NostrEvent } from "@snort/system";
import { hexToBech32 } from "@snort/shared";
export function findTag(e: NostrEvent | undefined, tag: string) {
const maybeTag = e?.tags.find(evTag => {
return evTag[0] === tag;
});
return maybeTag && maybeTag[1];
}
}
export function linkToProfileHex(pubkeyHex: string) {
return `https://snort.social/p/${hexToBech32("npub", pubkeyHex)}`;
}