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, emojis } = account; let { username } = account; const displayNameWithEmoji = emojifyText(displayName, emojis); if ( !short && username.toLowerCase().trim() === (displayName || '') .replace(/(\:(\w|\+|\-)+\:)(?=|[\!\.\?]|$)/g, '') // Remove shortcodes, regex from https://regex101.com/r/iE9uV0/1 .toLowerCase() .trim() ) { username = null; } return ( { if (external) return; e.preventDefault(); states.showAccount = account; }} > {showAvatar && ( <> {' '} )} {displayName && !short ? ( <> {!showAcct && username && ( <> {' '} @{username} )} ) : short ? ( @{username} ) : ( @{username} )} {showAcct && ( <>
@{acct} )}
); } export default NameText;