Show account block in Composer
This commit is contained in:
parent
c5766e431c
commit
a9109f4839
3 changed files with 42 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
||||||
import './account-block.css';
|
import './account-block.css';
|
||||||
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
// import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import enhanceContent from '../utils/enhance-content';
|
import enhanceContent from '../utils/enhance-content';
|
||||||
import niceDateTime from '../utils/nice-date-time';
|
import niceDateTime from '../utils/nice-date-time';
|
||||||
import shortenNumber from '../utils/shorten-number';
|
import shortenNumber from '../utils/shorten-number';
|
||||||
|
@ -21,6 +20,8 @@ function AccountBlock({
|
||||||
onClick,
|
onClick,
|
||||||
showActivity = false,
|
showActivity = false,
|
||||||
showStats = false,
|
showStats = false,
|
||||||
|
accountInstance,
|
||||||
|
hideDisplayName = false,
|
||||||
}) {
|
}) {
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
return (
|
return (
|
||||||
|
@ -35,7 +36,7 @@ function AccountBlock({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const navigate = useNavigate();
|
// const navigate = useNavigate();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
|
@ -53,7 +54,10 @@ function AccountBlock({
|
||||||
note,
|
note,
|
||||||
group,
|
group,
|
||||||
} = account;
|
} = account;
|
||||||
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
let [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
||||||
|
if (accountInstance) {
|
||||||
|
acct2 = `@${accountInstance}`;
|
||||||
|
}
|
||||||
|
|
||||||
const verifiedField = fields?.find((f) => !!f.verifiedAt && !!f.value);
|
const verifiedField = fields?.find((f) => !!f.verifiedAt && !!f.value);
|
||||||
|
|
||||||
|
@ -68,7 +72,8 @@ function AccountBlock({
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (onClick) return onClick(e);
|
if (onClick) return onClick(e);
|
||||||
if (internal) {
|
if (internal) {
|
||||||
navigate(`/${instance}/a/${id}`);
|
// navigate(`/${instance}/a/${id}`);
|
||||||
|
location.hash = `/${instance}/a/${id}`;
|
||||||
} else {
|
} else {
|
||||||
states.showAccount = {
|
states.showAccount = {
|
||||||
account,
|
account,
|
||||||
|
@ -79,14 +84,18 @@ function AccountBlock({
|
||||||
>
|
>
|
||||||
<Avatar url={avatar} size={avatarSize} squircle={bot} />
|
<Avatar url={avatar} size={avatarSize} squircle={bot} />
|
||||||
<span>
|
<span>
|
||||||
{displayName ? (
|
{!hideDisplayName && (
|
||||||
<b>
|
<>
|
||||||
<EmojiText text={displayName} emojis={emojis} />
|
{displayName ? (
|
||||||
</b>
|
<b>
|
||||||
) : (
|
<EmojiText text={displayName} emojis={emojis} />
|
||||||
<b>{username}</b>
|
</b>
|
||||||
|
) : (
|
||||||
|
<b>{username}</b>
|
||||||
|
)}
|
||||||
|
<br />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<br />
|
|
||||||
<span class="account-block-acct">
|
<span class="account-block-acct">
|
||||||
@{acct1}
|
@{acct1}
|
||||||
<wbr />
|
<wbr />
|
||||||
|
|
|
@ -25,6 +25,15 @@
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
#compose-container .compose-top .account-block {
|
||||||
|
text-align: start;
|
||||||
|
pointer-events: none;
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--text-insignificant-color);
|
||||||
|
line-height: 1.1;
|
||||||
|
font-size: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#compose-container textarea {
|
#compose-container textarea {
|
||||||
|
|
|
@ -28,7 +28,8 @@ import supports from '../utils/supports';
|
||||||
import useInterval from '../utils/useInterval';
|
import useInterval from '../utils/useInterval';
|
||||||
import visibilityIconsMap from '../utils/visibility-icons-map';
|
import visibilityIconsMap from '../utils/visibility-icons-map';
|
||||||
|
|
||||||
import Avatar from './avatar';
|
import AccountBlock from './account-block';
|
||||||
|
// import Avatar from './avatar';
|
||||||
import Icon from './icon';
|
import Icon from './icon';
|
||||||
import Loader from './loader';
|
import Loader from './loader';
|
||||||
import Modal from './modal';
|
import Modal from './modal';
|
||||||
|
@ -508,11 +509,16 @@ function Compose({
|
||||||
<div id="compose-container" class={standalone ? 'standalone' : ''}>
|
<div id="compose-container" class={standalone ? 'standalone' : ''}>
|
||||||
<div class="compose-top">
|
<div class="compose-top">
|
||||||
{currentAccountInfo?.avatarStatic && (
|
{currentAccountInfo?.avatarStatic && (
|
||||||
<Avatar
|
// <Avatar
|
||||||
url={currentAccountInfo.avatarStatic}
|
// url={currentAccountInfo.avatarStatic}
|
||||||
size="xl"
|
// size="xl"
|
||||||
alt={currentAccountInfo.username}
|
// alt={currentAccountInfo.username}
|
||||||
squircle={currentAccountInfo?.bot}
|
// squircle={currentAccountInfo?.bot}
|
||||||
|
// />
|
||||||
|
<AccountBlock
|
||||||
|
account={currentAccountInfo}
|
||||||
|
accountInstance={currentAccount.instanceURL}
|
||||||
|
hideDisplayName
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!standalone ? (
|
{!standalone ? (
|
||||||
|
|
Loading…
Add table
Reference in a new issue