diff --git a/src/app/components/message/layout/Base.tsx b/src/app/components/message/layout/Base.tsx index ac196a5b7..922e704a7 100644 --- a/src/app/components/message/layout/Base.tsx +++ b/src/app/components/message/layout/Base.tsx @@ -28,6 +28,10 @@ export const UsernameBold = as<'b'>(({ as: AsUsernameBold = 'b', className, ...p )); +export const PronounPill = as<'span'>(({ as: AsPronounPill = 'span', className, ...props }, ref) => ( + +)); + export const MessageTextBody = as<'div', css.MessageTextBodyVariants & { notice?: boolean }>( ({ as: asComp = 'div', className, preWrap, jumboEmoji, emote, notice, ...props }, ref) => ( void, delay = 300) { ); } -function PronounPill({ summary, tagColor }: { summary: string; tagColor: string }) { - return ( - - - {summary} - - - ); -} - -function PronounTag({ pronouns, tagColor }: { pronouns?: any[]; tagColor: string }) { +const Pronouns = as< + 'div', + { + pronouns?: any[]; + tagColor: string; + } +>(({ pronouns, tagColor, ...props }, ref) => { if (!pronouns || pronouns.length === 0) return null; const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str); + const limit = mobileOrTablet() ? 1 : 3; - const display = pronouns - .slice(0, 3) - .map((p) => ); + const display = pronouns.slice(0, limit).map((p) => ( + + {clamp(p.summary, 16)} + + )); - if (pronouns.length > 3) { - display.push(); + if (pronouns.length > limit) { + display.push( + + ... + + ); } - return display; -} + return <>{display}; +}); function MessageInternal( { @@ -405,7 +392,7 @@ function MessageInternal( {showPronouns && ( - + )} {tagIconSrc && }