'use client' import { useEffect, useRef, useState } from 'react' interface PostFeedbackMenuProps { /** "Not interested" — hide and send a negative ranking signal. */ onNotInterested: () => void /** "Show more like this" — positive ranking signal. */ onShowMore: () => void className?: string } /** * Per-post overflow ("...") menu exposing negative/positive feed-feedback * actions ("Not interested" / "Show more like this"). Adapted from Bluesky's * requestLess/requestMore affordance into a self-contained dropdown matching * this product's ShareMenu pattern (outside-click + Escape to close). */ export function PostFeedbackMenu({ onNotInterested, onShowMore, className = '', }: PostFeedbackMenuProps) { const [isOpen, setIsOpen] = useState(false) const menuRef = useRef(null) const buttonRef = useRef(null) useEffect(() => { if (!isOpen) return const handleOutside = (event: MouseEvent) => { const target = event.target as Node if ( menuRef.current && !menuRef.current.contains(target) && buttonRef.current && !buttonRef.current.contains(target) ) { setIsOpen(false) } } const handleKey = (e: KeyboardEvent) => { if (e.key === 'Escape') setIsOpen(false) } document.addEventListener('mousedown', handleOutside) document.addEventListener('keydown', handleKey) return () => { document.removeEventListener('mousedown', handleOutside) document.removeEventListener('keydown', handleKey) } }, [isOpen]) const handleSelect = (action: () => void) => { setIsOpen(false) action() } return (
{isOpen && (
)}
) } export default PostFeedbackMenu