2022-12-10 12:14:48 +03:00
|
|
|
import './name-text.css';
|
|
|
|
|
|
|
|
import emojifyText from '../utils/emojify-text';
|
|
|
|
import states from '../utils/states';
|
|
|
|
|
|
|
|
import Avatar from './avatar';
|
|
|
|
|
2022-12-16 08:27:04 +03:00
|
|
|
function NameText({ account, showAvatar, showAcct, short, external }) {
|
2022-12-10 12:14:48 +03:00
|
|
|
const { acct, avatar, avatarStatic, id, url, displayName, username, emojis } =
|
|
|
|
account;
|
|
|
|
|
|
|
|
const displayNameWithEmoji = emojifyText(displayName, emojis);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<a
|
|
|
|
class={`name-text ${short ? 'short' : ''}`}
|
|
|
|
href={url}
|
2022-12-15 14:45:25 +03:00
|
|
|
target={external ? '_blank' : null}
|
2022-12-10 12:14:48 +03:00
|
|
|
title={`@${acct}`}
|
|
|
|
onClick={(e) => {
|
|
|
|
if (external) return;
|
|
|
|
e.preventDefault();
|
|
|
|
states.showAccount = account;
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{showAvatar && (
|
|
|
|
<>
|
|
|
|
<Avatar url={avatar} />{' '}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
{displayName && !short ? (
|
|
|
|
<>
|
|
|
|
<b
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: displayNameWithEmoji,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{!showAcct && (
|
|
|
|
<>
|
|
|
|
{' '}
|
|
|
|
<i>@{username}</i>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : short ? (
|
|
|
|
<i>@{username}</i>
|
|
|
|
) : (
|
|
|
|
<b>@{username}</b>
|
|
|
|
)}
|
|
|
|
{showAcct && (
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
<i>@{acct}</i>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</a>
|
|
|
|
);
|
2022-12-16 08:27:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export default NameText;
|