mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-19 09:11:54 +03:00
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
import './name-text.css';
|
|
|
|
import emojifyText from '../utils/emojify-text';
|
|
import states from '../utils/states';
|
|
|
|
import Avatar from './avatar';
|
|
|
|
function NameText({ 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={external ? '_blank' : null}
|
|
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>
|
|
);
|
|
}
|
|
|
|
export default NameText;
|