mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-22 11:14:23 +03:00
59 lines
1.2 KiB
React
59 lines
1.2 KiB
React
|
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"
|
||
|
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>
|
||
|
);
|
||
|
};
|