mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-24 06:24:42 +01:00
Show additional stats for accounts in search results
This commit is contained in:
parent
d035d18aa0
commit
f67fdd5759
3 changed files with 78 additions and 0 deletions
|
@ -12,3 +12,45 @@
|
||||||
.account-block.skeleton {
|
.account-block.skeleton {
|
||||||
color: var(--bg-faded-color);
|
color: var(--bg-faded-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-block .short-desc {
|
||||||
|
max-height: 1.2em; /* just in case clamping ain't working */
|
||||||
|
}
|
||||||
|
.account-block .short-desc,
|
||||||
|
.account-block .short-desc > * {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 1;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.account-block .short-desc > * + * {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.account-block .short-desc * {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-block .verified-field {
|
||||||
|
color: var(--green-color);
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
.account-block .verified-field .icon {
|
||||||
|
}
|
||||||
|
.account-block .verified-field .invisible {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-block .account-block-stats {
|
||||||
|
margin-top: 2px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: var(--text-insignificant-color);
|
||||||
|
}
|
||||||
|
.account-block .account-block-stats a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
|
@ -2,11 +2,14 @@ import './account-block.css';
|
||||||
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
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 states from '../utils/states';
|
import states from '../utils/states';
|
||||||
|
|
||||||
import Avatar from './avatar';
|
import Avatar from './avatar';
|
||||||
import EmojiText from './emoji-text';
|
import EmojiText from './emoji-text';
|
||||||
|
import Icon from './icon';
|
||||||
|
|
||||||
function AccountBlock({
|
function AccountBlock({
|
||||||
skeleton,
|
skeleton,
|
||||||
|
@ -17,6 +20,7 @@ function AccountBlock({
|
||||||
internal,
|
internal,
|
||||||
onClick,
|
onClick,
|
||||||
showActivity = false,
|
showActivity = false,
|
||||||
|
showStats = false,
|
||||||
}) {
|
}) {
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
return (
|
return (
|
||||||
|
@ -45,9 +49,13 @@ function AccountBlock({
|
||||||
statusesCount,
|
statusesCount,
|
||||||
lastStatusAt,
|
lastStatusAt,
|
||||||
bot,
|
bot,
|
||||||
|
fields,
|
||||||
|
note,
|
||||||
} = account;
|
} = account;
|
||||||
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
||||||
|
|
||||||
|
const verifiedField = fields?.find((f) => !!f.verifiedAt && !!f.value);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
class="account-block"
|
class="account-block"
|
||||||
|
@ -100,6 +108,33 @@ function AccountBlock({
|
||||||
</small>
|
</small>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{showStats && (
|
||||||
|
<div class="account-block-stats">
|
||||||
|
<div
|
||||||
|
class="short-desc"
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: enhanceContent(note, { emojis }),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{bot && (
|
||||||
|
<>
|
||||||
|
<span class="tag">
|
||||||
|
<Icon icon="bot" /> Automated
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!!verifiedField && (
|
||||||
|
<span class="verified-field ib">
|
||||||
|
<Icon icon="check-circle" size="s" />{' '}
|
||||||
|
<span
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: enhanceContent(verifiedField.value, { emojis }),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
|
|
@ -178,6 +178,7 @@ function Search(props) {
|
||||||
<AccountBlock
|
<AccountBlock
|
||||||
account={account}
|
account={account}
|
||||||
instance={instance}
|
instance={instance}
|
||||||
|
showStats
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|
Loading…
Add table
Reference in a new issue