From 8751ba26ebf7b7761b9e237f2bf3453623dd1018 Mon Sep 17 00:00:00 2001 From: polwex Date: Mon, 6 Oct 2025 10:13:39 +0700 Subject: added frontend WS connection for demonstration purposes --- gui/src/components/Avatar.tsx | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 gui/src/components/Avatar.tsx (limited to 'gui/src/components/Avatar.tsx') diff --git a/gui/src/components/Avatar.tsx b/gui/src/components/Avatar.tsx new file mode 100644 index 0000000..a071655 --- /dev/null +++ b/gui/src/components/Avatar.tsx @@ -0,0 +1,62 @@ +import useLocalState from "@/state/state"; +import Sigil from "./Sigil"; +import { isValidPatp } from "urbit-ob"; +import type { UserProfile, UserType } from "@/types/nostrill"; +import Icon from "@/components/Icon"; +import UserModal from "./modals/UserModal"; + +export default function ({ + user, + userString, + size, + color, + noClickOnName, + profile, + picOnly = false, +}: { + user: UserType; + userString: string; + size: number; + color?: string; + noClickOnName?: boolean; + profile?: UserProfile; + picOnly?: boolean; +}) { + const { setModal } = useLocalState((s) => ({ setModal: s.setModal })); + // TODO revisit this when %whom updates + console.log({ profile }); + const avatarInner = profile ? ( + + ) : "urbit" in user && isValidPatp(user.urbit) ? ( + + ) : ( + + ); + const avatar = ( +
+ {avatarInner} +
+ ); + if (picOnly) return avatar; + + const tooLong = (s: string) => (s.length > 15 ? " too-long" : ""); + function openModal(e: React.MouseEvent) { + if (noClickOnName) return; + e.stopPropagation(); + setModal(); + } + const name = ( +
+ {profile ? ( +

{profile.name}

+ ) : "urbit" in user ? ( +

+ {user.urbit.length > 28 ? "Anon" : user.urbit} +

+ ) : ( +

{user.nostr}

+ )} +
+ ); + return
{name}
; +} -- cgit v1.2.3