2023-02-12 14:29:03 +03:00
|
|
|
import './account-block.css';
|
|
|
|
|
|
|
|
import emojifyText from '../utils/emojify-text';
|
2023-03-07 17:36:12 +03:00
|
|
|
import niceDateTime from '../utils/nice-date-time';
|
2023-02-12 14:29:03 +03:00
|
|
|
import states from '../utils/states';
|
|
|
|
|
|
|
|
import Avatar from './avatar';
|
|
|
|
|
|
|
|
function AccountBlock({
|
|
|
|
skeleton,
|
|
|
|
account,
|
|
|
|
avatarSize = 'xl',
|
|
|
|
instance,
|
|
|
|
external,
|
|
|
|
onClick,
|
2023-03-07 17:36:12 +03:00
|
|
|
showActivity = false,
|
2023-02-12 14:29:03 +03:00
|
|
|
}) {
|
|
|
|
if (skeleton) {
|
|
|
|
return (
|
|
|
|
<div class="account-block skeleton">
|
|
|
|
<Avatar size={avatarSize} />
|
|
|
|
<span>
|
|
|
|
<b>████████</b>
|
|
|
|
<br />
|
|
|
|
@██████
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-03-07 17:36:12 +03:00
|
|
|
const {
|
|
|
|
acct,
|
|
|
|
avatar,
|
|
|
|
avatarStatic,
|
|
|
|
displayName,
|
|
|
|
username,
|
|
|
|
emojis,
|
|
|
|
url,
|
|
|
|
statusesCount,
|
|
|
|
lastStatusAt,
|
|
|
|
} = account;
|
2023-02-12 14:29:03 +03:00
|
|
|
const displayNameWithEmoji = emojifyText(displayName, emojis);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<a
|
|
|
|
class="account-block"
|
|
|
|
href={url}
|
|
|
|
target={external ? '_blank' : null}
|
|
|
|
title={`@${acct}`}
|
|
|
|
onClick={(e) => {
|
|
|
|
if (external) return;
|
|
|
|
e.preventDefault();
|
|
|
|
if (onClick) return onClick(e);
|
|
|
|
states.showAccount = {
|
|
|
|
account,
|
|
|
|
instance,
|
|
|
|
};
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Avatar url={avatar} size={avatarSize} />
|
|
|
|
<span>
|
|
|
|
{displayName ? (
|
|
|
|
<b
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: displayNameWithEmoji,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<b>{username}</b>
|
|
|
|
)}
|
|
|
|
<br />@{acct}
|
2023-03-07 17:36:12 +03:00
|
|
|
{showActivity && (
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
<small class="last-status-at insignificant">
|
|
|
|
Posts: {statusesCount}
|
|
|
|
{!!lastStatusAt && (
|
|
|
|
<>
|
|
|
|
{' '}
|
|
|
|
· Last posted:{' '}
|
|
|
|
{niceDateTime(lastStatusAt, {
|
|
|
|
hideTime: true,
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</small>
|
|
|
|
</>
|
|
|
|
)}
|
2023-02-12 14:29:03 +03:00
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AccountBlock;
|