From 79cd9bd2bf2844dab23ef0bba7d9cf1c977f77b8 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Sun, 24 May 2026 22:29:03 -0500 Subject: [PATCH] feat: pronoun pill hover details --- .changeset/add-hover-pronouns-list.md | 5 ++ src/app/features/room/message/Message.tsx | 75 ++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 .changeset/add-hover-pronouns-list.md diff --git a/.changeset/add-hover-pronouns-list.md b/.changeset/add-hover-pronouns-list.md new file mode 100644 index 000000000..a302a53be --- /dev/null +++ b/.changeset/add-hover-pronouns-list.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Adds the ability to hover/tap over `...` to see the rest of someone's pronouns. diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index ca1517de8..94b51f1dc 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -11,10 +11,13 @@ import { MenuItem, PopOut, Text, + Tooltip, + TooltipProvider, as, config, + toRem, } from 'folds'; -import type { MouseEventHandler, MouseEvent, ReactNode } from 'react'; +import type { KeyboardEventHandler, MouseEventHandler, MouseEvent, ReactNode } from 'react'; import { memo, useCallback, useRef, useState, useEffect, useMemo } from 'react'; import FocusTrap from 'focus-trap-react'; import { useHover, useFocusWithin } from 'react-aria'; @@ -274,6 +277,72 @@ function useMobileDoubleTap(callback: () => void, delay = 300) { const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str); +type MorePronounsPillProps = { + pronouns: PronounSet[]; + tagColor: string; +}; + +function MorePronounsPill({ pronouns, tagColor }: MorePronounsPillProps) { + const [anchor, setAnchor] = useState(); + + const toggleAnchor = (target: HTMLElement) => { + setAnchor((prev) => (prev ? undefined : target.getBoundingClientRect())); + }; + + const handleClick: MouseEventHandler = (e) => { + e.stopPropagation(); + toggleAnchor(e.currentTarget); + }; + + const handleKeyDown: KeyboardEventHandler = (e) => { + if (e.key !== 'Enter' && e.key !== ' ') return; + e.preventDefault(); + e.stopPropagation(); + toggleAnchor(e.currentTarget); + }; + + // On mobile, tapping the pill pins the tooltip open. + // Tapping anywhere else dismisses it. + useEffect(() => { + if (!anchor) return undefined; + const dismiss = () => setAnchor(undefined); + document.addEventListener('click', dismiss, { once: true }); + return () => document.removeEventListener('click', dismiss); + }, [anchor]); + + const tooltipText = pronouns.map((p) => clamp(p.summary, 16)).join(', '); + + const tooltipContent = ( + + {tooltipText} + + ); + + return ( + <> + + {(triggerRef) => ( + } + style={{ color: tagColor, cursor: 'help' }} + onClick={handleClick} + onKeyDown={handleKeyDown} + role="button" + tabIndex={0} + > + ... + + )} + + {anchor && ( + + {null} + + )} + + ); +} + /** * Component to render pronouns in the chat timeline. * It also filters them. @@ -320,7 +389,9 @@ const Pronouns = as< {clamp(p.summary, 16)} ))} - {visiblePronouns.length > limit && ...} + {visiblePronouns.length > limit && ( + + )} ); });