All files / src/components/Chatbot TriggerButton.tsx

100% Statements 20/20
100% Branches 7/7
100% Functions 2/2
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  1x 1x     1x     1x   1x 3x   3x 1x 1x   3x 3x 3x   3x 3x 3x 3x   3x 3x 3x   3x  
// Components
import { useChat } from '@/providers/chatbot';
import { ScrollToTopButton } from '../ScrollToTopButton';
 
// Icons
import { ChatbotIcon, CollapseChatIcon } from '../icons/reacts';
 
// Utils
import { combineClasses } from '@shared/utils';
 
export const TriggerButton = () => {
  const { isOpen, toggleVisibility } = useChat();
 
  const handleToggle = () => {
    toggleVisibility();
  };
 
  return (
    <>
      <ScrollToTopButton className="fixed bottom-28 right-9 mb-8 md:mb-5 text-ocean" />
 
      <button
        onClick={handleToggle}
        className={combineClasses('chatButton', isOpen && 'open')}
        aria-label={isOpen ? 'Close Chat' : 'Open Chat'}
      >
        {isOpen ? <CollapseChatIcon /> : <ChatbotIcon />}
      </button>
    </>
  );
};