import { FC, useEffect, useRef } from 'react'; import { LayoutAvatarImageView } from '../../../../common'; import { MentionSuggestion } from '../../../../hooks/rooms/widgets/useChatMentions.helpers'; interface ChatInputMentionSelectorViewProps { suggestions: MentionSuggestion[]; selectedIndex: number; onSelect: (suggestion: MentionSuggestion) => void; onHover: (index: number) => void; /** * When true, render the flat minimalist look (gray list, dark-blue * selection, no header / no kind chip). When false / undefined (default) * the picker wears the Habbo NitroCard chrome. */ newStyle?: boolean; } /** * @-mention autocomplete popover. Two visual modes, both driven by the * "New style" toggle in user settings (memenu.settings.other.catalog.classic.style): * * - newStyle = false (default): cream cardstock, habbo-blue header, * UbuntuCondensed names, kind chips, custom Habbo scrollbar. * - newStyle = true: flat gray list, dark-blue selection, plain text rows. * * Both modes share the same suggestion structure and keyboard contract - * the difference is purely cosmetic. */ export const ChatInputMentionSelectorView: FC = props => { const { suggestions = [], selectedIndex = 0, onSelect = null, onHover = null, newStyle = false } = props; const listRef = useRef(null); useEffect(() => { if(!listRef.current) return; const selected = listRef.current.children[selectedIndex] as HTMLElement; if(selected) selected.scrollIntoView({ block: 'nearest' }); }, [ selectedIndex ]); if(suggestions.length === 0) return null; if(newStyle) { return (
{ suggestions.map((suggestion, index) => { const isSelected = (index === selectedIndex); const rowClass = `px-3 py-1.5 cursor-pointer text-sm flex items-center gap-2 ${ isSelected ? 'bg-[#283F5D] text-white' : 'hover:bg-gray-300' }`; return (
onSelect(suggestion) } onMouseEnter={ () => onHover(index) } > { suggestion.kind === 'user' && suggestion.figure ? (
) : (
@
) } @{ suggestion.name } { suggestion.description && { suggestion.description } }
); }) }
); } return (
@ Mention
{ suggestions.map((suggestion, index) => { const isSelected = (index === selectedIndex); const rowClass = [ 'chat-input-mention-row', isSelected ? 'is-selected' : '' ].filter(Boolean).join(' '); return (
onSelect(suggestion) } onMouseEnter={ () => onHover(index) } > { suggestion.kind === 'user' && suggestion.figure ? (
) : (
@
) }
@{ suggestion.name } { suggestion.description && { suggestion.description } }
{ suggestion.kind === 'alias' ? 'Broadcast' : 'User' }
); }) }
); };