jevstrudel.git / website / src / jev / NameLink.jsx
NameLink.jsx23 lines · 756 B · raw
1// A listener's name that opens their profile (profile.mjs, Profile.jsx):
2// every name the site shows goes through this. Without an account id (a
3// visitor not signed in, or an old payload) it is the name as text.
4import { openProfile } from './profile.mjs';
5
6export function NameLink({ id, name, className = '' }) {
7  const text = name ?? 'a listener';
8  if (!id) return <b className={className}>{text}</b>;
9  return (
10    <button
11      type="button"
12      className={`font-bold underline decoration-dotted underline-offset-2 hover:opacity-70 ${className}`}
13      title={`${text}'s profile`}
14      data-testid="jev-name-link"
15      onClick={(e) => {
16        e.stopPropagation();
17        openProfile(id);
18      }}
19    >
20      {text}
21    </button>
22  );
23}