From 1b287b90aadbb825e3774558ee05ee040b99dbf9 Mon Sep 17 00:00:00 2001 From: MK Fain Date: Wed, 3 Dec 2025 20:47:13 -0600 Subject: [PATCH] Add hover close button to FloatingChatButton and hide on settings pages - Added "x" button that appears when hovering over the chat button - Clicking "x" temporarily hides the button until page navigation or refresh - Button no longer appears on /settings/* pages - Reset hidden state when navigating to a different page --- src/components/FloatingChatButton.tsx | 83 +++++++++++++++++++++------ 1 file changed, 65 insertions(+), 18 deletions(-) diff --git a/src/components/FloatingChatButton.tsx b/src/components/FloatingChatButton.tsx index 7ece6a85..cd1f63b1 100644 --- a/src/components/FloatingChatButton.tsx +++ b/src/components/FloatingChatButton.tsx @@ -1,4 +1,6 @@ -import { MessageCircle } from 'lucide-react'; +import { useState, useEffect } from 'react'; +import { useLocation } from 'react-router-dom'; +import { MessageCircle, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { useGlobalChat } from '@/hooks/useGlobalChat'; import { useAppContext } from '@/hooks/useAppContext'; @@ -7,30 +9,75 @@ import { cn } from '@/lib/utils'; export function FloatingChatButton() { const { isOpen, setIsOpen, hasUnread } = useGlobalChat(); const { config } = useAppContext(); + const location = useLocation(); + const [isHovered, setIsHovered] = useState(false); + const [isHiddenTemporarily, setIsHiddenTemporarily] = useState(false); + + // Reset hidden state when navigating to a different page + useEffect(() => { + setIsHiddenTemporarily(false); + }, [location.pathname]); // Don't render if disabled in settings if (config.globalChatEnabled === false) { return null; } + // Don't render on settings pages + if (location.pathname.startsWith('/settings')) { + return null; + } + + // Don't render if temporarily hidden + if (isHiddenTemporarily) { + return null; + } + + const handleClose = (e: React.MouseEvent) => { + e.stopPropagation(); + setIsHiddenTemporarily(true); + }; + return ( - + {/* Close button - appears on hover */} + + + {/* Main chat button */} + + ); }