diff --git a/src/app/components/message/layout/Base.tsx b/src/app/components/message/layout/Base.tsx index ac196a5b77..922e704a78 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) => ( (str.length > len ? `${str.slice(0, len)}...` : str); const [showMore, setShowMore] = useState(false); - const pronouns = profile.pronouns?.map((p: any) => clamp(p.summary, 20)).join('/'); + const pronouns = profile.pronouns?.map((p: any) => clamp(p.summary, 16)).join(', '); const timezone = profile.timezone ? clamp(profile.timezone, 64) : null; const localTime = timezone ? new Intl.DateTimeFormat([], { diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index ff7882aa5a..7e266f913d 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -35,6 +35,7 @@ import { CompactLayout, MessageBase, ModernLayout, + PronounPill, Time, Username, UsernameBold, @@ -249,46 +250,33 @@ function useMobileDoubleTap(callback: () => void, delay = 300) { ); } -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 = clamp( - pronouns - .slice(0, 2) - .map((p) => clamp(p.summary, 48)) - .join('/'), - 128 - ); - const hasMore = pronouns.length > 2; + const display = pronouns.slice(0, limit).map((p) => ( + + {clamp(p.summary, 16)} + + )); - return ( - - - {display} - {hasMore ? '...' : ''} - - - ); -} + if (pronouns.length > limit) { + display.push( + + ... + + ); + } + return <>{display}; +}); function MessageInternal( { @@ -404,7 +392,7 @@ function MessageInternal( {showPronouns && ( - + )} {tagIconSrc && } diff --git a/src/app/features/settings/account/PronounEditor.tsx b/src/app/features/settings/account/PronounEditor.tsx index 8cab2db271..b138c8f2ae 100644 --- a/src/app/features/settings/account/PronounEditor.tsx +++ b/src/app/features/settings/account/PronounEditor.tsx @@ -5,6 +5,7 @@ import { SettingTile } from '$components/setting-tile'; type PronounSet = { summary: string; language?: string; + grammatical_gender?: string; }; type PronounEditorProps = { @@ -13,7 +14,7 @@ type PronounEditorProps = { }; export function PronounEditor({ current, onSave }: PronounEditorProps) { - const initialString = current.map((p) => p.summary).join('/'); + const initialString = current.map((p) => p.summary).join(', '); const [val, setVal] = useState(initialString); useEffect(() => setVal(initialString), [initialString]); @@ -22,10 +23,10 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { if (val === initialString) return; const safeVal = val.slice(0, 128); const next = safeVal - .split('/') + .split(',') .map((s) => s.trim()) .filter(Boolean) - .map((s) => ({ summary: s.slice(0, 16) })); + .map((s) => ({ summary: s.slice(0, 16), language: "en" })); onSave(next); }; @@ -36,7 +37,7 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { return (