phanpy/src/components/name-text.jsx

59 lines
1.2 KiB
React
Raw Normal View History

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';
export default ({ account, showAvatar, showAcct, short, external }) => {
const { acct, avatar, avatarStatic, id, url, displayName, username, emojis } =
account;
const displayNameWithEmoji = emojifyText(displayName, emojis);
return (
<a
class={`name-text ${short ? 'short' : ''}`}
href={url}
// target="_blank"
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>
);
};